Revision 47432
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.jts/src/test/java/org/gvsig/fmap/geom/jts/TestForceSubtype.java | ||
---|---|---|
1 |
/* |
|
2 |
* To change this license header, choose License Headers in Project Properties. |
|
3 |
* To change this template file, choose Tools | Templates |
|
4 |
* and open the template in the editor. |
|
5 |
*/ |
|
6 |
package org.gvsig.fmap.geom.jts; |
|
7 |
|
|
8 |
import org.gvsig.fmap.geom.Geometry; |
|
9 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
10 |
import org.gvsig.fmap.geom.GeometryManager; |
|
11 |
import org.gvsig.fmap.geom.jts.operation.towkb.OGCWKBEncoder; |
|
12 |
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase; |
|
13 |
|
|
14 |
/** |
|
15 |
* |
|
16 |
* @author fdiaz |
|
17 |
*/ |
|
18 |
public class TestForceSubtype extends AbstractLibraryAutoInitTestCase { |
|
19 |
|
|
20 |
private static class Data { |
|
21 |
|
|
22 |
public String wkt; |
|
23 |
public String wkt2D; |
|
24 |
public String wkt2DM; |
|
25 |
public String wkt3D; |
|
26 |
public String wkt3DM; |
|
27 |
// public int byteOrder; |
|
28 |
public boolean skip; |
|
29 |
|
|
30 |
public Data(String wkt, String wkt2D, String wkt2DM, String wkt3D, String wkt3DM, boolean skip) { |
|
31 |
this.wkt = wkt; |
|
32 |
this.wkt2D = wkt2D; |
|
33 |
this.wkt2DM = wkt2DM; |
|
34 |
this.wkt3D = wkt3D; |
|
35 |
this.wkt3DM = wkt3DM; |
|
36 |
// this.byteOrder = byteOrder; |
|
37 |
this.skip = skip; |
|
38 |
} |
|
39 |
|
|
40 |
} |
|
41 |
|
|
42 |
@Override |
|
43 |
protected void doSetUp() throws Exception { |
|
44 |
} |
|
45 |
|
|
46 |
public String bytearray(byte[] data) { |
|
47 |
StringBuilder builder = new StringBuilder(); |
|
48 |
builder.append("0x"); |
|
49 |
for (byte abyte : data) { |
|
50 |
int v = abyte & 0xff; |
|
51 |
builder.append(String.format("%02x", v)); |
|
52 |
} |
|
53 |
return builder.toString(); |
|
54 |
} |
|
55 |
|
|
56 |
public void test1() throws Exception { |
|
57 |
GeometryManager manager = GeometryLocator.getGeometryManager(); |
|
58 |
Data[] allData = new Data[] { |
|
59 |
new Data( |
|
60 |
"POINT (30 10)", |
|
61 |
"POINT (30 10)", |
|
62 |
"POINT M (30 10 0)", |
|
63 |
"POINT Z (30 10 0)", |
|
64 |
"POINT ZM (30 10 0 0)", |
|
65 |
false |
|
66 |
), |
|
67 |
new Data( |
|
68 |
"LINESTRING (30 10, 10 30, 40 40)", |
|
69 |
"LINESTRING (30 10, 10 30, 40 40)", |
|
70 |
"LINESTRING M (30 10 0, 10 30 0, 40 40 0)", |
|
71 |
"LINESTRING Z (30 10 0, 10 30 0, 40 40 0)", |
|
72 |
"LINESTRING ZM (30 10 0 0, 10 30 0 0, 40 40 0 0)", |
|
73 |
false |
|
74 |
), |
|
75 |
new Data( |
|
76 |
"POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))", |
|
77 |
"POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))", |
|
78 |
"POLYGON M ((30 10 0, 40 40 0, 20 40 0, 10 20 0, 30 10 0))", |
|
79 |
"POLYGON Z ((30 10 0, 40 40 0, 20 40 0, 10 20 0, 30 10 0))", |
|
80 |
"POLYGON ZM ((30 10 0 0, 40 40 0 0, 20 40 0 0, 10 20 0 0, 30 10 0 0))", |
|
81 |
false |
|
82 |
), |
|
83 |
new Data( |
|
84 |
"POLYGON ((35 10, 45 45, 15 40, 10 20, 35 10),(20 30, 35 35, 30 20, 20 30))", |
|
85 |
"POLYGON ((35 10, 45 45, 15 40, 10 20, 35 10),(20 30, 35 35, 30 20, 20 30))", |
|
86 |
"POLYGON M ((35 10 0, 45 45 0, 15 40 0, 10 20 0, 35 10 0),(20 30 0, 35 35 0, 30 20 0, 20 30 0))", |
|
87 |
"POLYGON Z ((35 10 0, 45 45 0, 15 40 0, 10 20 0, 35 10 0),(20 30 0, 35 35 0, 30 20 0, 20 30 0))", |
|
88 |
"POLYGON ZM ((35 10 0 0, 45 45 0 0, 15 40 0 0, 10 20 0 0, 35 10 0 0),(20 30 0 0, 35 35 0 0, 30 20 0 0, 20 30 0 0))", |
|
89 |
false |
|
90 |
), |
|
91 |
new Data( |
|
92 |
"MULTIPOINT ((10 40), (40 30), (20 20), (30 10))", |
|
93 |
"MULTIPOINT ((10 40), (40 30), (20 20), (30 10))", |
|
94 |
"MULTIPOINT M ((10 40 0), (40 30 0), (20 20 0), (30 10 0))", |
|
95 |
"MULTIPOINT Z ((10 40 0), (40 30 0), (20 20 0), (30 10 0))", |
|
96 |
"MULTIPOINT ZM ((10 40 0 0), (40 30 0 0), (20 20 0 0), (30 10 0 0))", |
|
97 |
false |
|
98 |
), |
|
99 |
new Data( |
|
100 |
"MULTIPOINT (10 40, 40 30, 20 20, 30 10)", |
|
101 |
"MULTIPOINT (10 40, 40 30, 20 20, 30 10)", |
|
102 |
"MULTIPOINT M (10 40 0, 40 30 0, 20 20 0, 30 10 0)", |
|
103 |
"MULTIPOINT Z (10 40 0, 40 30 0, 20 20 0, 30 10 0)", |
|
104 |
"MULTIPOINT ZM (10 40 0 0, 40 30 0 0, 20 20 0 0, 30 10 0 0)", |
|
105 |
false |
|
106 |
), |
|
107 |
new Data( |
|
108 |
"MULTILINESTRING ((10 10, 20 20, 10 40),(40 40, 30 30, 40 20, 30 10))", |
|
109 |
"MULTILINESTRING ((10 10, 20 20, 10 40),(40 40, 30 30, 40 20, 30 10))", |
|
110 |
"MULTILINESTRING M ((10 10 0, 20 20 0, 10 40 0),(40 40 0, 30 30 0, 40 20 0, 30 10 0))", |
|
111 |
"MULTILINESTRING Z ((10 10 0, 20 20 0, 10 40 0),(40 40 0, 30 30 0, 40 20 0, 30 10 0))", |
|
112 |
"MULTILINESTRING ZM ((10 10 0 0, 20 20 0 0, 10 40 0 0),(40 40 0 0, 30 30 0 0, 40 20 0 0, 30 10 0 0))", |
|
113 |
false |
|
114 |
), |
|
115 |
new Data( |
|
116 |
"MULTIPOLYGON (((30 20, 45 40, 10 40, 30 20)),((15 5, 40 10, 10 20, 5 10, 15 5)))", |
|
117 |
"MULTIPOLYGON (((30 20, 45 40, 10 40, 30 20)),((15 5, 40 10, 10 20, 5 10, 15 5)))", |
|
118 |
"MULTIPOLYGON M (((30 20 0, 45 40 0, 10 40 0, 30 20 0)),((15 5 0, 40 10 0, 10 20 0, 5 10 0, 15 5 0)))", |
|
119 |
"MULTIPOLYGON Z (((30 20 0, 45 40 0, 10 40 0, 30 20 0)),((15 5 0, 40 10 0, 10 20 0, 5 10 0, 15 5 0)))", |
|
120 |
"MULTIPOLYGON ZM (((30 20 0 0, 45 40 0 0, 10 40 0 0, 30 20 0 0)),((15 5 0 0, 40 10 0 0, 10 20 0 0, 5 10 0 0, 15 5 0 0)))", |
|
121 |
false |
|
122 |
), |
|
123 |
new Data( |
|
124 |
"MULTIPOLYGON (((40 40, 20 45, 45 30, 40 40)),((20 35, 10 30, 10 10, 30 5, 45 20, 20 35),(30 20, 20 15, 20 25, 30 20)))", |
|
125 |
"MULTIPOLYGON (((40 40, 20 45, 45 30, 40 40)),((20 35, 10 30, 10 10, 30 5, 45 20, 20 35),(30 20, 20 15, 20 25, 30 20)))", |
|
126 |
"MULTIPOLYGON M (((40 40 0, 20 45 0, 45 30 0, 40 40 0)),((20 35 0, 10 30 0, 10 10 0, 30 5 0, 45 20 0, 20 35 0),(30 20 0, 20 15 0, 20 25 0, 30 20 0)))", |
|
127 |
"MULTIPOLYGON Z(((40 40 0, 20 45 0, 45 30 0, 40 40 0)),((20 35 0, 10 30 0, 10 10 0, 30 5 0, 45 20 0, 20 35 0),(30 20 0, 20 15 0, 20 25 0, 30 20 0)))", |
|
128 |
"MULTIPOLYGON ZM(((40 40 0 0, 20 45 0 0, 45 30 0 0, 40 40 0 0)),((20 35 0 0, 10 30 0 0, 10 10 0 0, 30 5 0 0, 45 20 0 0, 20 35 0 0),(30 20 0 0, 20 15 0 0, 20 25 0 0, 30 20 0 0)))", |
|
129 |
false |
|
130 |
), |
|
131 |
new Data( |
|
132 |
"POLYGON ((710847.97223687172 4368973.1207255824, 720362.03232662566 4368973.1207255824, 720362.03232662566 4373121.8750170888, 710847.97223687172 4373121.8750170888, 710847.97223687172 4368973.1207255824))", |
|
133 |
"POLYGON ((710847.97223687172 4368973.1207255824, 720362.03232662566 4368973.1207255824, 720362.03232662566 4373121.8750170888, 710847.97223687172 4373121.8750170888, 710847.97223687172 4368973.1207255824))", |
|
134 |
"POLYGON M ((710847.97223687172 4368973.1207255824 0.0, 720362.03232662566 4368973.1207255824 0.0, 720362.03232662566 4373121.8750170888 0.0, 710847.97223687172 4373121.8750170888 0.0, 710847.97223687172 4368973.1207255824 0.0))", |
|
135 |
"POLYGON Z ((710847.97223687172 4368973.1207255824 0.0, 720362.03232662566 4368973.1207255824 0.0, 720362.03232662566 4373121.8750170888 0.0, 710847.97223687172 4373121.8750170888 0.0, 710847.97223687172 4368973.1207255824 0.0))", |
|
136 |
"POLYGON ZM ((710847.97223687172 4368973.1207255824 0.0 0.0, 720362.03232662566 4368973.1207255824 0.0 0.0, 720362.03232662566 4373121.8750170888 0.0 0.0, 710847.97223687172 4373121.8750170888 0.0 0.0, 710847.97223687172 4368973.1207255824 0.0 0.0))", |
|
137 |
false |
|
138 |
), |
|
139 |
|
|
140 |
new Data( |
|
141 |
"POINT Z (30 10 20)", |
|
142 |
"POINT (30 10)", |
|
143 |
"POINT M (30 10 0)", |
|
144 |
"POINT Z (30 10 20)", |
|
145 |
"POINT ZM (30 10 20 0)", |
|
146 |
false |
|
147 |
), |
|
148 |
|
|
149 |
new Data( |
|
150 |
"POINT M (30 10 30)", |
|
151 |
"POINT (30 10)", |
|
152 |
"POINT M (30 10 30)", |
|
153 |
"POINT Z (30 10 0)", |
|
154 |
"POINT ZM (30 10 0 30)", |
|
155 |
false |
|
156 |
), |
|
157 |
|
|
158 |
new Data( |
|
159 |
"POINT ZM (30 10 20 30)", |
|
160 |
"POINT (30 10)", |
|
161 |
"POINT M (30 10 30)", |
|
162 |
"POINT Z (30 10 20)", |
|
163 |
"POINT ZM (30 10 20 30)", |
|
164 |
false |
|
165 |
), |
|
166 |
|
|
167 |
new Data( |
|
168 |
"POLYGON Z ((30 10 10, 40 40 10, 20 40 10, 10 20 10, 30 10 10))", |
|
169 |
"POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))", |
|
170 |
"POLYGON M ((30 10 0, 40 40 0, 20 40 0, 10 20 0, 30 10 0))", |
|
171 |
"POLYGON Z ((30 10 10, 40 40 10, 20 40 10, 10 20 10, 30 10 10))", |
|
172 |
"POLYGON ZM ((30 10 10 0, 40 40 10 0, 20 40 10 0, 10 20 10 0, 30 10 10 0))", |
|
173 |
false |
|
174 |
), |
|
175 |
|
|
176 |
new Data( |
|
177 |
"POLYGON M ((30 10 100, 40 40 200, 20 40 300, 10 20 400, 30 10 100))", |
|
178 |
"POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))", |
|
179 |
"POLYGON M ((30 10 100, 40 40 200, 20 40 300, 10 20 400, 30 10 100))", |
|
180 |
"POLYGON Z ((30 10 0, 40 40 0, 20 40 0, 10 20 0, 30 10 0))", |
|
181 |
"POLYGON ZM ((30 10 0 100, 40 40 0 200, 20 40 0 300, 10 20 0 400, 30 10 0 100))", |
|
182 |
false |
|
183 |
), |
|
184 |
|
|
185 |
new Data( |
|
186 |
"POLYGON ZM ((30 10 10 100, 40 40 10 200, 20 40 10 300, 10 20 10 400, 30 10 10 100))", |
|
187 |
"POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))", |
|
188 |
"POLYGON M ((30 10 100, 40 40 200, 20 40 300, 10 20 400, 30 10 100))", |
|
189 |
"POLYGON Z ((30 10 10, 40 40 10, 20 40 10, 10 20 10, 30 10 10))", |
|
190 |
"POLYGON ZM ((30 10 10 100, 40 40 10 200, 20 40 10 300, 10 20 10 400, 30 10 10 100))", |
|
191 |
false |
|
192 |
), |
|
193 |
|
|
194 |
new Data( |
|
195 |
"MULTIPOINT Z ((10 40 10), (40 30 10), (20 20 10), (30 10 10))", |
|
196 |
"MULTIPOINT ((10 40), (40 30), (20 20), (30 10))", |
|
197 |
"MULTIPOINT M ((10 40 0), (40 30 0), (20 20 0), (30 10 0))", |
|
198 |
"MULTIPOINT Z ((10 40 10), (40 30 10), (20 20 10), (30 10 10))", |
|
199 |
"MULTIPOINT ZM ((10 40 10 0), (40 30 10 0), (20 20 10 0), (30 10 10 0))", |
|
200 |
false |
|
201 |
), |
|
202 |
|
|
203 |
new Data( |
|
204 |
"MULTIPOINT M ((10 40 100), (40 30 200), (20 20 300), (30 10 400))", |
|
205 |
"MULTIPOINT ((10 40), (40 30), (20 20), (30 10))", |
|
206 |
"MULTIPOINT M ((10 40 100), (40 30 200), (20 20 300), (30 10 400))", |
|
207 |
"MULTIPOINT Z ((10 40 0), (40 30 0), (20 20 0), (30 10 0))", |
|
208 |
"MULTIPOINT ZM ((10 40 0 100), (40 30 0 200), (20 20 0 300), (30 10 0 400))", |
|
209 |
false |
|
210 |
), |
|
211 |
|
|
212 |
new Data( |
|
213 |
"MULTIPOINT ZM ((10 40 10 100), (40 30 10 200), (20 20 10 300), (30 10 10 400))", |
|
214 |
"MULTIPOINT ((10 40), (40 30), (20 20), (30 10))", |
|
215 |
"MULTIPOINT M ((10 40 100), (40 30 200), (20 20 300), (30 10 400))", |
|
216 |
"MULTIPOINT Z ((10 40 10), (40 30 10), (20 20 10), (30 10 10))", |
|
217 |
"MULTIPOINT ZM ((10 40 10 100), (40 30 10 200), (20 20 10 300), (30 10 10 400))", |
|
218 |
false |
|
219 |
), |
|
220 |
|
|
221 |
new Data( |
|
222 |
"MULTIPOINT Z (10 40 10, 40 30 10, 20 20 10, 30 10 10)", |
|
223 |
"MULTIPOINT (10 40, 40 30, 20 20, 30 10)", |
|
224 |
"MULTIPOINT M (10 40 0, 40 30 0, 20 20 0, 30 10 0)", |
|
225 |
"MULTIPOINT Z (10 40 10, 40 30 10, 20 20 10, 30 10 10)", |
|
226 |
"MULTIPOINT ZM (10 40 10 0, 40 30 10 0, 20 20 10 0, 30 10 10 0)", |
|
227 |
false |
|
228 |
), |
|
229 |
|
|
230 |
new Data( |
|
231 |
"MULTIPOINT M (10 40 100, 40 30 200, 20 20 300, 30 10 400)", |
|
232 |
"MULTIPOINT (10 40, 40 30, 20 20, 30 10)", |
|
233 |
"MULTIPOINT M (10 40 100, 40 30 200, 20 20 300, 30 10 400)", |
|
234 |
"MULTIPOINT Z (10 40 0, 40 30 0, 20 20 0, 30 10 0)", |
|
235 |
"MULTIPOINT ZM (10 40 0 100, 40 30 0 200, 20 20 0 300, 30 10 0 400)", |
|
236 |
false |
|
237 |
), |
|
238 |
|
|
239 |
new Data( |
|
240 |
"MULTIPOINT ZM (10 40 10 100, 40 30 10 200, 20 20 10 300, 30 10 10 400)", |
|
241 |
"MULTIPOINT (10 40, 40 30, 20 20, 30 10)", |
|
242 |
"MULTIPOINT M (10 40 100, 40 30 200, 20 20 300, 30 10 400)", |
|
243 |
"MULTIPOINT Z (10 40 10, 40 30 10, 20 20 10, 30 10 10)", |
|
244 |
"MULTIPOINT ZM (10 40 10 100, 40 30 10 200, 20 20 10 300, 30 10 10 400)", |
|
245 |
false |
|
246 |
), |
|
247 |
|
|
248 |
new Data( |
|
249 |
"MULTIPOLYGON Z (((30 20 10, 45 40 10, 10 40 10, 30 20 10)),((15 5 10, 40 10 10, 10 20 10, 5 10 10, 15 5 10)))", |
|
250 |
"MULTIPOLYGON (((30 20, 45 40, 10 40, 30 20)),((15 5, 40 10, 10 20, 5 10, 15 5)))", |
|
251 |
"MULTIPOLYGON M (((30 20 0, 45 40 0, 10 40 0, 30 20 0)),((15 5 0, 40 10 0, 10 20 0, 5 10 0, 15 5 0)))", |
|
252 |
"MULTIPOLYGON Z (((30 20 10, 45 40 10, 10 40 10, 30 20 10)),((15 5 10, 40 10 10, 10 20 10, 5 10 10, 15 5 10)))", |
|
253 |
"MULTIPOLYGON ZM (((30 20 10 0, 45 40 10 0, 10 40 10 0, 30 20 10 0)),((15 5 10 0, 40 10 10 0, 10 20 10 0, 5 10 10 0, 15 5 10 0)))", |
|
254 |
false |
|
255 |
), |
|
256 |
|
|
257 |
new Data( |
|
258 |
"MULTIPOLYGON M (((30 20 100, 45 40 200, 10 40 300, 30 20 100)),((15 5 20, 40 10 500, 10 20 600, 5 10 700, 15 5 20)))", |
|
259 |
"MULTIPOLYGON (((30 20, 45 40, 10 40, 30 20)),((15 5, 40 10, 10 20, 5 10, 15 5)))", |
|
260 |
"MULTIPOLYGON M (((30 20 100, 45 40 200, 10 40 300, 30 20 100)),((15 5 20, 40 10 500, 10 20 600, 5 10 700, 15 5 20)))", |
|
261 |
"MULTIPOLYGON Z (((30 20 0, 45 40 0, 10 40 0, 30 20 0)),((15 5 0, 40 10 0, 10 20 0, 5 10 0, 15 5 0)))", |
|
262 |
"MULTIPOLYGON ZM (((30 20 0 100, 45 40 0 200, 10 40 0 300, 30 20 0 100)),((15 5 0 20, 40 10 0 500, 10 20 0 600, 5 10 0 700, 15 5 0 20)))", |
|
263 |
false |
|
264 |
), |
|
265 |
|
|
266 |
new Data( |
|
267 |
"MULTIPOLYGON ZM (((30 20 10 100, 45 40 10 200, 10 40 10 300, 30 20 10 100)),((15 5 10 500, 40 10 10 600, 10 20 10 700, 5 10 10 800, 15 5 10 500)))", |
|
268 |
"MULTIPOLYGON (((30 20, 45 40, 10 40, 30 20)),((15 5, 40 10, 10 20, 5 10, 15 5)))", |
|
269 |
"MULTIPOLYGON M (((30 20 100, 45 40 200, 10 40 300, 30 20 100)),((15 5 500, 40 10 600, 10 20 700, 5 10 800, 15 5 500)))", |
|
270 |
"MULTIPOLYGON Z (((30 20 10, 45 40 10, 10 40 10, 30 20 10)),((15 5 10, 40 10 10, 10 20 10, 5 10 10, 15 5 10)))", |
|
271 |
"MULTIPOLYGON ZM (((30 20 10 100, 45 40 10 200, 10 40 10 300, 30 20 10 100)),((15 5 10 500, 40 10 10 600, 10 20 10 700, 5 10 10 800, 15 5 10 500)))", |
|
272 |
false |
|
273 |
), |
|
274 |
|
|
275 |
new Data( |
|
276 |
"LINESTRING M (30 10 100, 10 30 200, 40 40 300)", |
|
277 |
"LINESTRING (30 10, 10 30, 40 40)", |
|
278 |
"LINESTRING M (30 10 100, 10 30 200, 40 40 300)", |
|
279 |
"LINESTRING Z (30 10 0, 10 30 0, 40 40 0)", |
|
280 |
"LINESTRING ZM (30 10 0 100, 10 30 0 200, 40 40 0 300)", |
|
281 |
false |
|
282 |
), |
|
283 |
|
|
284 |
new Data( |
|
285 |
"LINESTRING ZM (30 10 20 100, 10 30 20 200, 40 40 20 300)", |
|
286 |
"LINESTRING (30 10, 10 30, 40 40)", |
|
287 |
"LINESTRING M (30 10 100, 10 30 200, 40 40 300)", |
|
288 |
"LINESTRING Z (30 10 20, 10 30 20, 40 40 20)", |
|
289 |
"LINESTRING ZM (30 10 20 100, 10 30 20 200, 40 40 20 300)", |
|
290 |
false |
|
291 |
), |
|
292 |
|
|
293 |
new Data( |
|
294 |
"MULTILINESTRING M ((10 10 100, 20 20 200, 10 40 300),(40 40 400, 30 30 500, 40 20 600, 30 10 700))", |
|
295 |
"MULTILINESTRING ((10 10, 20 20, 10 40),(40 40, 30 30, 40 20, 30 10))", |
|
296 |
"MULTILINESTRING M ((10 10 100, 20 20 200, 10 40 300),(40 40 400, 30 30 500, 40 20 600, 30 10 700))", |
|
297 |
"MULTILINESTRING Z ((10 10 0, 20 20 0, 10 40 0),(40 40 0, 30 30 0, 40 20 0, 30 10 0))", |
|
298 |
"MULTILINESTRING ZM ((10 10 0 100, 20 20 0 200, 10 40 0 300),(40 40 0 400, 30 30 0 500, 40 20 0 600, 30 10 0 700))", |
|
299 |
false |
|
300 |
), |
|
301 |
|
|
302 |
new Data( |
|
303 |
"MULTILINESTRING ZM ((10 10 20 100, 20 20 20 200, 10 40 20 300),(40 40 20 400, 30 30 20 500, 40 20 20 600, 30 10 20 700))", |
|
304 |
"MULTILINESTRING ((10 10, 20 20, 10 40),(40 40, 30 30, 40 20, 30 10))", |
|
305 |
"MULTILINESTRING M ((10 10 100, 20 20 200, 10 40 300),(40 40 400, 30 30 500, 40 20 600, 30 10 700))", |
|
306 |
"MULTILINESTRING Z ((10 10 20, 20 20 20, 10 40 20),(40 40 20, 30 30 20, 40 20 20, 30 10 20))", |
|
307 |
"MULTILINESTRING ZM ((10 10 20 100, 20 20 20 200, 10 40 20 300),(40 40 20 400, 30 30 20 500, 40 20 20 600, 30 10 20 700))", |
|
308 |
false |
|
309 |
), |
|
310 |
|
|
311 |
|
|
312 |
}; |
|
313 |
|
|
314 |
System.out.println("# Test:: test1"); |
|
315 |
for (Data data : allData) { |
|
316 |
if( data.skip ) { |
|
317 |
continue; |
|
318 |
} |
|
319 |
System.out.println("# WKT:: " + data.wkt); |
|
320 |
Geometry geom = manager.createFrom(data.wkt); |
|
321 |
Geometry geom2D = manager.createFrom(data.wkt2D); |
|
322 |
Geometry geom2DM = manager.createFrom(data.wkt2DM); |
|
323 |
Geometry geom3D = manager.createFrom(data.wkt3D); |
|
324 |
Geometry geom3DM = manager.createFrom(data.wkt3DM); |
|
325 |
assertEquals(geom2D, geom.forceSubtype(Geometry.SUBTYPES.GEOM2D)); |
|
326 |
assertEquals(geom2DM, geom.forceSubtype(Geometry.SUBTYPES.GEOM2DM)); |
|
327 |
assertEquals(geom3D, geom.forceSubtype(Geometry.SUBTYPES.GEOM3D)); |
|
328 |
assertEquals(geom3DM, geom.forceSubtype(Geometry.SUBTYPES.GEOM3DM)); |
|
329 |
} |
|
330 |
} |
|
331 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.jts/src/test/java/org/gvsig/fmap/geom/jts/operation/towkb/TestOGCWKBEncoder.java | ||
---|---|---|
23 | 23 |
*/ |
24 | 24 |
package org.gvsig.fmap.geom.jts.operation.towkb; |
25 | 25 |
|
26 |
import static junit.framework.Assert.assertEquals; |
|
27 | 26 |
import org.gvsig.fmap.geom.Geometry; |
28 | 27 |
import org.gvsig.fmap.geom.GeometryLocator; |
29 | 28 |
import org.gvsig.fmap.geom.GeometryManager; |
... | ... | |
66 | 65 |
GeometryManager manager = GeometryLocator.getGeometryManager(); |
67 | 66 |
Data[] allData = new Data[] { |
68 | 67 |
new Data( |
69 |
"POINT (30 10)",
|
|
70 |
"0x01010000000000000000003E400000000000002440",
|
|
71 |
OGCWKBEncoder.wkbByteOrder.wkbNDR,
|
|
72 |
false
|
|
68 |
"POINT (30 10)", |
|
69 |
"0x01010000000000000000003E400000000000002440", |
|
70 |
OGCWKBEncoder.wkbByteOrder.wkbNDR, |
|
71 |
false |
|
73 | 72 |
), |
74 | 73 |
new Data( |
75 |
"LINESTRING (30 10, 10 30, 40 40)",
|
|
76 |
"0x0102000000030000000000000000003E40000000000000244000000000000024400000000000003E4000000000000044400000000000004440",
|
|
77 |
OGCWKBEncoder.wkbByteOrder.wkbNDR,
|
|
78 |
false
|
|
74 |
"LINESTRING (30 10, 10 30, 40 40)", |
|
75 |
"0x0102000000030000000000000000003E40000000000000244000000000000024400000000000003E4000000000000044400000000000004440", |
|
76 |
OGCWKBEncoder.wkbByteOrder.wkbNDR, |
|
77 |
false |
|
79 | 78 |
), |
80 | 79 |
new Data( |
81 |
"POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))",
|
|
82 |
"0x010300000001000000050000000000000000003E4000000000000024400000000000004440000000000000444000000000000034400000000000004440000000000000244000000000000034400000000000003E400000000000002440",
|
|
83 |
OGCWKBEncoder.wkbByteOrder.wkbNDR,
|
|
84 |
false
|
|
80 |
"POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))", |
|
81 |
"0x010300000001000000050000000000000000003E4000000000000024400000000000004440000000000000444000000000000034400000000000004440000000000000244000000000000034400000000000003E400000000000002440", |
|
82 |
OGCWKBEncoder.wkbByteOrder.wkbNDR, |
|
83 |
false |
|
85 | 84 |
), |
86 | 85 |
new Data( |
87 |
"POLYGON ((35 10, 45 45, 15 40, 10 20, 35 10),(20 30, 35 35, 30 20, 20 30))",
|
|
88 |
"0x0103000000020000000500000000000000008041400000000000002440000000000080464000000000008046400000000000002E40000000000000444000000000000024400000000000003440000000000080414000000000000024400400000000000000000034400000000000003E40000000000080414000000000008041400000000000003E40000000000000344000000000000034400000000000003E40",
|
|
89 |
OGCWKBEncoder.wkbByteOrder.wkbNDR,
|
|
90 |
false
|
|
86 |
"POLYGON ((35 10, 45 45, 15 40, 10 20, 35 10),(20 30, 35 35, 30 20, 20 30))", |
|
87 |
"0x0103000000020000000500000000000000008041400000000000002440000000000080464000000000008046400000000000002E40000000000000444000000000000024400000000000003440000000000080414000000000000024400400000000000000000034400000000000003E40000000000080414000000000008041400000000000003E40000000000000344000000000000034400000000000003E40", |
|
88 |
OGCWKBEncoder.wkbByteOrder.wkbNDR, |
|
89 |
false |
|
91 | 90 |
), |
92 | 91 |
new Data( |
93 |
"MULTIPOINT ((10 40), (40 30), (20 20), (30 10))",
|
|
94 |
"0x010400000004000000010100000000000000000024400000000000004440010100000000000000000044400000000000003E4001010000000000000000003440000000000000344001010000000000000000003E400000000000002440",
|
|
95 |
OGCWKBEncoder.wkbByteOrder.wkbNDR,
|
|
96 |
true
|
|
92 |
"MULTIPOINT ((10 40), (40 30), (20 20), (30 10))", |
|
93 |
"0x010400000004000000010100000000000000000024400000000000004440010100000000000000000044400000000000003E4001010000000000000000003440000000000000344001010000000000000000003E400000000000002440", |
|
94 |
OGCWKBEncoder.wkbByteOrder.wkbNDR, |
|
95 |
false
|
|
97 | 96 |
), |
98 | 97 |
new Data( |
99 |
"MULTIPOINT (10 40, 40 30, 20 20, 30 10)",
|
|
100 |
"0x010400000004000000010100000000000000000024400000000000004440010100000000000000000044400000000000003E4001010000000000000000003440000000000000344001010000000000000000003E400000000000002440",
|
|
101 |
OGCWKBEncoder.wkbByteOrder.wkbNDR,
|
|
102 |
true
|
|
98 |
"MULTIPOINT (10 40, 40 30, 20 20, 30 10)", |
|
99 |
"0x010400000004000000010100000000000000000024400000000000004440010100000000000000000044400000000000003E4001010000000000000000003440000000000000344001010000000000000000003E400000000000002440", |
|
100 |
OGCWKBEncoder.wkbByteOrder.wkbNDR, |
|
101 |
false
|
|
103 | 102 |
), |
104 | 103 |
new Data( |
105 |
"MULTILINESTRING ((10 10, 20 20, 10 40),(40 40, 30 30, 40 20, 30 10))",
|
|
106 |
"0x010500000002000000010200000003000000000000000000244000000000000024400000000000003440000000000000344000000000000024400000000000004440010200000004000000000000000000444000000000000044400000000000003E400000000000003E40000000000000444000000000000034400000000000003E400000000000002440",
|
|
107 |
OGCWKBEncoder.wkbByteOrder.wkbNDR,
|
|
108 |
false
|
|
104 |
"MULTILINESTRING ((10 10, 20 20, 10 40),(40 40, 30 30, 40 20, 30 10))", |
|
105 |
"0x010500000002000000010200000003000000000000000000244000000000000024400000000000003440000000000000344000000000000024400000000000004440010200000004000000000000000000444000000000000044400000000000003E400000000000003E40000000000000444000000000000034400000000000003E400000000000002440", |
|
106 |
OGCWKBEncoder.wkbByteOrder.wkbNDR, |
|
107 |
false |
|
109 | 108 |
), |
110 | 109 |
new Data( |
111 |
"MULTIPOLYGON (((30 20, 45 40, 10 40, 30 20)),((15 5, 40 10, 10 20, 5 10, 15 5)))",
|
|
112 |
"0x010600000002000000010300000001000000040000000000000000003E40000000000000344000000000008046400000000000004440000000000000244000000000000044400000000000003E400000000000003440010300000001000000050000000000000000002E4000000000000014400000000000004440000000000000244000000000000024400000000000003440000000000000144000000000000024400000000000002E400000000000001440",
|
|
113 |
OGCWKBEncoder.wkbByteOrder.wkbNDR,
|
|
114 |
false
|
|
110 |
"MULTIPOLYGON (((30 20, 45 40, 10 40, 30 20)),((15 5, 40 10, 10 20, 5 10, 15 5)))", |
|
111 |
"0x010600000002000000010300000001000000040000000000000000003E40000000000000344000000000008046400000000000004440000000000000244000000000000044400000000000003E400000000000003440010300000001000000050000000000000000002E4000000000000014400000000000004440000000000000244000000000000024400000000000003440000000000000144000000000000024400000000000002E400000000000001440", |
|
112 |
OGCWKBEncoder.wkbByteOrder.wkbNDR, |
|
113 |
false |
|
115 | 114 |
), |
116 | 115 |
new Data( |
117 |
"MULTIPOLYGON (((40 40, 20 45, 45 30, 40 40)),((20 35, 10 30, 10 10, 30 5, 45 20, 20 35),(30 20, 20 15, 20 25, 30 20)))",
|
|
118 |
"0x01060000000200000001030000000100000004000000000000000000444000000000000044400000000000003440000000000080464000000000008046400000000000003E4000000000000044400000000000004440010300000002000000060000000000000000003440000000000080414000000000000024400000000000003E40000000000000244000000000000024400000000000003E4000000000000014400000000000804640000000000000344000000000000034400000000000804140040000000000000000003E40000000000000344000000000000034400000000000002E40000000000000344000000000000039400000000000003E400000000000003440",
|
|
119 |
OGCWKBEncoder.wkbByteOrder.wkbNDR,
|
|
120 |
false
|
|
116 |
"MULTIPOLYGON (((40 40, 20 45, 45 30, 40 40)),((20 35, 10 30, 10 10, 30 5, 45 20, 20 35),(30 20, 20 15, 20 25, 30 20)))", |
|
117 |
"0x01060000000200000001030000000100000004000000000000000000444000000000000044400000000000003440000000000080464000000000008046400000000000003E4000000000000044400000000000004440010300000002000000060000000000000000003440000000000080414000000000000024400000000000003E40000000000000244000000000000024400000000000003E4000000000000014400000000000804640000000000000344000000000000034400000000000804140040000000000000000003E40000000000000344000000000000034400000000000002E40000000000000344000000000000039400000000000003E400000000000003440", |
|
118 |
OGCWKBEncoder.wkbByteOrder.wkbNDR, |
|
119 |
false |
|
121 | 120 |
), |
122 | 121 |
new Data( |
123 |
"POLYGON ((710847.97223687172 4368973.1207255824, 720362.03232662566 4368973.1207255824, 720362.03232662566 4373121.8750170888, 710847.97223687172 4373121.8750170888, 710847.97223687172 4368973.1207255824))", |
|
124 |
"0x010300000001000000050000000008C9F17FB12541CBF7B94793AA5041901D8D10D4FB2541CBF7B94793AA5041901D8D10D4FB2541AD470078A0AE50410008C9F17FB12541AD470078A0AE50410008C9F17FB12541CBF7B94793AA5041", |
|
125 |
OGCWKBEncoder.wkbByteOrder.wkbNDR, |
|
126 |
false |
|
127 |
), }; |
|
122 |
"POLYGON ((710847.97223687172 4368973.1207255824, 720362.03232662566 4368973.1207255824, 720362.03232662566 4373121.8750170888, 710847.97223687172 4373121.8750170888, 710847.97223687172 4368973.1207255824))", |
|
123 |
"0x010300000001000000050000000008C9F17FB12541CBF7B94793AA5041901D8D10D4FB2541CBF7B94793AA5041901D8D10D4FB2541AD470078A0AE50410008C9F17FB12541AD470078A0AE50410008C9F17FB12541CBF7B94793AA5041", |
|
124 |
OGCWKBEncoder.wkbByteOrder.wkbNDR, |
|
125 |
false |
|
126 |
), |
|
127 |
|
|
128 |
new Data( |
|
129 |
"POINT Z (30 10 20)", |
|
130 |
"0x01e90300000000000000003e4000000000000024400000000000003440", |
|
131 |
OGCWKBEncoder.wkbByteOrder.wkbNDR, |
|
132 |
false |
|
133 |
), |
|
134 |
|
|
135 |
new Data( |
|
136 |
"POINT M (30 10 30)", |
|
137 |
"0x01d10700000000000000003e4000000000000024400000000000003e40", |
|
138 |
OGCWKBEncoder.wkbByteOrder.wkbNDR, |
|
139 |
false |
|
140 |
), |
|
141 |
|
|
142 |
new Data( |
|
143 |
"POINT ZM (30 10 20 30)", |
|
144 |
"0x01b90b00000000000000003e40000000000000244000000000000034400000000000003e40", |
|
145 |
OGCWKBEncoder.wkbByteOrder.wkbNDR, |
|
146 |
false |
|
147 |
), |
|
148 |
|
|
149 |
new Data( |
|
150 |
"POLYGON Z ((30 10 10, 40 40 10, 20 40 10, 10 20 10, 30 10 10))", |
|
151 |
"0x01eb03000001000000050000000000000000003e40000000000000244000000000000024400000000000004440000000000000444000000000000024400000000000003440000000000000444000000000000024400000000000002440000000000000344000000000000024400000000000003e4000000000000024400000000000002440", |
|
152 |
OGCWKBEncoder.wkbByteOrder.wkbNDR, |
|
153 |
false |
|
154 |
), |
|
155 |
|
|
156 |
new Data( |
|
157 |
"POLYGON M ((30 10 100, 40 40 200, 20 40 300, 10 20 400, 30 10 500))", |
|
158 |
"0x01d307000001000000050000000000000000003e4000000000000024400000000000005940000000000000444000000000000044400000000000006940000000000000344000000000000044400000000000c072400000000000002440000000000000344000000000000079400000000000003e4000000000000024400000000000407f40", |
|
159 |
OGCWKBEncoder.wkbByteOrder.wkbNDR, |
|
160 |
false |
|
161 |
), |
|
162 |
|
|
163 |
new Data( |
|
164 |
"POLYGON ZM ((30 10 10 100, 40 40 10 200, 20 40 10 300, 10 20 10 400, 30 10 10 500))", |
|
165 |
"0x01bb0b000001000000050000000000000000003e4000000000000024400000000000002440000000000000594000000000000044400000000000004440000000000000244000000000000069400000000000003440000000000000444000000000000024400000000000c0724000000000000024400000000000003440000000000000244000000000000079400000000000003e40000000000000244000000000000024400000000000407f40", |
|
166 |
OGCWKBEncoder.wkbByteOrder.wkbNDR, |
|
167 |
false |
|
168 |
), |
|
169 |
|
|
170 |
new Data( |
|
171 |
"MULTIPOINT Z ((10 40 10), (40 30 10), (20 20 10), (30 10 10))", |
|
172 |
"0x01ec0300000400000001e903000000000000000024400000000000004440000000000000244001e903000000000000000044400000000000003e40000000000000244001e903000000000000000034400000000000003440000000000000244001e90300000000000000003e4000000000000024400000000000002440", |
|
173 |
OGCWKBEncoder.wkbByteOrder.wkbNDR, |
|
174 |
false |
|
175 |
), |
|
176 |
|
|
177 |
new Data( |
|
178 |
"MULTIPOINT M ((10 40 100), (40 30 200), (20 20 300), (30 10 400))", |
|
179 |
"0x01d40700000400000001d107000000000000000024400000000000004440000000000000594001d107000000000000000044400000000000003e40000000000000694001d1070000000000000000344000000000000034400000000000c0724001d10700000000000000003e4000000000000024400000000000007940", |
|
180 |
OGCWKBEncoder.wkbByteOrder.wkbNDR, |
|
181 |
false |
|
182 |
), |
|
183 |
|
|
184 |
new Data( |
|
185 |
"MULTIPOINT ZM ((10 40 10 100), (40 30 10 200), (20 20 10 300), (30 10 10 400))", |
|
186 |
"0x01bc0b00000400000001b90b0000000000000000244000000000000044400000000000002440000000000000594001b90b000000000000000044400000000000003e400000000000002440000000000000694001b90b00000000000000003440000000000000344000000000000024400000000000c0724001b90b00000000000000003e40000000000000244000000000000024400000000000007940", |
|
187 |
OGCWKBEncoder.wkbByteOrder.wkbNDR, |
|
188 |
false |
|
189 |
), |
|
190 |
|
|
191 |
new Data( |
|
192 |
"MULTIPOINT Z (10 40 10, 40 30 10, 20 20 10, 30 10 10)", |
|
193 |
"0x01ec0300000400000001e903000000000000000024400000000000004440000000000000244001e903000000000000000044400000000000003e40000000000000244001e903000000000000000034400000000000003440000000000000244001e90300000000000000003e4000000000000024400000000000002440", |
|
194 |
OGCWKBEncoder.wkbByteOrder.wkbNDR, |
|
195 |
false |
|
196 |
), |
|
197 |
|
|
198 |
new Data( |
|
199 |
"MULTIPOINT M (10 40 100, 40 30 200, 20 20 300, 30 10 400)", |
|
200 |
"0x01d40700000400000001d107000000000000000024400000000000004440000000000000594001d107000000000000000044400000000000003e40000000000000694001d1070000000000000000344000000000000034400000000000c0724001d10700000000000000003e4000000000000024400000000000007940", |
|
201 |
OGCWKBEncoder.wkbByteOrder.wkbNDR, |
|
202 |
false |
|
203 |
), |
|
204 |
|
|
205 |
new Data( |
|
206 |
"MULTIPOINT ZM (10 40 10 100, 40 30 10 200, 20 20 10 300, 30 10 10 400)", |
|
207 |
"0x01bc0b00000400000001b90b0000000000000000244000000000000044400000000000002440000000000000594001b90b000000000000000044400000000000003e400000000000002440000000000000694001b90b00000000000000003440000000000000344000000000000024400000000000c0724001b90b00000000000000003e40000000000000244000000000000024400000000000007940", |
|
208 |
OGCWKBEncoder.wkbByteOrder.wkbNDR, |
|
209 |
false |
|
210 |
), |
|
211 |
|
|
212 |
new Data( |
|
213 |
"MULTIPOLYGON Z (((30 20 10, 45 40 10, 10 40 10, 30 20 10)),((15 5 10, 40 10 10, 10 20 10, 5 10 10, 15 5 10)))", |
|
214 |
"0x01ee0300000200000001eb03000001000000040000000000000000003e40000000000000344000000000000024400000000000804640000000000000444000000000000024400000000000002440000000000000444000000000000024400000000000003e400000000000003440000000000000244001eb03000001000000050000000000000000002e40000000000000144000000000000024400000000000004440000000000000244000000000000024400000000000002440000000000000344000000000000024400000000000001440000000000000244000000000000024400000000000002e4000000000000014400000000000002440", |
|
215 |
OGCWKBEncoder.wkbByteOrder.wkbNDR, |
|
216 |
false |
|
217 |
), |
|
218 |
|
|
219 |
new Data( |
|
220 |
"MULTIPOLYGON M (((30 20 100, 45 40 200, 10 40 300, 30 20 400)),((15 5 20, 40 10 500, 10 20 600, 5 10 700, 15 5 800)))", |
|
221 |
"0x01d60700000200000001d307000001000000040000000000000000003e4000000000000034400000000000005940000000000080464000000000000044400000000000006940000000000000244000000000000044400000000000c072400000000000003e400000000000003440000000000000794001d307000001000000050000000000000000002e4000000000000014400000000000003440000000000000444000000000000024400000000000407f40000000000000244000000000000034400000000000c08240000000000000144000000000000024400000000000e085400000000000002e4000000000000014400000000000008940", |
|
222 |
OGCWKBEncoder.wkbByteOrder.wkbNDR, |
|
223 |
false |
|
224 |
), |
|
225 |
|
|
226 |
new Data( |
|
227 |
"MULTIPOLYGON ZM (((30 20 10 100, 45 40 10 200, 10 40 10 300, 30 20 10 400)),((15 5 10 500, 40 10 10 600, 10 20 10 700, 5 10 10 800, 15 5 10 900)))", |
|
228 |
"0x01be0b00000200000001bb0b000001000000040000000000000000003e4000000000000034400000000000002440000000000000594000000000008046400000000000004440000000000000244000000000000069400000000000002440000000000000444000000000000024400000000000c072400000000000003e4000000000000034400000000000002440000000000000794001bb0b000001000000050000000000000000002e40000000000000144000000000000024400000000000407f400000000000004440000000000000244000000000000024400000000000c082400000000000002440000000000000344000000000000024400000000000e0854000000000000014400000000000002440000000000000244000000000000089400000000000002e40000000000000144000000000000024400000000000208c40", |
|
229 |
OGCWKBEncoder.wkbByteOrder.wkbNDR, |
|
230 |
false |
|
231 |
), |
|
232 |
|
|
233 |
new Data( |
|
234 |
"LINESTRING M (30 10 100, 10 30 200, 40 40 300)", |
|
235 |
"0x01d2070000030000000000000000003e400000000000002440000000000000594000000000000024400000000000003e400000000000006940000000000000444000000000000044400000000000c07240", |
|
236 |
OGCWKBEncoder.wkbByteOrder.wkbNDR, |
|
237 |
false |
|
238 |
), |
|
239 |
|
|
240 |
new Data( |
|
241 |
"LINESTRING ZM (30 10 20 100, 10 30 20 200, 40 40 20 300)", |
|
242 |
"0x01ba0b0000030000000000000000003e4000000000000024400000000000003440000000000000594000000000000024400000000000003e40000000000000344000000000000069400000000000004440000000000000444000000000000034400000000000c07240", |
|
243 |
OGCWKBEncoder.wkbByteOrder.wkbNDR, |
|
244 |
false |
|
245 |
), |
|
246 |
|
|
247 |
new Data( |
|
248 |
"MULTILINESTRING M ((10 10 100, 20 20 200, 10 40 300),(40 40 400, 30 30 500, 40 20 600, 30 10 700))", |
|
249 |
"0x01d50700000200000001d207000003000000000000000000244000000000000024400000000000005940000000000000344000000000000034400000000000006940000000000000244000000000000044400000000000c0724001d2070000040000000000000000004440000000000000444000000000000079400000000000003e400000000000003e400000000000407f40000000000000444000000000000034400000000000c082400000000000003e4000000000000024400000000000e08540", |
|
250 |
OGCWKBEncoder.wkbByteOrder.wkbNDR, |
|
251 |
false |
|
252 |
), |
|
253 |
|
|
254 |
new Data( |
|
255 |
"MULTILINESTRING ZM ((10 10 20 100, 20 20 20 200, 10 40 20 300),(40 40 20 400, 30 30 20 500, 40 20 20 600, 30 10 20 700))", |
|
256 |
"0x01bd0b00000200000001ba0b000003000000000000000000244000000000000024400000000000003440000000000000594000000000000034400000000000003440000000000000344000000000000069400000000000002440000000000000444000000000000034400000000000c0724001ba0b00000400000000000000000044400000000000004440000000000000344000000000000079400000000000003e400000000000003e4000000000000034400000000000407f400000000000004440000000000000344000000000000034400000000000c082400000000000003e40000000000000244000000000000034400000000000e08540", |
|
257 |
OGCWKBEncoder.wkbByteOrder.wkbNDR, |
|
258 |
false |
|
259 |
), |
|
260 |
|
|
261 |
|
|
262 |
}; |
|
128 | 263 |
|
129 | 264 |
System.out.println("# Test:: test1"); |
130 | 265 |
for (Data data : allData) { |
... | ... | |
139 | 274 |
System.out.println("# WKB-E:: " + data.wkb); |
140 | 275 |
System.out.println("# WKB-R:: " + bytearray(wbk)); |
141 | 276 |
assertEquals(data.wkb.toUpperCase(),bytearray(wbk).toUpperCase()); |
277 |
Geometry geom2 = manager.createFrom(wbk); |
|
278 |
assertNotNull(geom2); |
|
279 |
assertEquals(geom.getGeometryType(), geom2.getGeometryType()); |
|
280 |
assertEquals(geom, geom2); |
|
142 | 281 |
} |
143 | 282 |
} |
144 | 283 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.jts/src/main/java/org/gvsig/fmap/geom/jts/aggregate/DefaultMultiCurve.java | ||
---|---|---|
79 | 79 |
other.setProjection(this.getProjection()); |
80 | 80 |
other.ensureCapacity(primitives.size()); |
81 | 81 |
for (Primitive primitive : primitives) { |
82 |
other.addPrimitive((Primitive)primitive.force2D());
|
|
82 |
other.addPrimitive((Primitive)primitive.forceSubtype(Geometry.SUBTYPES.GEOM2D));
|
|
83 | 83 |
} |
84 | 84 |
return other; |
85 | 85 |
} |
86 | 86 |
|
87 | 87 |
@Override |
88 |
public Geometry force2DM() throws GeometryOperationNotSupportedException, GeometryOperationException { |
|
89 |
DefaultMultiCurve other = new DefaultMultiCurve(getGeometryType()); |
|
90 |
other.setProjection(this.getProjection()); |
|
91 |
other.ensureCapacity(primitives.size()); |
|
92 |
for (Primitive primitive : primitives) { |
|
93 |
other.addPrimitive((Primitive)primitive.forceSubtype(Geometry.SUBTYPES.GEOM2DM)); |
|
94 |
} |
|
95 |
return other; |
|
96 |
} |
|
97 |
|
|
98 |
@Override |
|
99 |
public Geometry force3D() throws GeometryOperationNotSupportedException, GeometryOperationException { |
|
100 |
DefaultMultiCurve other = new DefaultMultiCurve(getGeometryType()); |
|
101 |
other.setProjection(this.getProjection()); |
|
102 |
other.ensureCapacity(primitives.size()); |
|
103 |
for (Primitive primitive : primitives) { |
|
104 |
other.addPrimitive((Primitive)primitive.forceSubtype(Geometry.SUBTYPES.GEOM3D)); |
|
105 |
} |
|
106 |
return other; |
|
107 |
} |
|
108 |
|
|
109 |
@Override |
|
110 |
public Geometry force3DM() throws GeometryOperationNotSupportedException, GeometryOperationException { |
|
111 |
DefaultMultiCurve other = new DefaultMultiCurve(getGeometryType()); |
|
112 |
other.setProjection(this.getProjection()); |
|
113 |
other.ensureCapacity(primitives.size()); |
|
114 |
for (Primitive primitive : primitives) { |
|
115 |
other.addPrimitive((Primitive)primitive.forceSubtype(Geometry.SUBTYPES.GEOM3DM)); |
|
116 |
} |
|
117 |
return other; |
|
118 |
} |
|
119 |
|
|
120 |
@Override |
|
88 | 121 |
public int getDimension() { |
89 | 122 |
switch (getGeometryType().getSubType()) { |
90 | 123 |
case Geometry.SUBTYPES.GEOM2D: |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.jts/src/main/java/org/gvsig/fmap/geom/jts/aggregate/DefaultMultiSurface.java | ||
---|---|---|
74 | 74 |
other.setProjection(this.getProjection()); |
75 | 75 |
other.ensureCapacity(primitives.size()); |
76 | 76 |
for (Primitive primitive : primitives) { |
77 |
other.addPrimitive((Primitive)primitive.force2D());
|
|
77 |
other.addPrimitive((Primitive)primitive.forceSubtype(Geometry.SUBTYPES.GEOM2D));
|
|
78 | 78 |
} |
79 | 79 |
return other; |
80 | 80 |
} |
81 | 81 |
|
82 | 82 |
@Override |
83 |
public Geometry force2DM() throws GeometryOperationNotSupportedException, GeometryOperationException { |
|
84 |
DefaultMultiSurface other = new DefaultMultiSurface(getGeometryType()); |
|
85 |
other.setProjection(this.getProjection()); |
|
86 |
other.ensureCapacity(primitives.size()); |
|
87 |
for (Primitive primitive : primitives) { |
|
88 |
other.addPrimitive((Primitive)primitive.forceSubtype(Geometry.SUBTYPES.GEOM2DM)); |
|
89 |
} |
|
90 |
return other; |
|
91 |
} |
|
92 |
|
|
93 |
@Override |
|
94 |
public Geometry force3D() throws GeometryOperationNotSupportedException, GeometryOperationException { |
|
95 |
DefaultMultiSurface other = new DefaultMultiSurface(getGeometryType()); |
|
96 |
other.setProjection(this.getProjection()); |
|
97 |
other.ensureCapacity(primitives.size()); |
|
98 |
for (Primitive primitive : primitives) { |
|
99 |
other.addPrimitive((Primitive)primitive.forceSubtype(Geometry.SUBTYPES.GEOM3D)); |
|
100 |
} |
|
101 |
return other; |
|
102 |
} |
|
103 |
|
|
104 |
@Override |
|
105 |
public Geometry force3DM() throws GeometryOperationNotSupportedException, GeometryOperationException { |
|
106 |
DefaultMultiSurface other = new DefaultMultiSurface(getGeometryType()); |
|
107 |
other.setProjection(this.getProjection()); |
|
108 |
other.ensureCapacity(primitives.size()); |
|
109 |
for (Primitive primitive : primitives) { |
|
110 |
other.addPrimitive((Primitive)primitive.forceSubtype(Geometry.SUBTYPES.GEOM3DM)); |
|
111 |
} |
|
112 |
return other; |
|
113 |
} |
|
114 |
|
|
115 |
@Override |
|
83 | 116 |
public void addSurface(Surface surface) { |
84 | 117 |
GeometryType geometryType = surface.getGeometryType(); |
85 | 118 |
if(geometryType.getSubType() == getGeometryType().getSubType()){ |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.jts/src/main/java/org/gvsig/fmap/geom/jts/aggregate/AbstractMultiPolygon.java | ||
---|---|---|
76 | 76 |
other.setProjection(this.getProjection()); |
77 | 77 |
other.ensureCapacity(primitives.size()); |
78 | 78 |
for (Primitive primitive : primitives) { |
79 |
other.addPrimitive((Primitive)primitive.force2D());
|
|
79 |
other.addPrimitive((Primitive)primitive.forceSubtype(Geometry.SUBTYPES.GEOM2D));
|
|
80 | 80 |
} |
81 | 81 |
return other; |
82 | 82 |
} |
83 | 83 |
|
84 | 84 |
@Override |
85 |
public Geometry force2DM() throws GeometryOperationNotSupportedException, GeometryOperationException { |
|
86 |
MultiPolygon2DM other = new MultiPolygon2DM(); |
|
87 |
other.setProjection(this.getProjection()); |
|
88 |
other.ensureCapacity(primitives.size()); |
|
89 |
for (Primitive primitive : primitives) { |
|
90 |
other.addPrimitive((Primitive)primitive.forceSubtype(Geometry.SUBTYPES.GEOM2DM)); |
|
91 |
} |
|
92 |
return other; |
|
93 |
} |
|
94 |
|
|
95 |
@Override |
|
96 |
public Geometry force3D() throws GeometryOperationNotSupportedException, GeometryOperationException { |
|
97 |
MultiPolygon3D other = new MultiPolygon3D(); |
|
98 |
other.setProjection(this.getProjection()); |
|
99 |
other.ensureCapacity(primitives.size()); |
|
100 |
for (Primitive primitive : primitives) { |
|
101 |
other.addPrimitive((Primitive)primitive.forceSubtype(Geometry.SUBTYPES.GEOM3D)); |
|
102 |
} |
|
103 |
return other; |
|
104 |
} |
|
105 |
|
|
106 |
@Override |
|
107 |
public Geometry force3DM() throws GeometryOperationNotSupportedException, GeometryOperationException { |
|
108 |
MultiPolygon3DM other = new MultiPolygon3DM(); |
|
109 |
other.setProjection(this.getProjection()); |
|
110 |
other.ensureCapacity(primitives.size()); |
|
111 |
for (Primitive primitive : primitives) { |
|
112 |
other.addPrimitive((Primitive)primitive.forceSubtype(Geometry.SUBTYPES.GEOM3DM)); |
|
113 |
} |
|
114 |
return other; |
|
115 |
} |
|
116 |
|
|
117 |
@Override |
|
85 | 118 |
public PathIterator getPathIterator(AffineTransform at) { |
86 | 119 |
MultiPolygonIterator pi = new MultiPolygonIterator(at); |
87 | 120 |
return pi; |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.jts/src/main/java/org/gvsig/fmap/geom/jts/aggregate/AbstractMultiLine.java | ||
---|---|---|
66 | 66 |
other.setProjection(this.getProjection()); |
67 | 67 |
other.ensureCapacity(primitives.size()); |
68 | 68 |
for (Primitive primitive : primitives) { |
69 |
other.addPrimitive((Primitive)primitive.force2D());
|
|
69 |
other.addPrimitive((Primitive)primitive.forceSubtype(Geometry.SUBTYPES.GEOM2D));
|
|
70 | 70 |
} |
71 | 71 |
return other; |
72 | 72 |
} |
73 | 73 |
|
74 | 74 |
@Override |
75 |
public Geometry force2DM() throws GeometryOperationNotSupportedException, GeometryOperationException { |
|
76 |
MultiLine2DM other = new MultiLine2DM(); |
|
77 |
other.setProjection(this.getProjection()); |
|
78 |
other.ensureCapacity(primitives.size()); |
|
79 |
for (Primitive primitive : primitives) { |
|
80 |
other.addPrimitive((Primitive)primitive.forceSubtype(Geometry.SUBTYPES.GEOM2DM)); |
|
81 |
} |
|
82 |
return other; |
|
83 |
} |
|
84 |
|
|
85 |
@Override |
|
86 |
public Geometry force3D() throws GeometryOperationNotSupportedException, GeometryOperationException { |
|
87 |
MultiLine3D other = new MultiLine3D(); |
|
88 |
other.setProjection(this.getProjection()); |
|
89 |
other.ensureCapacity(primitives.size()); |
|
90 |
for (Primitive primitive : primitives) { |
|
91 |
other.addPrimitive((Primitive)primitive.forceSubtype(Geometry.SUBTYPES.GEOM3D)); |
|
92 |
} |
|
93 |
return other; |
|
94 |
} |
|
95 |
|
|
96 |
@Override |
|
97 |
public Geometry force3DM() throws GeometryOperationNotSupportedException, GeometryOperationException { |
|
98 |
MultiLine3DM other = new MultiLine3DM(); |
|
99 |
other.setProjection(this.getProjection()); |
|
100 |
other.ensureCapacity(primitives.size()); |
|
101 |
for (Primitive primitive : primitives) { |
|
102 |
other.addPrimitive((Primitive)primitive.forceSubtype(Geometry.SUBTYPES.GEOM3DM)); |
|
103 |
} |
|
104 |
return other; |
|
105 |
} |
|
106 |
|
|
107 |
@Override |
|
75 | 108 |
public void flip() throws GeometryOperationNotSupportedException, GeometryOperationException { |
76 | 109 |
for (Iterator iterator = primitives.iterator(); iterator.hasNext();) { |
77 | 110 |
((GeometryJTS)iterator.next()).flip(); |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.jts/src/main/java/org/gvsig/fmap/geom/jts/aggregate/AbstractMultiPoint.java | ||
---|---|---|
27 | 27 |
import java.awt.geom.PathIterator; |
28 | 28 |
import java.util.Collections; |
29 | 29 |
import java.util.Iterator; |
30 |
|
|
31 | 30 |
import org.gvsig.fmap.geom.Geometry; |
32 | 31 |
import org.gvsig.fmap.geom.aggregate.MultiPoint; |
33 | 32 |
import org.gvsig.fmap.geom.jts.gputils.DefaultGeneralPathX; |
... | ... | |
83 | 82 |
} |
84 | 83 |
|
85 | 84 |
@Override |
85 |
public Geometry force2DM() throws GeometryOperationNotSupportedException, GeometryOperationException { |
|
86 |
MultiPoint2DM other = new MultiPoint2DM(); |
|
87 |
other.setProjection(this.getProjection()); |
|
88 |
other.ensureCapacity(primitives.size()); |
|
89 |
for (Primitive primitive : primitives) { |
|
90 |
other.addPrimitive(((Point) primitive).force2DM()); |
|
91 |
} |
|
92 |
return other; |
|
93 |
} |
|
94 |
|
|
95 |
@Override |
|
96 |
public Geometry force3D() throws GeometryOperationNotSupportedException, GeometryOperationException { |
|
97 |
MultiPoint3D other = new MultiPoint3D(); |
|
98 |
other.setProjection(this.getProjection()); |
|
99 |
other.ensureCapacity(primitives.size()); |
|
100 |
for (Primitive primitive : primitives) { |
|
101 |
other.addPrimitive(((Point) primitive).force3D()); |
|
102 |
} |
|
103 |
return other; |
|
104 |
} |
|
105 |
|
|
106 |
@Override |
|
107 |
public Geometry force3DM() throws GeometryOperationNotSupportedException, GeometryOperationException { |
|
108 |
MultiPoint3DM other = new MultiPoint3DM(); |
|
109 |
other.setProjection(this.getProjection()); |
|
110 |
other.ensureCapacity(primitives.size()); |
|
111 |
for (Primitive primitive : primitives) { |
|
112 |
other.addPrimitive(((Point) primitive).force3DM()); |
|
113 |
} |
|
114 |
return other; |
|
115 |
} |
|
116 |
|
|
117 |
|
|
118 |
@Override |
|
119 |
public Geometry forceSubtype(int subtype) throws GeometryOperationNotSupportedException, GeometryOperationException { |
|
120 |
switch(subtype){ |
|
121 |
case Geometry.SUBTYPES.GEOM2D: |
|
122 |
return force2D(); |
|
123 |
case Geometry.SUBTYPES.GEOM2DM: |
|
124 |
return force2DM(); |
|
125 |
case Geometry.SUBTYPES.GEOM3D: |
|
126 |
return force3D(); |
|
127 |
case Geometry.SUBTYPES.GEOM3DM: |
|
128 |
return force3DM(); |
|
129 |
} |
|
130 |
return this; |
|
131 |
} |
|
132 |
|
|
133 |
|
|
134 |
|
|
135 |
@Override |
|
86 | 136 |
public void addPoint(Point point) { |
87 | 137 |
point = fixPoint(point); |
88 | 138 |
primitives.add(point); |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.jts/src/main/java/org/gvsig/fmap/geom/jts/AbstractGeometry.java | ||
---|---|---|
1016 | 1016 |
} |
1017 | 1017 |
} |
1018 | 1018 |
|
1019 |
@Override |
|
1020 |
public Geometry forceSubtype(int subtype) throws GeometryOperationNotSupportedException, GeometryOperationException { |
|
1021 |
switch(subtype){ |
|
1022 |
case Geometry.SUBTYPES.GEOM2D: |
|
1023 |
return force2D(); |
|
1024 |
case Geometry.SUBTYPES.GEOM2DM: |
|
1025 |
return force2DM(); |
|
1026 |
case Geometry.SUBTYPES.GEOM3D: |
|
1027 |
return force3D(); |
|
1028 |
case Geometry.SUBTYPES.GEOM3DM: |
|
1029 |
return force3DM(); |
|
1030 |
} |
|
1031 |
return this; |
|
1032 |
} |
|
1019 | 1033 |
|
1034 |
protected abstract Geometry force2DM() throws GeometryOperationNotSupportedException, GeometryOperationException; |
|
1035 |
|
|
1036 |
protected abstract Geometry force3D() throws GeometryOperationNotSupportedException, GeometryOperationException; |
|
1037 |
|
|
1038 |
protected abstract Geometry force3DM() throws GeometryOperationNotSupportedException, GeometryOperationException; |
|
1039 |
|
|
1040 |
|
|
1041 |
|
|
1042 |
|
|
1020 | 1043 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.jts/src/main/java/org/gvsig/fmap/geom/jts/coerce/CoerceToGeometry.java | ||
---|---|---|
117 | 117 |
case Geometry.TYPES.MULTIPOINT: |
118 | 118 |
geom = geom.toPoints(); |
119 | 119 |
break; |
120 |
case Geometry.TYPES.MULTICURVE: |
|
121 |
if(geom.getGeometryType().getSubType() != Geometry.TYPES.MULTICURVE){ |
|
122 |
geom = geom.toLines(); |
|
123 |
} |
|
124 |
break; |
|
120 | 125 |
case Geometry.TYPES.MULTILINE: |
121 | 126 |
geom = geom.toLines(); |
122 | 127 |
break; |
128 |
case Geometry.TYPES.MULTISURFACE: |
|
129 |
if(geom.getGeometryType().getSubType() != Geometry.TYPES.MULTISURFACE){ |
|
130 |
geom = geom.toPolygons(); |
|
131 |
} |
|
132 |
break; |
|
123 | 133 |
case Geometry.TYPES.MULTIPOLYGON: |
124 | 134 |
geom = geom.toPolygons(); |
125 | 135 |
break; |
126 | 136 |
case Geometry.TYPES.POINT: |
127 | 137 |
geom = this.convertToPoint(targetGeometryType, geom); |
128 | 138 |
break; |
139 |
case Geometry.TYPES.CURVE: |
|
140 |
if(geom.getGeometryType().getSubType() != Geometry.TYPES.CURVE){ |
|
141 |
geom = this.convertToLine(targetGeometryType, geom); |
|
142 |
} |
|
143 |
break; |
|
129 | 144 |
case Geometry.TYPES.LINE: |
130 | 145 |
geom = this.convertToLine(targetGeometryType, geom); |
131 | 146 |
break; |
147 |
case Geometry.TYPES.SURFACE: |
|
148 |
if(geom.getGeometryType().getSubType() != Geometry.TYPES.SURFACE){ |
|
149 |
geom = this.convertToPolygon(targetGeometryType, geom); |
|
150 |
} |
|
151 |
break; |
|
132 | 152 |
case Geometry.TYPES.POLYGON: |
133 | 153 |
geom = this.convertToPolygon(targetGeometryType, geom); |
134 | 154 |
break; |
... | ... | |
139 | 159 |
geom = null; |
140 | 160 |
break; |
141 | 161 |
} |
162 |
|
|
163 |
if (geom.getGeometryType().getSubType() != targetGeometryType.getSubType()) { |
|
164 |
geom = geom.forceSubtype(targetGeometryType.getSubType()); |
|
165 |
} |
|
166 |
|
|
142 | 167 |
if (geom != null) { |
143 | 168 |
// Return converted geometry |
144 | 169 |
return geom; |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.jts/src/main/java/org/gvsig/fmap/geom/jts/operation/towkb/OGCWKBEncoder.java | ||
---|---|---|
21 | 21 |
* For any additional information, do not hesitate to contact us |
22 | 22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
23 | 23 |
*/ |
24 |
|
|
25 | 24 |
package org.gvsig.fmap.geom.jts.operation.towkb; |
26 | 25 |
|
27 |
import java.awt.geom.PathIterator; |
|
28 | 26 |
import java.io.ByteArrayOutputStream; |
29 | 27 |
import java.io.DataOutputStream; |
30 | 28 |
import java.io.IOException; |
31 |
import java.util.ArrayList; |
|
32 |
import java.util.List; |
|
33 | 29 |
import org.apache.commons.io.EndianUtils; |
34 |
|
|
35 | 30 |
import org.gvsig.fmap.geom.Geometry; |
36 | 31 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
37 | 32 |
import org.gvsig.fmap.geom.Geometry.TYPES; |
33 |
import org.gvsig.fmap.geom.GeometryException; |
|
38 | 34 |
import org.gvsig.fmap.geom.aggregate.Aggregate; |
39 |
import org.gvsig.fmap.geom.aggregate.MultiCurve;
|
|
35 |
import org.gvsig.fmap.geom.aggregate.MultiLine;
|
|
40 | 36 |
import org.gvsig.fmap.geom.aggregate.MultiPoint; |
41 |
import org.gvsig.fmap.geom.aggregate.MultiSurface;
|
|
42 |
import org.gvsig.fmap.geom.primitive.Curve;
|
|
37 |
import org.gvsig.fmap.geom.aggregate.MultiPolygon;
|
|
38 |
import org.gvsig.fmap.geom.primitive.Line;
|
|
43 | 39 |
import org.gvsig.fmap.geom.primitive.Point; |
44 |
import org.gvsig.fmap.geom.primitive.Surface; |
|
40 |
import org.gvsig.fmap.geom.primitive.Polygon; |
|
41 |
import org.gvsig.fmap.geom.primitive.Ring; |
|
45 | 42 |
import org.gvsig.fmap.geom.type.GeometryType; |
46 | 43 |
import org.gvsig.fmap.geom.type.GeometryTypeNotSupportedException; |
47 | 44 |
|
45 |
public class OGCWKBEncoder { |
|
48 | 46 |
|
47 |
public interface wkbGeometryType { |
|
49 | 48 |
|
50 |
public class OGCWKBEncoder { |
|
49 |
public final static int wkbPoint = 1; |
|
50 |
public final static int wkbLineString = 2; |
|
51 |
public final static int wkbPolygon = 3; |
|
52 |
public final static int wkbTriangle = 17; |
|
53 |
public final static int wkbMultiPoint = 4; |
|
54 |
public final static int wkbMultiLineString = 5; |
|
55 |
public final static int wkbMultiPolygon = 6; |
|
56 |
public final static int wkbGeometryCollection = 7; |
|
57 |
public final static int wkbPolyhedralSurface = 15; |
|
58 |
public final static int wkbTIN = 16; |
|
51 | 59 |
|
52 |
public interface wkbGeometryType { |
|
53 |
public final static int wkbPoint = 1; |
|
54 |
public final static int wkbLineString = 2; |
|
55 |
public final static int wkbPolygon = 3; |
|
56 |
public final static int wkbTriangle = 17; |
|
57 |
public final static int wkbMultiPoint = 4; |
|
58 |
public final static int wkbMultiLineString = 5; |
|
59 |
public final static int wkbMultiPolygon = 6; |
|
60 |
public final static int wkbGeometryCollection = 7; |
|
61 |
public final static int wkbPolyhedralSurface = 15; |
|
62 |
public final static int wkbTIN = 16; |
|
60 |
public final static int wkbPointZ = 1001; |
|
61 |
public final static int wkbLineStringZ = 1002; |
|
62 |
public final static int wkbPolygonZ = 1003; |
|
63 |
public final static int wkbTrianglez = 1017; |
|
64 |
public final static int wkbMultiPointZ = 1004; |
|
65 |
public final static int wkbMultiLineStringZ = 1005; |
|
66 |
public final static int wkbMultiPolygonZ = 1006; |
|
67 |
public final static int wkbGeometryCollectionZ = 1007; |
|
68 |
public final static int wkbPolyhedralSurfaceZ = 1015; |
|
69 |
public final static int wkbTINZ = 1016; |
|
63 | 70 |
|
64 |
public final static int wkbPointZ = 1001;
|
|
65 |
public final static int wkbLineStringZ = 1002;
|
|
66 |
public final static int wkbPolygonZ = 1003;
|
|
67 |
public final static int wkbTrianglez = 1017;
|
|
68 |
public final static int wkbMultiPointZ = 1004;
|
|
69 |
public final static int wkbMultiLineStringZ = 1005;
|
|
70 |
public final static int wkbMultiPolygonZ = 1006;
|
|
71 |
public final static int wkbGeometryCollectionZ = 1007;
|
|
72 |
public final static int wkbPolyhedralSurfaceZ = 1015;
|
|
73 |
public final static int wkbTINZ = 1016;
|
|
71 |
public final static int wkbPointM = 2001;
|
|
72 |
public final static int wkbLineStringM = 2002;
|
|
73 |
public final static int wkbPolygonM = 2003;
|
|
74 |
public final static int wkbTriangleM = 2017;
|
|
75 |
public final static int wkbMultiPointM = 2004;
|
|
76 |
public final static int wkbMultiLineStringM = 2005;
|
|
77 |
public final static int wkbMultiPolygonM = 2006;
|
|
78 |
public final static int wkbGeometryCollectionM = 2007;
|
|
79 |
public final static int wkbPolyhedralSurfaceM = 2015;
|
|
80 |
public final static int wkbTINM = 2016;
|
|
74 | 81 |
|
75 |
public final static int wkbPointM = 2001;
|
|
76 |
public final static int wkbLineStringM = 2002;
|
|
77 |
public final static int wkbPolygonM = 2003;
|
|
78 |
public final static int wkbTriangleM = 2017;
|
|
79 |
public final static int wkbMultiPointM = 2004;
|
|
80 |
public final static int wkbMultiLineStringM = 2005;
|
|
81 |
public final static int wkbMultiPolygonM = 2006;
|
|
82 |
public final static int wkbGeometryCollectionM = 2007;
|
|
83 |
public final static int wkbPolyhedralSurfaceM = 2015;
|
|
84 |
public final static int wkbTINM = 2016;
|
|
82 |
public final static int wkbPointZM = 3001;
|
|
83 |
public final static int wkbLineStringZM = 3002;
|
|
84 |
public final static int wkbPolygonZM = 3003;
|
|
85 |
public final static int wkbTriangleZM = 3017;
|
|
86 |
public final static int wkbMultiPointZM = 3004;
|
|
87 |
public final static int wkbMultiLineStringZM = 3005;
|
|
88 |
public final static int wkbMultiPolygonZM = 3006;
|
|
89 |
public final static int wkbGeometryCollectionZM = 3007;
|
|
90 |
public final static int wkbPolyhedralSurfaceZM = 3015;
|
|
91 |
public final static int wkbTinZM = 3016;
|
|
85 | 92 |
|
86 |
public final static int wkbPointZM = 3001; |
|
87 |
public final static int wkbLineStringZM = 3002; |
|
88 |
public final static int wkbPolygonZM = 3003; |
|
89 |
public final static int wkbTriangleZM = 3017; |
|
90 |
public final static int wkbMultiPointZM = 3004; |
|
91 |
public final static int wkbMultiLineStringZM = 3005; |
|
92 |
public final static int wkbMultiPolygonZM = 3006; |
|
93 |
public final static int wkbGeometryCollectionZM = 3007; |
|
94 |
public final static int wkbPolyhedralSurfaceZM = 3015; |
|
95 |
public final static int wkbTinZM = 3016; |
|
93 |
public final static int wkb_baseToZ = wkbPointZ - wkbPoint; |
|
94 |
public final static int wkb_baseToM = wkbPointM - wkbPoint; |
|
95 |
public final static int wkb_baseToZM = wkbPointZM - wkbPoint; |
|
96 |
} |
|
96 | 97 |
|
97 |
public final static int wkb_baseToZ = wkbPointZ - wkbPoint; |
|
98 |
public final static int wkb_baseToM = wkbPointM - wkbPoint; |
|
99 |
public final static int wkb_baseToZM = wkbPointZM - wkbPoint; |
|
100 |
} |
|
98 |
public interface wkbByteOrder { |
|
101 | 99 |
|
102 |
public interface wkbByteOrder { |
|
103 |
public final static byte wkbXDR = 0; // Big Endian |
|
104 |
public final static byte wkbNDR = 1; // Little Endian |
|
105 |
} |
|
100 |
public final static byte wkbXDR = 0; // Big Endian |
|
101 |
public final static byte wkbNDR = 1; // Little Endian |
|
102 |
} |
|
106 | 103 |
|
107 |
private int byteOrder; |
|
108 |
|
|
109 |
public OGCWKBEncoder() { |
|
110 |
this(wkbByteOrder.wkbXDR); |
|
111 |
} |
|
112 |
|
|
113 |
public OGCWKBEncoder(int byteOrder) { |
|
114 |
this.byteOrder = byteOrder; |
|
115 |
} |
|
116 |
|
|
117 |
public byte[] encode(Geometry geometry) |
|
118 |
throws GeometryTypeNotSupportedException, |
|
119 |
WKBEncodingException, |
|
120 |
IOException { |
|
121 |
ByteArrayOutputStream stream; |
|
104 |
private int byteOrder; |
|
122 | 105 |
|
123 |
if (geometry.getType() == TYPES.POINT) { |
|
124 |
stream = new ByteArrayOutputStream(50); |
|
125 |
} else { |
|
126 |
stream = new ByteArrayOutputStream(512); |
|
127 |
} |
|
106 |
public OGCWKBEncoder() { |
|
107 |
this(wkbByteOrder.wkbXDR); |
|
108 |
} |
|
128 | 109 |
|
129 |
encode(geometry, stream); |
|
130 |
return stream.toByteArray(); |
|
110 |
public OGCWKBEncoder(int byteOrder) { |
|
111 |
this.byteOrder = byteOrder; |
|
112 |
} |
|
131 | 113 |
|
132 |
} |
|
133 |
public void encode(Geometry geometry, ByteArrayOutputStream stream) |
|
134 |
throws GeometryTypeNotSupportedException, WKBEncodingException, |
|
135 |
IOException { |
|
136 |
encode(geometry, new DataOutputStream(stream)); |
|
137 |
} |
|
114 |
public byte[] encode(Geometry geometry) |
|
115 |
throws GeometryTypeNotSupportedException, |
|
116 |
WKBEncodingException, |
|
117 |
IOException { |
|
118 |
ByteArrayOutputStream stream; |
|
138 | 119 |
|
139 |
public void encode(Geometry geometry, DataOutputStream stream) |
|
140 |
throws GeometryTypeNotSupportedException, |
|
141 |
WKBEncodingException, |
|
142 |
IOException { |
|
143 |
if (geometry.getGeometryType().isTypeOf(TYPES.POINT)) { |
|
144 |
encodePoint(geometry, stream); |
|
120 |
if (geometry.getType() == TYPES.POINT) { |
|
121 |
stream = new ByteArrayOutputStream(50); |
|
122 |
} else { |
|
123 |
stream = new ByteArrayOutputStream(512); |
|
124 |
} |
|
145 | 125 |
|
146 |
} else if (geometry.getGeometryType().isTypeOf(TYPES.CURVE)) {
|
|
147 |
encodeLineString(geometry, stream);
|
|
126 |
encode(geometry, stream);
|
|
127 |
return stream.toByteArray();
|
|
148 | 128 |
|
149 |
} else if (geometry.getGeometryType().isTypeOf(TYPES.SURFACE)) { |
|
150 |
encodePolygon(geometry, stream); |
|
129 |
} |
|
151 | 130 |
|
152 |
} else if (geometry.getGeometryType().isTypeOf(TYPES.AGGREGATE)) { |
|
153 |
switch (geometry.getType()) { |
|
154 |
case TYPES.MULTIPOINT: |
|
155 |
encodeMultiPoint(geometry, stream); |
|
156 |
break; |
|
157 |
case TYPES.MULTICURVE: |
|
158 |
case TYPES.MULTILINE: |
|
159 |
encodeMultiLineString(geometry, stream); |
|
160 |
break; |
|
131 |
public void encode(Geometry geometry, ByteArrayOutputStream stream) |
|
132 |
throws GeometryTypeNotSupportedException, WKBEncodingException, |
|
133 |
IOException { |
|
134 |
encode(geometry, new DataOutputStream(stream)); |
|
135 |
} |
|
161 | 136 |
|
162 |
case TYPES.MULTISURFACE: |
|
163 |
case TYPES.MULTIPOLYGON: |
|
164 |
encodeMultiPolygon(geometry, stream); |
|
165 |
break; |
|
137 |
public void encode(Geometry geometry, DataOutputStream stream) |
|
138 |
throws GeometryTypeNotSupportedException, |
|
139 |
WKBEncodingException, |
|
140 |
IOException { |
|
141 |
if (geometry.getGeometryType().isTypeOf(TYPES.POINT)) { |
|
142 |
encodePoint(geometry, stream); |
|
166 | 143 |
|
167 |
case TYPES.AGGREGATE: |
|
168 |
encodeCollection(geometry, stream); |
|
169 |
break; |
|
144 |
} else if (geometry.getGeometryType().isTypeOf(TYPES.LINE)) { |
|
145 |
encodeLineString((Line)geometry, stream); |
|
146 |
} else if (geometry.getGeometryType().isTypeOf(TYPES.CURVE)) { |
|
147 |
try { |
|
148 |
MultiLine lines = geometry.toLines(); |
|
149 |
if(lines.getPrimitivesNumber() == 1){ |
|
150 |
encodeLineString((Line) lines.getPrimitiveAt(0), stream); |
|
151 |
} else { |
|
152 |
encodeMultiLineString(lines, stream); |
|
170 | 153 |
} |
154 |
} catch (GeometryException ex) { |
|
155 |
throw new WKBEncodingException(ex); |
|
156 |
} |
|
171 | 157 |
|
172 |
} else { |
|
173 |
throw new GeometryTypeNotSupportedException(geometry.getType(), |
|
174 |
geometry.getGeometryType().getSubType()); |
|
158 |
} else if (geometry.getGeometryType().isTypeOf(TYPES.POLYGON)) { |
|
159 |
encodePolygon((Polygon) geometry, stream); |
|
160 |
} else if (geometry.getGeometryType().isTypeOf(TYPES.SURFACE)) { |
|
161 |
try { |
|
162 |
MultiPolygon pols = geometry.toPolygons(); |
|
163 |
if(pols.getPrimitivesNumber() == 1){ |
|
164 |
encodePolygon((Polygon) pols.getPrimitiveAt(0), stream); |
|
165 |
} else { |
|
166 |
encodeMultiPolygon(pols, stream); |
|
167 |
} |
|
168 |
} catch (GeometryException ex) { |
|
169 |
throw new WKBEncodingException(ex); |
|
175 | 170 |
} |
171 |
|
|
172 |
} else if (geometry.getGeometryType().isTypeOf(TYPES.AGGREGATE)) { |
|
173 |
switch (geometry.getType()) { |
|
174 |
case TYPES.MULTIPOINT: |
|
175 |
encodeMultiPoint(geometry, stream); |
|
176 |
break; |
|
177 |
case TYPES.MULTICURVE: |
|
178 |
try { |
|
179 |
encodeMultiLineString(geometry.toLines(), stream); |
|
180 |
} catch (GeometryException ex) { |
|
181 |
throw new WKBEncodingException(ex); |
|
182 |
} |
|
183 |
break; |
|
184 |
case TYPES.MULTILINE: |
|
185 |
encodeMultiLineString((MultiLine) geometry, stream); |
|
186 |
break; |
|
187 |
|
|
188 |
case TYPES.MULTISURFACE: |
|
189 |
try { |
|
190 |
encodeMultiPolygon(geometry.toPolygons(), stream); |
|
191 |
} catch (GeometryException ex) { |
|
192 |
throw new WKBEncodingException(ex); |
|
193 |
} |
|
194 |
break; |
|
195 |
case TYPES.MULTIPOLYGON: |
|
196 |
encodeMultiPolygon((MultiPolygon) geometry, stream); |
|
197 |
break; |
|
198 |
|
|
199 |
case TYPES.AGGREGATE: |
|
200 |
encodeCollection(geometry, stream); |
|
201 |
break; |
|
202 |
} |
|
203 |
|
|
204 |
} else { |
|
205 |
throw new GeometryTypeNotSupportedException(geometry.getType(), |
|
206 |
geometry.getGeometryType().getSubType()); |
|
207 |
} |
|
176 | 208 |
// |
177 | 209 |
// // FIXME geom.subtype != SUBTYPES.GEOM2D NOT SUPPORTED !!!! |
178 | 210 |
// if (geometry.getGeometryType().getSubType() != SUBTYPES.GEOM2D) { |
179 | 211 |
// throw new GeometryTypeNotSupportedException(geometry.getType(), |
180 | 212 |
// geometry.getGeometryType().getSubType()); |
181 | 213 |
// } |
182 |
}
|
|
214 |
}
|
|
183 | 215 |
|
216 |
private void encodeCollection(Geometry geometry, DataOutputStream stream) |
|
217 |
throws GeometryTypeNotSupportedException, |
|
218 |
WKBEncodingException, |
|
219 |
IOException { |
|
220 |
GeometryType geometryType = geometry.getGeometryType(); |
|
221 |
encodeWKBGeomHead(wkbGeometryType.wkbGeometryCollection, geometryType, |
|
222 |
stream); |
|
184 | 223 |
|
185 |
private void encodeCollection(Geometry geometry, DataOutputStream stream) |
|
186 |
throws GeometryTypeNotSupportedException, |
|
187 |
WKBEncodingException, |
|
188 |
IOException { |
|
189 |
GeometryType geometryType = geometry.getGeometryType(); |
|
190 |
encodeWKBGeomHead(wkbGeometryType.wkbGeometryCollection, geometryType, |
|
191 |
stream); |
|
224 |
Aggregate collection = (Aggregate) geometry; |
|
192 | 225 |
|
193 |
Aggregate collection = (Aggregate) geometry; |
|
226 |
int nGeometries = collection.getPrimitivesNumber(); |
|
227 |
encodeInteger(nGeometries, stream); |
|
228 |
for (int i = 0; i < nGeometries; i++) { |
|
229 |
encode(collection.getPrimitiveAt(i), stream); |
|
230 |
} |
|
231 |
} |
|
194 | 232 |
|
195 |
int nGeometries = collection.getPrimitivesNumber(); |
|
196 |
encodeInteger(nGeometries, stream); |
|
197 |
for (int i = 0; i < nGeometries; i++) { |
|
198 |
encode(collection.getPrimitiveAt(i), stream); |
|
199 |
} |
|
200 |
} |
|
233 |
private void encodeMultiPolygon(MultiPolygon geometry, DataOutputStream stream) |
|
234 |
throws GeometryTypeNotSupportedException, |
|
235 |
WKBPolygonNotClosedException, IOException { |
|
236 |
GeometryType geometryType = geometry.getGeometryType(); |
|
237 |
encodeWKBGeomHead(wkbGeometryType.wkbMultiPolygon, geometryType, stream); |
|
201 | 238 |
|
202 |
private void encodeMultiPolygon(Geometry geometry, DataOutputStream stream) |
|
203 |
throws GeometryTypeNotSupportedException, |
|
204 |
WKBPolygonNotClosedException, IOException { |
|
205 |
GeometryType geometryType = geometry.getGeometryType(); |
|
206 |
encodeWKBGeomHead(wkbGeometryType.wkbMultiPolygon, geometryType, stream); |
|
239 |
int nGeometries = geometry.getPrimitivesNumber(); |
|
240 |
encodeInteger(nGeometries, stream); |
|
241 |
for (int i = 0; i < nGeometries; i++) { |
|
242 |
encodePolygon((Polygon) geometry.getPrimitiveAt(i), stream); |
|
243 |
} |
|
244 |
} |
|
207 | 245 |
|
208 |
MultiSurface surfaces = (MultiSurface) geometry; |
|
246 |
private void encodePolygon(Polygon geometry, DataOutputStream stream) |
|
247 |
throws GeometryTypeNotSupportedException, |
|
248 |
WKBPolygonNotClosedException, IOException { |
|
249 |
GeometryType geometryType = geometry.getGeometryType(); |
|
250 |
encodeWKBGeomHead(wkbGeometryType.wkbPolygon, geometryType, stream); |
|
209 | 251 |
|
210 |
int nGeometries = surfaces.getPrimitivesNumber(); |
|
211 |
encodeInteger(nGeometries, stream); |
|
212 |
for (int i = 0; i < nGeometries; i++) { |
|
213 |
encodePolygon(surfaces.getPrimitiveAt(i), stream); |
|
214 |
} |
|
215 |
} |
|
252 |
encodeInteger(1 + geometry.getNumInteriorRings(), stream); |
|
253 |
encodeLinearRing(geometry, stream); |
|
254 |
for (int i = 0; i < geometry.getNumInteriorRings(); i++) { |
|
255 |
Ring ring = geometry.getInteriorRing(i); |
|
256 |
encodeLinearRing(ring, stream); |
|
216 | 257 |
|
217 |
private void checkLinearRingIsClosed(Geometry geom, List linearRing) |
|
218 |
throws WKBPolygonNotClosedException { |
|
219 |
double[] first = (double[]) linearRing.get(0); |
|
220 |
double[] last = (double[]) linearRing.get(linearRing.size() - 1); |
|
258 |
} |
|
259 |
} |
|
221 | 260 |
|
222 |
for (int i = 0; i < first.length; i++) { |
|
223 |
if (Math.abs(first[i] - last[i]) > 0.000001) { |
|
224 |
throw new WKBPolygonNotClosedException(geom); |
|
225 |
} |
|
226 |
} |
|
261 |
private void encodeLinearRing(Ring geom, DataOutputStream stream) |
|
262 |
throws IOException { |
|
263 |
encodeInteger(geom.getNumVertices(), stream); |
|
264 |
for (Point point : geom) { |
|
265 |
encodeCoordinates(point.getCoordinates(), stream); |
|
266 |
} |
|
267 |
} |
|
227 | 268 |
|
228 |
} |
|
269 |
private void encodeMultiLineString(MultiLine geometry, DataOutputStream stream) |
|
270 |
throws GeometryTypeNotSupportedException, |
|
271 |
WKBPolygonNotClosedException, IOException { |
|
272 |
GeometryType geometryType = geometry.getGeometryType(); |
|
273 |
encodeWKBGeomHead(wkbGeometryType.wkbMultiLineString, geometryType, stream); |
|
229 | 274 |
|
230 |
private List getLinearRings(Surface surface) |
|
231 |
throws WKBPolygonNotClosedException { |
|
232 |
PathIterator theIterator = surface.getPathIterator(null); |
|
233 |
List linearRings = new ArrayList(); |
|
234 |
List curlinearRing = new ArrayList(); |
|
235 |
int theType; |
|
236 |
double[] theData = new double[6]; |
|
275 |
int nGeometries = geometry.getPrimitivesNumber(); |
|
276 |
encodeInteger(nGeometries, stream); |
|
277 |
for (int i = 0; i < nGeometries; i++) { |
|
278 |
encodeLineString((Line) geometry.getPrimitiveAt(i), stream); |
|
279 |
} |
|
280 |
} |
|
237 | 281 |
|
238 |
while (!theIterator.isDone()) { |
|
239 |
// while not done |
|
240 |
theType = theIterator.currentSegment(theData); |
|
282 |
private void encodeLineString(Line geometry, DataOutputStream stream) |
|
283 |
throws GeometryTypeNotSupportedException, |
|
284 |
WKBPolygonNotClosedException, IOException { |
|
285 |
GeometryType geometryType = geometry.getGeometryType(); |
|
286 |
encodeWKBGeomHead(wkbGeometryType.wkbLineString, geometryType, stream); |
|
287 |
|
|
288 |
int nVertices = geometry.getNumVertices(); |
|
289 |
encodeInteger(nVertices, stream); |
|
290 |
|
|
291 |
for (Point point : geometry) { |
|
292 |
encodeCoordinates(point.getCoordinates(), stream); |
|
293 |
} |
|
294 |
} |
|
241 | 295 |
|
242 |
// Populate a segment of the new |
|
243 |
// GeneralPathX object. |
|
244 |
// Process the current segment to populate a new |
|
245 |
// segment of the new GeneralPathX object. |
|
246 |
switch (theType) { |
|
247 |
case PathIterator.SEG_MOVETO: |
|
248 |
if (curlinearRing.size() != 0) { |
|
249 |
if (curlinearRing.size() < 4) { |
|
250 |
// FIXME exception |
|
251 |
throw new WKBPolygonNotClosedException(surface); |
|
252 |
} |
|
253 |
checkLinearRingIsClosed(surface, curlinearRing); |
|
254 |
linearRings.add(curlinearRing); |
|
255 |
curlinearRing = new ArrayList(); |
|
256 | 296 |
|
257 |
} |
|
258 |
curlinearRing.add(new double[] { theData[0], theData[1] }); |
|
259 |
break; |
|
297 |
private void encodeDouble(double data, DataOutputStream stream) |
|
298 |
throws IOException { |
|
299 |
if (this.byteOrder == wkbByteOrder.wkbXDR) { |
|
300 |
stream.writeDouble(data); |
|
301 |
} else { |
|
302 |
EndianUtils.writeSwappedDouble(stream, data); |
|
303 |
} |
|
304 |
} |
|
260 | 305 |
|
261 |
case PathIterator.SEG_LINETO: |
|
262 |
curlinearRing.add(new double[] { theData[0], theData[1] }); |
|
263 |
break; |
|
264 |
|
|
265 |
case PathIterator.SEG_QUADTO: |
|
266 |
// TODO transform to linear segments |
|
267 |
throw new IllegalArgumentException("SEG_QUADTO unsupported"); |
|
268 |
|
|
269 |
// shape.quadTo(theData[0], theData[1], theData[2], theData[3]); |
|
270 |
|
|
271 |
// break; |
|
272 |
|
|
273 |
case PathIterator.SEG_CUBICTO: |
|
274 |
// TODO transform to linear segments |
|
275 |
throw new IllegalArgumentException("SEG_QUADTO unsupported"); |
|
276 |
// shape.curveTo(theData[0], theData[1], theData[2], theData[3], |
|
277 |
// theData[4], theData[5]); |
|
278 |
|
|
279 |
// break; |
|
280 |
|
|
281 |
case PathIterator.SEG_CLOSE: |
|
282 |
curlinearRing.add(curlinearRing.get(0)); |
|
283 |
linearRings.add(curlinearRing); |
|
284 |
curlinearRing = new ArrayList(); |
|
285 |
break; |
|
286 |
} // end switch |
|
287 |
|
|
288 |
theIterator.next(); |
|
289 |
} |
|
290 |
|
|
291 |
if (curlinearRing.size() != 0) { |
|
292 |
if (curlinearRing.size() < 4) { |
|
293 |
// FIXME exception |
|
294 |
throw new WKBPolygonNotClosedException(surface); |
|
295 |
} |
|
296 |
checkLinearRingIsClosed(surface, curlinearRing); |
|
297 |
linearRings.add(curlinearRing); |
|
298 |
} |
|
299 |
return linearRings; |
|
300 |
} |
|
301 |
|
|
302 |
private List getLines(Curve curve) throws WKBEncodingException { |
|
303 |
List lines = new ArrayList(); |
|
304 |
PathIterator theIterator = curve.getPathIterator(null); |
|
305 |
List curlinearRing = new ArrayList(); |
|
306 |
int theType; |
|
307 |
double[] theData = new double[6]; |
|
308 |
|
|
309 |
while (!theIterator.isDone()) { |
|
310 |
// while not done |
|
311 |
theType = theIterator.currentSegment(theData); |
|
312 |
|
|
313 |
// Populate a segment of the new |
|
314 |
// GeneralPathX object. |
|
315 |
// Process the current segment to populate a new |
|
316 |
// segment of the new GeneralPathX object. |
|
317 |
switch (theType) { |
|
318 |
case PathIterator.SEG_MOVETO: |
|
319 |
if (curlinearRing.size() != 0) { |
|
320 |
if (curlinearRing.size() < 2) { |
|
321 |
throw new WKBOnePointLineException(curve); |
|
322 |
} |
|
323 |
lines.add(curlinearRing); |
|
324 |
curlinearRing = new ArrayList(); |
|
325 |
} |
|
326 |
curlinearRing.add(new double[] { theData[0], theData[1] }); |
|
327 |
|
Also available in: Unified diff