root / branches / v2_0_0_prep / libraries / libGPE / src-test / org / gvsig / gpe / writer / GPEMultiPolygonLayerTest.java @ 28113
History | View | Annotate | Download (4.71 KB)
1 | 19581 | jpiera | package org.gvsig.gpe.writer; |
---|---|---|---|
2 | 18288 | jpiera | |
3 | 21944 | jpiera | import org.gvsig.gpe.containers.CoordinatesSequence; |
4 | 18288 | jpiera | 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.MultiPolygon; |
||
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: GPEMultiPolygonLayerTest.java 144 2007-06-07 14:53:59Z jorpiell $
|
||
53 | * $Log$
|
||
54 | * Revision 1.7 2007/06/07 14:52:28 jorpiell
|
||
55 | * Add the schema support
|
||
56 | *
|
||
57 | * Revision 1.6 2007/05/16 09:28:19 jorpiell
|
||
58 | * The polygons has to be closed
|
||
59 | *
|
||
60 | * Revision 1.5 2007/05/09 10:03:19 jorpiell
|
||
61 | * Add the multigeometry tests
|
||
62 | *
|
||
63 | * Revision 1.4 2007/04/26 14:39:12 jorpiell
|
||
64 | * Add some tests
|
||
65 | *
|
||
66 | * Revision 1.3 2007/04/19 11:50:20 csanchez
|
||
67 | * Actualizacion protoripo libGPE
|
||
68 | *
|
||
69 | * Revision 1.2 2007/04/14 16:06:35 jorpiell
|
||
70 | * Add the container classes
|
||
71 | *
|
||
72 | * Revision 1.1 2007/04/13 13:14:55 jorpiell
|
||
73 | * Created the base tests and add some methods to the content handler
|
||
74 | *
|
||
75 | *
|
||
76 | */
|
||
77 | /**
|
||
78 | * @author Jorge Piera LLodr? (jorge.piera@iver.es)
|
||
79 | */
|
||
80 | public abstract class GPEMultiPolygonLayerTest extends GPEWriterBaseTest{ |
||
81 | private String layerId = "l1"; |
||
82 | private String srs = "EPSG:23030"; |
||
83 | private String feature1Id = "f1"; |
||
84 | private String multiPolygon1Id = "mp1"; |
||
85 | private String polygon1Id = "p1"; |
||
86 | private double[] polygon1X = generateRandomLinearRing(); |
||
87 | private double[] polygon1Y = generateRandomLinearRing(); |
||
88 | private double[] polygon1Z = generateRandomLinearRing(); |
||
89 | private String polygon2Id = "p2"; |
||
90 | private double[] polygon2X = generateRandomLinearRing(); |
||
91 | private double[] polygon2Y = generateRandomLinearRing(); |
||
92 | private double[] polygon2Z = generateRandomLinearRing(); |
||
93 | private String polygon3Id = "p3"; |
||
94 | private double[] polygon3X = generateRandomLinearRing(); |
||
95 | private double[] polygon3Y = generateRandomLinearRing(); |
||
96 | private double[] polygon3Z = generateRandomLinearRing(); |
||
97 | |||
98 | /*
|
||
99 | * (non-Javadoc)
|
||
100 | * @see org.gvsig.gpe.writers.GPEWriterBaseTest#readObjects()
|
||
101 | */
|
||
102 | public void readObjects() { |
||
103 | Layer[] layers = getLayers();
|
||
104 | assertEquals(layers.length, 1);
|
||
105 | Layer layer = layers[0];
|
||
106 | |||
107 | assertEquals(layer.getFeatures().size(), 1);
|
||
108 | //FEATURE 1
|
||
109 | Feature feature1 = (Feature)layer.getFeatures().get(0);
|
||
110 | MultiPolygon multiPolygon = (MultiPolygon)feature1.getGeometry(); |
||
111 | assertEquals(multiPolygon.getGeometries().size(), 3);
|
||
112 | GeometryAsserts.polygon(multiPolygon.getMultiPolygonAt(0), polygon1X, polygon1Y, polygon1Z);
|
||
113 | GeometryAsserts.polygon(multiPolygon.getMultiPolygonAt(1), polygon2X, polygon2Y, polygon2Z);
|
||
114 | GeometryAsserts.polygon(multiPolygon.getMultiPolygonAt(2), polygon3X, polygon3Y, polygon3Z);
|
||
115 | } |
||
116 | |||
117 | /*
|
||
118 | * (non-Javadoc)
|
||
119 | * @see org.gvsig.gpe.writers.GPEWriterBaseTest#writeObjects()
|
||
120 | */
|
||
121 | public void writeObjects() { |
||
122 | getWriterHandler().initialize(); |
||
123 | getWriterHandler().startLayer(layerId, null , null , srs, null); |
||
124 | 21968 | jpiera | getWriterHandler().startFeature(feature1Id, null, null); |
125 | 18288 | jpiera | getWriterHandler().startMultiPolygon(multiPolygon1Id, srs); |
126 | 21944 | jpiera | getWriterHandler().startPolygon(polygon1Id, new CoordinatesSequence(
|
127 | 18288 | jpiera | polygon1X, |
128 | polygon1Y, |
||
129 | 20219 | jpiera | polygon1Z), |
130 | 18288 | jpiera | srs); |
131 | getWriterHandler().endPolygon(); |
||
132 | 21944 | jpiera | getWriterHandler().startPolygon(polygon2Id, new CoordinatesSequence(
|
133 | 18288 | jpiera | polygon2X, |
134 | polygon2Y, |
||
135 | 20219 | jpiera | polygon2Z), |
136 | 18288 | jpiera | srs); |
137 | getWriterHandler().endPolygon(); |
||
138 | 21944 | jpiera | getWriterHandler().startPolygon(polygon3Id, new CoordinatesSequence(
|
139 | 18288 | jpiera | polygon3X, |
140 | polygon3Y, |
||
141 | 20219 | jpiera | polygon3Z), |
142 | 18288 | jpiera | srs); |
143 | getWriterHandler().endPolygon(); |
||
144 | getWriterHandler().endMultiPolygon(); |
||
145 | getWriterHandler().endFeature(); |
||
146 | getWriterHandler().endLayer(); |
||
147 | getWriterHandler().close(); |
||
148 | } |
||
149 | |||
150 | } |