Statistics
| Revision:

root / branches / v2_0_0_prep / libraries / libGPE / src-test / org / gvsig / gpe / writer / GPEGeometryWithIdTest.java @ 28113

History | View | Annotate | Download (4 KB)

1
package org.gvsig.gpe.writer;
2

    
3
import org.gvsig.gpe.containers.CoordinatesSequence;
4
import org.gvsig.gpe.containers.Feature;
5
import org.gvsig.gpe.containers.Layer;
6

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

    
104
        /*
105
         * (non-Javadoc)
106
         * @see org.gvsig.gpe.writers.GPEWriterBaseTest#writeObjects()
107
         */
108
        public void writeObjects() {
109
                getWriterHandler().initialize();
110
                getWriterHandler().startLayer(layerId, null, layerName, layerDescription, srs);
111
                getWriterHandler().startBbox(bboxId, new CoordinatesSequence(bboxX,        bboxY, bboxZ), srs);
112
                getWriterHandler().endBbox();
113
                getWriterHandler().startFeature(feature1Id, null, feature1Name);
114
                getWriterHandler().startPoint(point1Id, new CoordinatesSequence(point1X, point1Y, point1Z), srs);
115
                getWriterHandler().endPoint();                
116
                getWriterHandler().endFeature();
117
                getWriterHandler().startFeature(feature2Id, null, feature2Name);
118
                getWriterHandler().startPoint(point2Id, new CoordinatesSequence(point2X, point2Y, point2Z), srs);
119
                getWriterHandler().endPoint();                
120
                getWriterHandler().endFeature();
121
                getWriterHandler().endLayer();
122
                getWriterHandler().close();                
123
        }
124

    
125
}