svn-gvsig-desktop / trunk / libraries / libGPE / src-test / org / gvsig / gpe / writers / GPEPolygonWithInnerTest.java @ 11682
History | View | Annotate | Download (5.06 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.Polygon; |
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: GPEPolygonWithInnerTest.java 11682 2007-05-16 09:29:31Z jorpiell $
|
51 |
* $Log$
|
52 |
* Revision 1.2 2007-05-16 09:28:19 jorpiell
|
53 |
* The polygons has to be closed
|
54 |
*
|
55 |
* Revision 1.1 2007/05/02 11:46:07 jorpiell
|
56 |
* Writing tests updated
|
57 |
*
|
58 |
*
|
59 |
*/
|
60 |
/**
|
61 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es)
|
62 |
*/
|
63 |
public abstract class GPEPolygonWithInnerTest extends GPEWriterBaseTest{ |
64 |
private String layerId = "l1"; |
65 |
private String layerName = "Municipallity"; |
66 |
private String layerDescription = "Polygons test layer"; |
67 |
private String srs = "EPSG:23030"; |
68 |
private String bboxId = "bboxID"; |
69 |
private double[] bboxX = generateRandomBBox(); |
70 |
private double[] bboxY = generateRandomBBox(); |
71 |
private double[] bboxZ = generateRandomBBox(); |
72 |
private String feature1Name = "Madrid"; |
73 |
private String feature1Id = "f1"; |
74 |
private String polygon1Id = "p1"; |
75 |
private double[] polygon1X = generateRandomLinearRing(); |
76 |
private double[] polygon1Y = generateRandomLinearRing(); |
77 |
private double[] polygon1Z = generateRandomLinearRing(); |
78 |
private String inner11Id = "inner11"; |
79 |
private double[] inner11X = generateRandomLinearRing(); |
80 |
private double[] inner11Y = generateRandomLinearRing(); |
81 |
private double[] inner11Z = generateRandomLinearRing(); |
82 |
private String inner12Id = "inner12"; |
83 |
private double[] inner12X = generateRandomLinearRing(); |
84 |
private double[] inner12Y = generateRandomLinearRing(); |
85 |
private double[] inner12Z = generateRandomLinearRing(); |
86 |
private String feature2Name = "Valencia"; |
87 |
private String feature2Id = "f2"; |
88 |
private String polygon2Id = "p2"; |
89 |
private double[] polygon2X = generateRandomLinearRing(); |
90 |
private double[] polygon2Y = generateRandomLinearRing(); |
91 |
private double[] polygon2Z = generateRandomLinearRing(); |
92 |
|
93 |
/*
|
94 |
* (non-Javadoc)
|
95 |
* @see org.gvsig.gpe.writers.GPEWriterBaseTest#readObjects()
|
96 |
*/
|
97 |
public void readObjects() { |
98 |
Layer[] layers = getLayers();
|
99 |
assertEquals(layers.length, 1);
|
100 |
Layer layer = layers[0];
|
101 |
|
102 |
assertEquals(layer.getFeatures().size(), 2);
|
103 |
//FEATURE 1
|
104 |
Feature feature1 = (Feature)layer.getFeatures().get(0);
|
105 |
GeometryAsserts.polygon((Polygon)feature1.getGeometry(), polygon1X, polygon1Y, polygon1Z);
|
106 |
Polygon inner1 = (Polygon)((Polygon)feature1.getGeometry()).getInnerBoundary().get(0); |
107 |
GeometryAsserts.polygon(inner1, inner11X, inner11Y, inner11Z); |
108 |
Polygon inner2 = (Polygon)((Polygon)feature1.getGeometry()).getInnerBoundary().get(1); |
109 |
GeometryAsserts.polygon(inner2, inner12X, inner12Y, inner12Z); |
110 |
|
111 |
//FEATURE 2
|
112 |
Feature feature2 = (Feature)layer.getFeatures().get(1);
|
113 |
GeometryAsserts.polygon((Polygon)feature2.getGeometry(), polygon2X, polygon2Y, polygon2Z);
|
114 |
} |
115 |
|
116 |
/*
|
117 |
* (non-Javadoc)
|
118 |
* @see org.gvsig.gpe.writers.GPEWriterBaseTest#writeObjects()
|
119 |
*/
|
120 |
public void writeObjects() { |
121 |
getWriterHandler().initialize(); |
122 |
getWriterHandler().startLayer(layerId, layerName, layerDescription, srs); |
123 |
getWriterHandler().startBbox(bboxId, bboxX, |
124 |
bboxY, |
125 |
bboxZ, |
126 |
srs); |
127 |
getWriterHandler().endBbox(); |
128 |
getWriterHandler().startFeature(feature1Id,feature1Name); |
129 |
getWriterHandler().startPolygon(polygon1Id, |
130 |
polygon1X, |
131 |
polygon1Y, |
132 |
polygon1Z, |
133 |
srs); |
134 |
getWriterHandler().startInnerBoundary(inner11Id, |
135 |
inner11X, |
136 |
inner11Y, |
137 |
inner11Z, |
138 |
srs); |
139 |
getWriterHandler().endInnerBoundary(); |
140 |
getWriterHandler().startInnerBoundary(inner12Id, |
141 |
inner12X, |
142 |
inner12Y, |
143 |
inner12Z, |
144 |
srs); |
145 |
getWriterHandler().endInnerBoundary(); |
146 |
getWriterHandler().endPolygon(); |
147 |
getWriterHandler().endFeature(); |
148 |
getWriterHandler().startFeature(feature2Id,feature2Name); |
149 |
getWriterHandler().startPolygon(polygon2Id, |
150 |
polygon2X, |
151 |
polygon2Y, |
152 |
polygon2Z, |
153 |
srs); |
154 |
getWriterHandler().endPolygon(); |
155 |
getWriterHandler().endFeature(); |
156 |
getWriterHandler().endLayer(); |
157 |
getWriterHandler().close(); |
158 |
} |
159 |
|
160 |
} |