Statistics
| Revision:

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

History | View | Annotate | Download (4.34 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.LineString;
7
import org.gvsig.gpe.containers.MultiGeometry;
8
import org.gvsig.gpe.containers.MultiPolygon;
9
import org.gvsig.gpe.containers.Point;
10
import org.gvsig.gpe.containers.Polygon;
11

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

    
108
        /*
109
         * (non-Javadoc)
110
         * @see org.gvsig.gpe.writers.GPEWriterBaseTest#writeObjects()
111
         */
112
        public void writeObjects() {
113
                getWriterHandler().initialize();
114
                getWriterHandler().startLayer(layerId, null , null , srs);
115
                getWriterHandler().startFeature(feature1Id,null);
116
                getWriterHandler().startMultiGeometry(multiGeometryId, srs);
117
                getWriterHandler().startPoint(point1Id, point1X, point1Y, point1Z, srs);
118
                getWriterHandler().endPoint();        
119
                getWriterHandler().startLineString(lineString1Id,
120
                                lineString1X,
121
                                lineString1Y,
122
                                lineString1Z, 
123
                                srs);
124
                getWriterHandler().endLineString();                
125
                getWriterHandler().startPolygon(polygon1Id,
126
                                polygon1X,
127
                                polygon1Y,
128
                                polygon1Z,
129
                                srs);                
130
                getWriterHandler().endPolygon();                
131
                getWriterHandler().endMultiGeometry();                
132
                getWriterHandler().endFeature();
133
                getWriterHandler().endLayer();
134
                getWriterHandler().close();        
135
        }
136
}