Statistics
| Revision:

root / trunk / libraries / libGPE / src-test / org / gvsig / gpe / writers / GPEPointsLayerTest.java @ 11247

History | View | Annotate | Download (4.04 KB)

1
package org.gvsig.gpe.writers;
2

    
3
import java.io.File;
4

    
5
import org.gvsig.gpe.GPEErrorHandler;
6
import org.gvsig.gpe.containers.Element;
7
import org.gvsig.gpe.containers.Feature;
8
import org.gvsig.gpe.containers.Layer;
9

    
10
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
11
 *
12
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
13
 *
14
 * This program is free software; you can redistribute it and/or
15
 * modify it under the terms of the GNU General Public License
16
 * as published by the Free Software Foundation; either version 2
17
 * of the License, or (at your option) any later version.
18
 *
19
 * This program is distributed in the hope that it will be useful,
20
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
 * GNU General Public License for more details.
23
 *
24
 * You should have received a copy of the GNU General Public License
25
 * along with this program; if not, write to the Free Software
26
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
27
 *
28
 * For more information, contact:
29
 *
30
 *  Generalitat Valenciana
31
 *   Conselleria d'Infraestructures i Transport
32
 *   Av. Blasco Ib??ez, 50
33
 *   46010 VALENCIA
34
 *   SPAIN
35
 *
36
 *      +34 963862235
37
 *   gvsig@gva.es
38
 *      www.gvsig.gva.es
39
 *
40
 *    or
41
 *
42
 *   IVER T.I. S.A
43
 *   Salamanca 50
44
 *   46005 Valencia
45
 *   Spain
46
 *
47
 *   +34 963163400
48
 *   dac@iver.es
49
 */
50
/* CVS MESSAGES:
51
 *
52
 * $Id: GPEPointsLayerTest.java 11247 2007-04-19 07:30:40Z jorpiell $
53
 * $Log$
54
 * Revision 1.3  2007-04-19 07:23:20  jorpiell
55
 * Add the add methods to teh contenhandler and change the register mode
56
 *
57
 * Revision 1.2  2007/04/14 16:06:35  jorpiell
58
 * Add the container classes
59
 *
60
 * Revision 1.1  2007/04/13 07:17:54  jorpiell
61
 * Add the writting tests for the simple geometries
62
 *
63
 *
64
 */
65
/**
66
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
67
 */
68
public abstract class GPEPointsLayerTest extends GPEWriterBaseTest {
69
        private String layerId = "l1";
70
        private String layerName = "Points Layer";
71
        private String layerDescription = "This is a test of a points layer";
72
        private double[] bboxX = generateRandomBBox();
73
        private double[] bboxY = generateRandomBBox();
74
        private double[] bboxZ = generateRandomBBox();
75
        private String feature1Name = "New York";
76
        private String feature1Id = "f1";
77
        private String element1 = "POPULATION";
78
        
79
        /*
80
         * (non-Javadoc)
81
         * @see org.gvsig.gpe.writers.GPEWriterBaseTest#readObjects()
82
         */
83
        public void readObjects() {
84
                Layer[] layers = getLayers();
85
                assertEquals(layers.length, 1);
86
                
87
                Layer layer = layers[0];
88
                assertEquals(layer.getName(),layerName);
89
                assertEquals(layer.getDescription(),layerDescription);
90
//                assertEquals(layer.getId(),layerId);
91
//                assertEquals(layer.getBbox().getX(),bboxX);
92
//                assertEquals(layer.getBbox().getY(),bboxY);
93
//                assertEquals(layer.getBbox().getZ(),bboxZ);
94
                assertEquals(layer.getFeatures().size(), 2);
95
                Feature feature1 = (Feature)layer.getFeatures().get(0);
96
//                assertEquals(feature1.getId(), feature1Id);
97
                assertEquals(feature1.getName(), feature1Name);
98
                Element element11 = (Element)feature1.getElements().get(0);
99
        }
100

    
101
        /*
102
         * (non-Javadoc)
103
         * @see org.gvsig.gpe.writers.GPEWriterBaseTest#writeObjects()
104
         */
105
        public void writeObjects() {
106
                getWriterHandler().initialize();
107
                getWriterHandler().startLayer(layerId, layerName, layerDescription, "23030");
108
                getWriterHandler().startBbox("bbox", bboxX,
109
                                bboxY,
110
                                bboxZ,
111
                                "23030");
112
                getWriterHandler().endBbox();
113
                getWriterHandler().startFeature(feature1Name,feature1Id);
114
                getWriterHandler().startElement("POPULATION", new Integer("300000"), Integer.class);
115
                getWriterHandler().endElement();
116
                getWriterHandler().startPoint("p1", 2, 2, 2, "EPSG:23030");
117
                getWriterHandler().endPoint();                
118
                getWriterHandler().endFeature();
119
                getWriterHandler().startFeature("Los Angeles","2");
120
                getWriterHandler().startElement("POPULATION", new Integer("400000"), Integer.class);
121
                getWriterHandler().endElement();
122
                getWriterHandler().startPoint("p1", 1, 1, 1, "EPSG:23030");
123
                getWriterHandler().endPoint();                
124
                getWriterHandler().endFeature();
125
                getWriterHandler().endLayer();
126
                getWriterHandler().close();                
127
        }
128

    
129
}