root / trunk / libraries / libGPE / src-test / org / gvsig / gpe / writers / GPEPolygonsLayerTest.java @ 11435
History | View | Annotate | Download (4.47 KB)
1 |
package org.gvsig.gpe.writers; |
---|---|
2 |
|
3 |
import org.gvsig.gpe.containers.Element; |
4 |
import org.gvsig.gpe.containers.Feature; |
5 |
import org.gvsig.gpe.containers.GeometryAsserts; |
6 |
import org.gvsig.gpe.containers.Layer; |
7 |
import org.gvsig.gpe.containers.Polygon; |
8 |
|
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: GPEPolygonsLayerTest.java 11435 2007-05-02 11:46:50Z jorpiell $
|
53 |
* $Log$
|
54 |
* Revision 1.6 2007-05-02 11:46:07 jorpiell
|
55 |
* Writing tests updated
|
56 |
*
|
57 |
* Revision 1.5 2007/04/26 14:39:12 jorpiell
|
58 |
* Add some tests
|
59 |
*
|
60 |
* Revision 1.4 2007/04/19 11:50:20 csanchez
|
61 |
* Actualizacion protoripo libGPE
|
62 |
*
|
63 |
* Revision 1.3 2007/04/14 16:06:35 jorpiell
|
64 |
* Add the container classes
|
65 |
*
|
66 |
* Revision 1.2 2007/04/13 13:14:55 jorpiell
|
67 |
* Created the base tests and add some methods to the content handler
|
68 |
*
|
69 |
* Revision 1.1 2007/04/13 07:17:54 jorpiell
|
70 |
* Add the writting tests for the simple geometries
|
71 |
*
|
72 |
*
|
73 |
*/
|
74 |
/**
|
75 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es)
|
76 |
*/
|
77 |
public abstract class GPEPolygonsLayerTest extends GPEWriterBaseTest{ |
78 |
private String layerId = "l1"; |
79 |
private String layerName = "Municipallity"; |
80 |
private String layerDescription = "Polygons test layer"; |
81 |
private String srs = "EPSG:23030"; |
82 |
private String bboxId = "bboxID"; |
83 |
private double[] bboxX = generateRandomBBox(); |
84 |
private double[] bboxY = generateRandomBBox(); |
85 |
private double[] bboxZ = generateRandomBBox(); |
86 |
private String feature1Name = "Madrid"; |
87 |
private String feature1Id = "f1"; |
88 |
private String polygon1Id = "p1"; |
89 |
private double[] polygon1X = generateRandomCoordinates(); |
90 |
private double[] polygon1Y = generateRandomCoordinates(); |
91 |
private double[] polygon1Z = generateRandomCoordinates(); |
92 |
private String feature2Name = "Valencia"; |
93 |
private String feature2Id = "f2"; |
94 |
private String polygon2Id = "p2"; |
95 |
private double[] polygon2X = generateRandomCoordinates(); |
96 |
private double[] polygon2Y = generateRandomCoordinates(); |
97 |
private double[] polygon2Z = generateRandomCoordinates(); |
98 |
|
99 |
/*
|
100 |
* (non-Javadoc)
|
101 |
* @see org.gvsig.gpe.writers.GPEWriterBaseTest#readObjects()
|
102 |
*/
|
103 |
public void readObjects() { |
104 |
Layer[] layers = getLayers();
|
105 |
assertEquals(layers.length, 1);
|
106 |
Layer layer = layers[0];
|
107 |
|
108 |
assertEquals(layer.getFeatures().size(), 2);
|
109 |
//FEATURE 1
|
110 |
Feature feature1 = (Feature)layer.getFeatures().get(0);
|
111 |
GeometryAsserts.polygon((Polygon)feature1.getGeometry(), polygon1X, polygon1Y, polygon1Z);
|
112 |
|
113 |
//FEATURE 2
|
114 |
Feature feature2 = (Feature)layer.getFeatures().get(1);
|
115 |
GeometryAsserts.polygon((Polygon)feature2.getGeometry(), polygon2X, polygon2Y, polygon2Z);
|
116 |
} |
117 |
|
118 |
/*
|
119 |
* (non-Javadoc)
|
120 |
* @see org.gvsig.gpe.writers.GPEWriterBaseTest#writeObjects()
|
121 |
*/
|
122 |
public void writeObjects() { |
123 |
getWriterHandler().initialize(); |
124 |
getWriterHandler().startLayer(layerId, layerName, layerDescription, srs); |
125 |
getWriterHandler().startBbox(bboxId, bboxX, |
126 |
bboxY, |
127 |
bboxZ, |
128 |
srs); |
129 |
getWriterHandler().endBbox(); |
130 |
getWriterHandler().startFeature(feature1Id,feature1Name); |
131 |
getWriterHandler().startPolygon(polygon1Id, |
132 |
polygon1X, |
133 |
polygon1Y, |
134 |
polygon1Z, |
135 |
srs); |
136 |
getWriterHandler().endPolygon(); |
137 |
getWriterHandler().endFeature(); |
138 |
getWriterHandler().startFeature(feature2Id,feature2Name); |
139 |
getWriterHandler().startPolygon(polygon2Id, |
140 |
polygon2X, |
141 |
polygon2Y, |
142 |
polygon2Z, |
143 |
srs); |
144 |
getWriterHandler().endPolygon(); |
145 |
getWriterHandler().endFeature(); |
146 |
getWriterHandler().endLayer(); |
147 |
getWriterHandler().close(); |
148 |
} |
149 |
|
150 |
} |