root / branches / v2_0_0_prep / libraries / libFMap_geometries / src-test / org / gvsig / fmap / geom / impl / DefaultGeometryManagerTest.java @ 38770
History | View | Annotate | Download (11.1 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
|
23 |
/*
|
24 |
* AUTHORS (In addition to CIT):
|
25 |
* 2009 {} {{Task}}
|
26 |
*/
|
27 |
package org.gvsig.fmap.geom.impl; |
28 |
|
29 |
import java.awt.Rectangle; |
30 |
import java.awt.Shape; |
31 |
import java.awt.geom.AffineTransform; |
32 |
import java.awt.geom.PathIterator; |
33 |
import java.awt.geom.Point2D; |
34 |
import java.awt.geom.Rectangle2D; |
35 |
|
36 |
import junit.framework.TestCase; |
37 |
|
38 |
import org.cresques.cts.ICoordTrans; |
39 |
|
40 |
import org.gvsig.fmap.geom.Geometry; |
41 |
import org.gvsig.fmap.geom.handler.Handler; |
42 |
import org.gvsig.fmap.geom.operation.GeometryOperationContext; |
43 |
import org.gvsig.fmap.geom.operation.GeometryOperationException; |
44 |
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException; |
45 |
import org.gvsig.fmap.geom.primitive.Envelope; |
46 |
import org.gvsig.fmap.geom.primitive.GeneralPathX; |
47 |
import org.gvsig.fmap.geom.primitive.Point; |
48 |
import org.gvsig.fmap.geom.type.GeometryType; |
49 |
|
50 |
/**
|
51 |
* Unit tests for the class {@link DefaultGeometryManager}.
|
52 |
*
|
53 |
* @author 2009- <a href="cordinyana@gvsig.org">C?sar Ordi?ana</a> - gvSIG team
|
54 |
*/
|
55 |
public class DefaultGeometryManagerTest extends TestCase { |
56 |
|
57 |
private DefaultGeometryManager manager;
|
58 |
|
59 |
protected void setUp() throws Exception { |
60 |
super.setUp();
|
61 |
} |
62 |
|
63 |
/**
|
64 |
* Test method for
|
65 |
* {@link org.gvsig.fmap.geom.impl.DefaultGeometryManager#registerGeometryType(int, int)}
|
66 |
* and
|
67 |
* {@link org.gvsig.fmap.geom.impl.DefaultGeometryManager#getGeometryType(int, int)
|
68 |
* .
|
69 |
*/
|
70 |
public void testRegisterGetGeometryType() throws Exception { |
71 |
manager = new DefaultGeometryManager(1, 1); |
72 |
manager.registerGeometryType(TestGeometry.class, |
73 |
Geometry.TYPES.GEOMETRY, Geometry.SUBTYPES.GEOM2D); |
74 |
manager.registerGeometryType(TestGeometry.class, |
75 |
Geometry.TYPES.GEOMETRY, Geometry.SUBTYPES.GEOM3D); |
76 |
manager.registerGeometryType(TestGeometry.class, |
77 |
Geometry.TYPES.MULTISOLID, Geometry.SUBTYPES.GEOM2D); |
78 |
manager.registerGeometryType(TestGeometry.class, Geometry.TYPES.ARC, |
79 |
Geometry.SUBTYPES.GEOM3DM); |
80 |
|
81 |
assertNotNull(manager.getGeometryType(Geometry.TYPES.GEOMETRY, |
82 |
Geometry.SUBTYPES.GEOM2D)); |
83 |
|
84 |
assertNotNull(manager.getGeometryType(Geometry.TYPES.GEOMETRY, |
85 |
Geometry.SUBTYPES.GEOM3D)); |
86 |
|
87 |
assertNotNull(manager.getGeometryType(Geometry.TYPES.MULTISOLID, |
88 |
Geometry.SUBTYPES.GEOM2D)); |
89 |
|
90 |
assertNotNull(manager.getGeometryType(Geometry.TYPES.ARC, |
91 |
Geometry.SUBTYPES.GEOM3DM)); |
92 |
} |
93 |
|
94 |
/**
|
95 |
* Test method for
|
96 |
* {@link org.gvsig.fmap.geom.impl.DefaultGeometryManager#create(int, int)}.
|
97 |
*/
|
98 |
public void testCreateIntInt() throws Exception { |
99 |
manager = new DefaultGeometryManager();
|
100 |
manager.registerGeometryType(TestGeometry.class, |
101 |
Geometry.TYPES.GEOMETRY, Geometry.SUBTYPES.GEOM2D); |
102 |
manager.registerGeometryType(TestGeometry.class, |
103 |
Geometry.TYPES.GEOMETRY, Geometry.SUBTYPES.GEOM3D); |
104 |
manager.registerGeometryType(TestGeometry.class, |
105 |
Geometry.TYPES.MULTISOLID, Geometry.SUBTYPES.GEOM2D); |
106 |
manager.registerGeometryType(TestGeometry.class, Geometry.TYPES.ARC, |
107 |
Geometry.SUBTYPES.GEOM3DM); |
108 |
|
109 |
assertGeometry(manager.create(Geometry.TYPES.GEOMETRY, |
110 |
Geometry.SUBTYPES.GEOM2D)); |
111 |
|
112 |
assertGeometry(manager.create(Geometry.TYPES.GEOMETRY, |
113 |
Geometry.SUBTYPES.GEOM3D)); |
114 |
|
115 |
assertGeometry(manager.create(Geometry.TYPES.MULTISOLID, |
116 |
Geometry.SUBTYPES.GEOM2D)); |
117 |
|
118 |
assertGeometry(manager.create(Geometry.TYPES.ARC, |
119 |
Geometry.SUBTYPES.GEOM3DM)); |
120 |
} |
121 |
|
122 |
private void assertGeometry(Geometry geom) { |
123 |
assertNotNull(geom); |
124 |
assertEquals(TestGeometry.class, geom.getClass()); |
125 |
} |
126 |
|
127 |
public static class TestGeometry implements Geometry { |
128 |
|
129 |
private final GeometryType geometryType; |
130 |
|
131 |
public TestGeometry(GeometryType geometryType) {
|
132 |
this.geometryType = geometryType;
|
133 |
} |
134 |
|
135 |
public Geometry cloneGeometry() {
|
136 |
// TODO Auto-generated method stub
|
137 |
return null; |
138 |
} |
139 |
|
140 |
public boolean fastIntersects(double x, double y, double w, double h) { |
141 |
// TODO Auto-generated method stub
|
142 |
return false; |
143 |
} |
144 |
|
145 |
public Rectangle2D getBounds2D() { |
146 |
// TODO Auto-generated method stub
|
147 |
return null; |
148 |
} |
149 |
|
150 |
public int getDimension() { |
151 |
// TODO Auto-generated method stub
|
152 |
return 0; |
153 |
} |
154 |
|
155 |
public Envelope getEnvelope() {
|
156 |
// TODO Auto-generated method stub
|
157 |
return null; |
158 |
} |
159 |
|
160 |
public GeneralPathX getGeneralPath() {
|
161 |
// TODO Auto-generated method stub
|
162 |
return null; |
163 |
} |
164 |
|
165 |
public GeometryType getGeometryType() {
|
166 |
return geometryType;
|
167 |
} |
168 |
|
169 |
public Handler[] getHandlers(int type) { |
170 |
// TODO Auto-generated method stub
|
171 |
return null; |
172 |
} |
173 |
|
174 |
public Shape getInternalShape() { |
175 |
// TODO Auto-generated method stub
|
176 |
return null; |
177 |
} |
178 |
|
179 |
public PathIterator getPathIterator(AffineTransform at) { |
180 |
// TODO Auto-generated method stub
|
181 |
return null; |
182 |
} |
183 |
|
184 |
public PathIterator getPathIterator(AffineTransform at, double flatness) { |
185 |
// TODO Auto-generated method stub
|
186 |
return null; |
187 |
} |
188 |
|
189 |
public int getType() { |
190 |
return 0; |
191 |
} |
192 |
|
193 |
public boolean intersects(Rectangle2D r) { |
194 |
// TODO Auto-generated method stub
|
195 |
return false; |
196 |
} |
197 |
|
198 |
public Object invokeOperation(int index, GeometryOperationContext ctx) |
199 |
throws GeometryOperationNotSupportedException,
|
200 |
GeometryOperationException { |
201 |
// TODO Auto-generated method stub
|
202 |
return null; |
203 |
} |
204 |
|
205 |
public Object invokeOperation(String opName, |
206 |
GeometryOperationContext ctx) |
207 |
throws GeometryOperationNotSupportedException,
|
208 |
GeometryOperationException { |
209 |
// TODO Auto-generated method stub
|
210 |
return null; |
211 |
} |
212 |
|
213 |
public boolean isSimple() { |
214 |
// TODO Auto-generated method stub
|
215 |
return false; |
216 |
} |
217 |
|
218 |
public void reProject(ICoordTrans ct) { |
219 |
// TODO Auto-generated method stub
|
220 |
|
221 |
} |
222 |
|
223 |
public void transform(AffineTransform at) { |
224 |
// TODO Auto-generated method stub
|
225 |
|
226 |
} |
227 |
|
228 |
public boolean contains(Point2D p) { |
229 |
// TODO Auto-generated method stub
|
230 |
return false; |
231 |
} |
232 |
|
233 |
public boolean contains(Rectangle2D r) { |
234 |
// TODO Auto-generated method stub
|
235 |
return false; |
236 |
} |
237 |
|
238 |
public boolean contains(double x, double y) { |
239 |
// TODO Auto-generated method stub
|
240 |
return false; |
241 |
} |
242 |
|
243 |
public boolean contains(double x, double y, double w, double h) { |
244 |
// TODO Auto-generated method stub
|
245 |
return false; |
246 |
} |
247 |
|
248 |
public Rectangle getBounds() { |
249 |
// TODO Auto-generated method stub
|
250 |
return null; |
251 |
} |
252 |
|
253 |
public boolean intersects(double x, double y, double w, double h) { |
254 |
// TODO Auto-generated method stub
|
255 |
return false; |
256 |
} |
257 |
|
258 |
public int compareTo(Object arg0) { |
259 |
// TODO Auto-generated method stub
|
260 |
return 0; |
261 |
} |
262 |
|
263 |
public Geometry buffer(double distance) |
264 |
throws GeometryOperationNotSupportedException,
|
265 |
GeometryOperationException { |
266 |
// TODO Auto-generated method stub
|
267 |
return null; |
268 |
} |
269 |
|
270 |
public boolean contains(Geometry geometry) |
271 |
throws GeometryOperationNotSupportedException,
|
272 |
GeometryOperationException { |
273 |
// TODO Auto-generated method stub
|
274 |
return false; |
275 |
} |
276 |
|
277 |
public byte[] convertToWKB() |
278 |
throws GeometryOperationNotSupportedException,
|
279 |
GeometryOperationException { |
280 |
// TODO Auto-generated method stub
|
281 |
return null; |
282 |
} |
283 |
|
284 |
public String convertToWKT() |
285 |
throws GeometryOperationNotSupportedException,
|
286 |
GeometryOperationException { |
287 |
// TODO Auto-generated method stub
|
288 |
return null; |
289 |
} |
290 |
|
291 |
public Geometry convexHull()
|
292 |
throws GeometryOperationNotSupportedException,
|
293 |
GeometryOperationException { |
294 |
// TODO Auto-generated method stub
|
295 |
return null; |
296 |
} |
297 |
|
298 |
public boolean coveredBy(Geometry geometry) |
299 |
throws GeometryOperationNotSupportedException,
|
300 |
GeometryOperationException { |
301 |
// TODO Auto-generated method stub
|
302 |
return false; |
303 |
} |
304 |
|
305 |
public boolean crosses(Geometry geometry) |
306 |
throws GeometryOperationNotSupportedException,
|
307 |
GeometryOperationException { |
308 |
// TODO Auto-generated method stub
|
309 |
return false; |
310 |
} |
311 |
|
312 |
public Geometry difference(Geometry other)
|
313 |
throws GeometryOperationNotSupportedException,
|
314 |
GeometryOperationException { |
315 |
// TODO Auto-generated method stub
|
316 |
return null; |
317 |
} |
318 |
|
319 |
public boolean disjoint(Geometry geometry) |
320 |
throws GeometryOperationNotSupportedException,
|
321 |
GeometryOperationException { |
322 |
// TODO Auto-generated method stub
|
323 |
return false; |
324 |
} |
325 |
|
326 |
public double distance(Geometry geometry) |
327 |
throws GeometryOperationNotSupportedException,
|
328 |
GeometryOperationException { |
329 |
// TODO Auto-generated method stub
|
330 |
return 0; |
331 |
} |
332 |
|
333 |
public Geometry intersection(Geometry other)
|
334 |
throws GeometryOperationNotSupportedException,
|
335 |
GeometryOperationException { |
336 |
// TODO Auto-generated method stub
|
337 |
return null; |
338 |
} |
339 |
|
340 |
public boolean intersects(Geometry geometry) |
341 |
throws GeometryOperationNotSupportedException,
|
342 |
GeometryOperationException { |
343 |
// TODO Auto-generated method stub
|
344 |
return false; |
345 |
} |
346 |
|
347 |
public boolean overlaps(Geometry geometry) |
348 |
throws GeometryOperationNotSupportedException,
|
349 |
GeometryOperationException { |
350 |
// TODO Auto-generated method stub
|
351 |
return false; |
352 |
} |
353 |
|
354 |
public boolean touches(Geometry geometry) |
355 |
throws GeometryOperationNotSupportedException,
|
356 |
GeometryOperationException { |
357 |
// TODO Auto-generated method stub
|
358 |
return false; |
359 |
} |
360 |
|
361 |
public Geometry union(Geometry other)
|
362 |
throws GeometryOperationNotSupportedException,
|
363 |
GeometryOperationException { |
364 |
// TODO Auto-generated method stub
|
365 |
return null; |
366 |
} |
367 |
|
368 |
public boolean within(Geometry geometry) |
369 |
throws GeometryOperationNotSupportedException,
|
370 |
GeometryOperationException { |
371 |
// TODO Auto-generated method stub
|
372 |
return false; |
373 |
} |
374 |
|
375 |
public Point centroid() throws GeometryOperationNotSupportedException, |
376 |
GeometryOperationException { |
377 |
// TODO Auto-generated method stub
|
378 |
return null; |
379 |
} |
380 |
|
381 |
public double area() throws GeometryOperationNotSupportedException, |
382 |
GeometryOperationException { |
383 |
// TODO Auto-generated method stub
|
384 |
return 0; |
385 |
} |
386 |
|
387 |
public double perimeter() |
388 |
throws GeometryOperationNotSupportedException,
|
389 |
GeometryOperationException { |
390 |
// TODO Auto-generated method stub
|
391 |
return 0; |
392 |
} |
393 |
|
394 |
public Shape getShape() { |
395 |
// TODO Auto-generated method stub
|
396 |
return null; |
397 |
} |
398 |
|
399 |
public Shape getShape(AffineTransform affineTransform) { |
400 |
// TODO Auto-generated method stub
|
401 |
return null; |
402 |
} |
403 |
|
404 |
/* (non-Javadoc)
|
405 |
* @see org.gvsig.fmap.geom.Geometry#getInteriorPoint()
|
406 |
*/
|
407 |
public Point getInteriorPoint() |
408 |
throws GeometryOperationNotSupportedException,
|
409 |
GeometryOperationException { |
410 |
// TODO Auto-generated method stub
|
411 |
return null; |
412 |
} |
413 |
|
414 |
} |
415 |
} |