Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libGPE / src-test / org / gvsig / gpe / writers / GPEGeometryWithIdTest.java @ 11435

History | View | Annotate | Download (3.82 KB)

1
package org.gvsig.gpe.writers;
2

    
3
import org.gvsig.gpe.containers.Feature;
4
import org.gvsig.gpe.containers.GeometryAsserts;
5
import org.gvsig.gpe.containers.Layer;
6
import org.gvsig.gpe.containers.Point;
7

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

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

    
126
}