svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.geometry / org.gvsig.fmap.geometry.api / src / main / java / org / gvsig / fmap / geom / GeometryManager.java @ 40435
History | View | Annotate | Download (45.6 KB)
1 | 40435 | jjdelcerro | /* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana
|
---|---|---|---|
2 | *
|
||
3 | * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
||
4 | *
|
||
5 | * This program is free software; you can redistribute it and/or
|
||
6 | * modify it under the terms of the GNU General Public License
|
||
7 | * as published by the Free Software Foundation; either version 2
|
||
8 | * of the License, or (at your option) any later version.
|
||
9 | *
|
||
10 | * This program is distributed in the hope that it will be useful,
|
||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
13 | * GNU General Public License for more details.
|
||
14 | *
|
||
15 | * You should have received a copy of the GNU General Public License
|
||
16 | * along with this program; if not, write to the Free Software
|
||
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
18 | *
|
||
19 | * For more information, contact:
|
||
20 | *
|
||
21 | * Generalitat Valenciana
|
||
22 | * Conselleria d'Infraestructures i Transport
|
||
23 | * Av. Blasco Ib��ez, 50
|
||
24 | * 46010 VALENCIA
|
||
25 | * SPAIN
|
||
26 | *
|
||
27 | * +34 963862235
|
||
28 | * gvsig@gva.es
|
||
29 | * www.gvsig.gva.es
|
||
30 | *
|
||
31 | * or
|
||
32 | *
|
||
33 | * IVER T.I. S.A
|
||
34 | * Salamanca 50
|
||
35 | * 46005 Valencia
|
||
36 | * Spain
|
||
37 | *
|
||
38 | * +34 963163400
|
||
39 | * dac@iver.es
|
||
40 | */
|
||
41 | package org.gvsig.fmap.geom; |
||
42 | |||
43 | import java.awt.geom.PathIterator; |
||
44 | import java.util.List; |
||
45 | |||
46 | import org.gvsig.fmap.geom.aggregate.MultiCurve; |
||
47 | import org.gvsig.fmap.geom.aggregate.MultiPrimitive; |
||
48 | import org.gvsig.fmap.geom.aggregate.MultiSurface; |
||
49 | import org.gvsig.fmap.geom.exception.CreateEnvelopeException; |
||
50 | import org.gvsig.fmap.geom.exception.CreateGeometryException; |
||
51 | import org.gvsig.fmap.geom.operation.GeometryOperation; |
||
52 | import org.gvsig.fmap.geom.operation.GeometryOperationContext; |
||
53 | import org.gvsig.fmap.geom.operation.GeometryOperationException; |
||
54 | import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException; |
||
55 | import org.gvsig.fmap.geom.primitive.Curve; |
||
56 | import org.gvsig.fmap.geom.primitive.Envelope; |
||
57 | import org.gvsig.fmap.geom.primitive.GeneralPathX; |
||
58 | import org.gvsig.fmap.geom.primitive.NullGeometry; |
||
59 | import org.gvsig.fmap.geom.primitive.OrientablePrimitive; |
||
60 | import org.gvsig.fmap.geom.primitive.Point; |
||
61 | import org.gvsig.fmap.geom.primitive.Surface; |
||
62 | import org.gvsig.fmap.geom.type.GeometryType; |
||
63 | import org.gvsig.fmap.geom.type.GeometryTypeNotSupportedException; |
||
64 | import org.gvsig.fmap.geom.type.GeometryTypeNotValidException; |
||
65 | |||
66 | /**
|
||
67 | * This singleton provides a centralized access to gvSIG's Geometry Model.
|
||
68 | * Its responsibilities are:<br>
|
||
69 | *
|
||
70 | * <ul>
|
||
71 | * <li>Offering a set of convenient methods for registering and retrieving
|
||
72 | * geometry types.
|
||
73 | * <li>Offering a set of convenient methods for registering and retrieving
|
||
74 | * geometry operations associated to one or more geometry types.
|
||
75 | * <li>Offering a set of convenient methods for registering and retrieving new
|
||
76 | * geometries.
|
||
77 | * </ul>
|
||
78 | *
|
||
79 | * @author jiyarza
|
||
80 | * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
|
||
81 | */
|
||
82 | public interface GeometryManager { |
||
83 | |||
84 | public interface OPERATIONS { |
||
85 | |||
86 | public final static String FROMWKT = "FromWKT"; |
||
87 | public final static String FROMWKB = "FromWKB"; |
||
88 | } |
||
89 | |||
90 | /**
|
||
91 | * <p>
|
||
92 | * Registers a GeometryOperation associated to a GeometryType. Returns an
|
||
93 | * unique index that is used later to identify and invoke the operation.
|
||
94 | * </p>
|
||
95 | * <p>
|
||
96 | * By convention this index should be in a final and static variable in the
|
||
97 | * class that implements the operation. The value of this variable must be
|
||
98 | * set using the method
|
||
99 | * {@link GeometryManager#getGeometryOperationCode(String)}:<BR>
|
||
100 | *
|
||
101 | * <pre>
|
||
102 | *
|
||
103 | * public class MyOperation extends GeometryOperation {
|
||
104 | *
|
||
105 | * public static final int CODE = GeometryLocator.getGeometryManager()
|
||
106 | * .getGeometryOperationCode("MyOperation");
|
||
107 | * }
|
||
108 | * </pre>
|
||
109 | *
|
||
110 | * </p>
|
||
111 | *
|
||
112 | * @param geomOpName
|
||
113 | * Operation's unique name
|
||
114 | * @param geomOp
|
||
115 | * Specific GeometryOperation's instance implementing this
|
||
116 | * operation
|
||
117 | * @param geomType
|
||
118 | * GeometryType instance to which this operation should be
|
||
119 | * associated
|
||
120 | * @return Index assigned to this operation. This index is used later to
|
||
121 | * access the operation.
|
||
122 | *
|
||
123 | */
|
||
124 | public int registerGeometryOperation(String geomOpName, |
||
125 | GeometryOperation geomOp, GeometryType geomType); |
||
126 | |||
127 | /**
|
||
128 | * <p>
|
||
129 | * Registers a GeometryOperation that is common for all GeometryType
|
||
130 | * (registered yet or not). Returns an unique index that is used later to
|
||
131 | * identify and invoke the operation.
|
||
132 | * </p>
|
||
133 | * <p>
|
||
134 | * By convention this index should be in a final and static variable in the
|
||
135 | * class that implements the operation. The value of this variable must be
|
||
136 | * set using the method
|
||
137 | * {@link GeometryManager#getGeometryOperationCode(String)}:<BR>
|
||
138 | *
|
||
139 | * <pre>
|
||
140 | *
|
||
141 | * public class MyOperation extends GeometryOperation {
|
||
142 | *
|
||
143 | * public static final int CODE = GeometryLocator.getGeometryManager()
|
||
144 | * .getGeometryOperationCode("MyOperation");
|
||
145 | * }
|
||
146 | * </pre>
|
||
147 | *
|
||
148 | * </p>
|
||
149 | *
|
||
150 | * @param geomOpName
|
||
151 | * Operation's unique name
|
||
152 | * @param geomOp
|
||
153 | * Specific GeometryOperation's instance implementing this
|
||
154 | * operation
|
||
155 | * @return Index assigned to this operation. This index is used later to
|
||
156 | * access the operation.
|
||
157 | */
|
||
158 | public int registerGeometryOperation(String geomOpName, |
||
159 | GeometryOperation geomOp); |
||
160 | |||
161 | /**
|
||
162 | * <p>
|
||
163 | * Registers a GeometryOperation associated to a GeometryType, that has been
|
||
164 | * specified using the type code and the subtype code. Returns an unique
|
||
165 | * index that is used later to identify and invoke the operation.
|
||
166 | * </p>
|
||
167 | * <p>
|
||
168 | * By convention this index should be in a final and static variable in the
|
||
169 | * class that implements the operation. The value of this variable must be
|
||
170 | * set using the method
|
||
171 | * {@link GeometryManager#getGeometryOperationCode(String)}:<BR>
|
||
172 | *
|
||
173 | * <pre>
|
||
174 | *
|
||
175 | * public class MyOperation extends GeometryOperation {
|
||
176 | *
|
||
177 | * public static final int CODE = GeometryLocator.getGeometryManager()
|
||
178 | * .getGeometryOperationCode("MyOperation");
|
||
179 | * }
|
||
180 | * </pre>
|
||
181 | *
|
||
182 | * </p>
|
||
183 | * <p>
|
||
184 | * This method is only used if you have not a reference to the GeometryType
|
||
185 | * associated to the geometry class. If you have such reference then it is
|
||
186 | * slightly faster to use the method that receives the GeometryType.<br>
|
||
187 | * </p>
|
||
188 | *
|
||
189 | * @param geomOpName
|
||
190 | * Operation's unique name
|
||
191 | * @param geomOp
|
||
192 | * Specific GeometryOperation's instance implementing this
|
||
193 | * operation
|
||
194 | * @param type
|
||
195 | * Type of geometry. Must be a value defined in
|
||
196 | * {@link Geometry.TYPES}
|
||
197 | * @param subType
|
||
198 | * SubType of geometry. Must be a value defined in
|
||
199 | * {@link Geometry.SUBTYPES}
|
||
200 | * @return Index assigned to this operation. This index is used later to
|
||
201 | * access the operation.
|
||
202 | * @throws GeometryTypeNotSupportedException
|
||
203 | * Returns this exception if there is not a registered geometry
|
||
204 | * with
|
||
205 | * these type and subtype
|
||
206 | * @throws GeometryTypeNotValidException
|
||
207 | * Returns if the type and subtype are not valid
|
||
208 | */
|
||
209 | public int registerGeometryOperation(String geomOpName, |
||
210 | GeometryOperation geomOp, int type, int subType) |
||
211 | throws GeometryTypeNotSupportedException, GeometryTypeNotValidException;
|
||
212 | |||
213 | /**
|
||
214 | * <p>
|
||
215 | * Registers a GeometryOperation associated to all the geometries with a
|
||
216 | * concrete type. Returns an unique index that is used later to identify and
|
||
217 | * invoke the operation.<br>
|
||
218 | * </p>
|
||
219 | * <p>
|
||
220 | * By convention this index should be in a final and static variable in the
|
||
221 | * class that implements the operation. The value of this variable must be
|
||
222 | * set using the method
|
||
223 | * {@link GeometryManager#getGeometryOperationCode(String)}:<BR>
|
||
224 | *
|
||
225 | * <pre>
|
||
226 | *
|
||
227 | * public class MyOperation extends GeometryOperation {
|
||
228 | *
|
||
229 | * public static final int CODE = GeometryLocator.getGeometryManager()
|
||
230 | * .getGeometryOperationCode("MyOperation");
|
||
231 | * }
|
||
232 | * </pre>
|
||
233 | *
|
||
234 | * </p>
|
||
235 | *
|
||
236 | * @param geomOpName
|
||
237 | * Operation's unique name
|
||
238 | * @param geomOp
|
||
239 | * Specific GeometryOperation's instance implementing this
|
||
240 | * operation
|
||
241 | * @param type
|
||
242 | * Type of geometry. Must be a value defined in
|
||
243 | * {@link Geometry.TYPES}
|
||
244 | * @return Index assigned to this operation. This index is used later to
|
||
245 | * access the operation.
|
||
246 | */
|
||
247 | public int registerGeometryOperation(String geomOpName, |
||
248 | GeometryOperation geomOp, int type);
|
||
249 | |||
250 | /**
|
||
251 | * <p>
|
||
252 | * Registers a GeometryOperation associated to all the geometries which
|
||
253 | * super type matches with a concrete type. Returns an unique index that
|
||
254 | * is used later to identify and invoke the operation.<br>
|
||
255 | * </p>
|
||
256 | * <p>
|
||
257 | * By convention this index should be in a final and static variable in the
|
||
258 | * class that implements the operation. The value of this variable must be
|
||
259 | * set using the method
|
||
260 | * {@link GeometryManager#getGeometryOperationCode(String)}:<BR>
|
||
261 | *
|
||
262 | * <pre>
|
||
263 | *
|
||
264 | * public class MyOperation extends GeometryOperation {
|
||
265 | *
|
||
266 | * public static final int CODE = GeometryLocator.getGeometryManager()
|
||
267 | * .getGeometryOperationCode("MyOperation");
|
||
268 | * }
|
||
269 | * </pre>
|
||
270 | *
|
||
271 | * </p>
|
||
272 | *
|
||
273 | * @param geomOpName
|
||
274 | * Operation's unique name
|
||
275 | * @param geomOp
|
||
276 | * Specific GeometryOperation's instance implementing this
|
||
277 | * operation
|
||
278 | * @param superType
|
||
279 | * super type of geometries that is used to register
|
||
280 | * the operation. Must be a value defined in
|
||
281 | * {@link Geometry.TYPES}
|
||
282 | * @return Index assigned to this operation. This index is used later to
|
||
283 | * access the operation.
|
||
284 | */
|
||
285 | public int registerGeometryOperationBySuperType(String geomOpName, |
||
286 | GeometryOperation geomOp, int superType);
|
||
287 | |||
288 | /**
|
||
289 | * <p>
|
||
290 | * Registers a GeometryOperation associated to all the geometries which
|
||
291 | * super subType matches with a concrete subType. Returns an unique index that
|
||
292 | * is used later to identify and invoke the operation.<br>
|
||
293 | * </p>
|
||
294 | * <p>
|
||
295 | * By convention this index should be in a final and static variable in the
|
||
296 | * class that implements the operation. The value of this variable must be
|
||
297 | * set using the method
|
||
298 | * {@link GeometryManager#getGeometryOperationCode(String)}:<BR>
|
||
299 | *
|
||
300 | * <pre>
|
||
301 | *
|
||
302 | * public class MyOperation extends GeometryOperation {
|
||
303 | *
|
||
304 | * public static final int CODE = GeometryLocator.getGeometryManager()
|
||
305 | * .getGeometryOperationCode("MyOperation");
|
||
306 | * }
|
||
307 | * </pre>
|
||
308 | *
|
||
309 | * </p>
|
||
310 | *
|
||
311 | * @param geomOpName
|
||
312 | * Operation's unique name
|
||
313 | * @param geomOp
|
||
314 | * Specific GeometryOperation's instance implementing this
|
||
315 | * operation
|
||
316 | * @param superSubType
|
||
317 | * super subType of geometries that is used to register
|
||
318 | * the operation. Must be a value defined in
|
||
319 | * {@link Geometry.SUBTYPES}
|
||
320 | * @return Index assigned to this operation. This index is used later to
|
||
321 | * access the operation.
|
||
322 | */
|
||
323 | public int registerGeometryOperationBySuperSubType(String geomOpName, |
||
324 | GeometryOperation geomOp, int superSubType);
|
||
325 | |||
326 | /**
|
||
327 | * <p>
|
||
328 | * Registers a GeometryOperation associated to all the geometries with a
|
||
329 | * concrete subtype. Returns an unique index that is used later to identify
|
||
330 | * and invoke the operation.<br>
|
||
331 | * </p>
|
||
332 | * <p>
|
||
333 | * By convention this index should be in a final and static variable in the
|
||
334 | * class that implements the operation. The value of this variable must be
|
||
335 | * set using the method
|
||
336 | * {@link GeometryManager#getGeometryOperationCode(String)}:<BR>
|
||
337 | *
|
||
338 | * <pre>
|
||
339 | *
|
||
340 | * public class MyOperation extends GeometryOperation {
|
||
341 | *
|
||
342 | * public static final int CODE = GeometryLocator.getGeometryManager()
|
||
343 | * .getGeometryOperationCode("MyOperation");
|
||
344 | * }
|
||
345 | * </pre>
|
||
346 | *
|
||
347 | * </p>
|
||
348 | *
|
||
349 | * @param geomOpName
|
||
350 | * Operation's unique name
|
||
351 | * @param geomOp
|
||
352 | * Specific GeometryOperation's instance implementing this
|
||
353 | * operation
|
||
354 | * @param subType
|
||
355 | * SubType of geometry. Must be a value defined in
|
||
356 | * {@link Geometry.SUBTYPES}
|
||
357 | * @return Index assigned to this operation. This index is used later to
|
||
358 | * access the operation.
|
||
359 | */
|
||
360 | public int registerGeometryOperationBySubtype(String geomOpName, |
||
361 | GeometryOperation geomOp, int subType);
|
||
362 | |||
363 | /**
|
||
364 | * <p>
|
||
365 | * Registers a GeometryType instance.
|
||
366 | * </p>
|
||
367 | *
|
||
368 | * @param geometryType
|
||
369 | * A {@link GeometryType} instance to create {@link Geometry} objects
|
||
370 | */
|
||
371 | public void registerGeometryType(GeometryType geometryType); |
||
372 | |||
373 | /**
|
||
374 | * <p>
|
||
375 | * Registers a Geometry implementation class with a predefined geometry type
|
||
376 | * and returns the associated GeometryType instance. Available predefined
|
||
377 | * types are defined in {@link Geometry.TYPES} and the subtypes are defined
|
||
378 | * in {@link Geometry.SUBTYPES}.
|
||
379 | * </p>
|
||
380 | * <p>
|
||
381 | * How to register a geometry class with a predefined type:
|
||
382 | *
|
||
383 | * <pre>
|
||
384 | *
|
||
385 | * GeometryType geomType = GeometryLocator.getGeometryManager()
|
||
386 | * .registerBasicGeometryType(Point2D.class, "Point2D", Geometry.TYPES.POINT,
|
||
387 | * Geometry.SYBTYPES.GEOM2D);
|
||
388 | * </pre>
|
||
389 | *
|
||
390 | * </p>
|
||
391 | *
|
||
392 | * @param geomClass
|
||
393 | * Geometry subclass. It must not be null and must implement
|
||
394 | * Geometry, otherwise an exception
|
||
395 | * is raised.
|
||
396 | * @param name
|
||
397 | * Symbolic name for the geometry type, it can be null. If it is
|
||
398 | * null then the symbolic name
|
||
399 | * will be the simple class name.
|
||
400 | * @param type
|
||
401 | * Type of geometry. Must be a value defined in
|
||
402 | * {@link Geometry.TYPES}
|
||
403 | * @param subType
|
||
404 | * SubType of geometry. Must be a value defined in
|
||
405 | * {@link Geometry.SUBTYPES}
|
||
406 | * @return Instance of GeometryType associated to the Geometry
|
||
407 | * implementation class
|
||
408 | * geomClass
|
||
409 | * @throws IllegalArgumentException
|
||
410 | * If geomClass is null or does not implement Geometry
|
||
411 | */
|
||
412 | public GeometryType registerGeometryType(Class geomClass, String name, |
||
413 | int type, int subType); |
||
414 | |||
415 | /**
|
||
416 | * <p>
|
||
417 | * Registers a Geometry implementation class with a predefined geometry type
|
||
418 | * and returns the associated GeometryType instance. Available predefined
|
||
419 | * types are defined in {@link Geometry.TYPES} and the subtypes are defined
|
||
420 | * in {@link Geometry.SUBTYPES}.
|
||
421 | * </p>
|
||
422 | * <p>
|
||
423 | * It adds also the super type and the super subType of the geometry, that
|
||
424 | * can be used to check if the type (or the subtype) inherits of other
|
||
425 | * type (or subType)
|
||
426 | * </p>
|
||
427 | * <p>
|
||
428 | * How to register a geometry class with a predefined type:
|
||
429 | *
|
||
430 | * <pre>
|
||
431 | *
|
||
432 | * GeometryType geomType = GeometryLocator.getGeometryManager()
|
||
433 | * .registerBasicGeometryType(Arc3D.class, "Arc3D", Geometry.TYPES.ARC,
|
||
434 | * Geometry.SYBTYPES.GEOM3D, Geometry.TYPES.CURVE, Geometry.SYBTYPES.GEOM2D);
|
||
435 | * </pre>
|
||
436 | *
|
||
437 | * </p>
|
||
438 | *
|
||
439 | * @param geomClass
|
||
440 | * Geometry subclass. It must not be null and must implement
|
||
441 | * Geometry, otherwise an exception
|
||
442 | * is raised.
|
||
443 | * @param name
|
||
444 | * Symbolic name for the geometry type, it can be null. If it is
|
||
445 | * null then the symbolic name
|
||
446 | * will be the simple class name.
|
||
447 | * @param type
|
||
448 | * Type of geometry. Must be a value defined in
|
||
449 | * {@link Geometry.TYPES}
|
||
450 | * @param subType
|
||
451 | * SubType of geometry. Must be a value defined in
|
||
452 | * {@link Geometry.SUBTYPES}
|
||
453 | * @param superType
|
||
454 | * Super type of a geometry. Must be a value defined in
|
||
455 | * {@link Geometry.TYPES}
|
||
456 | * @param superSubType
|
||
457 | * Super subType of a geometry. Must be a value defined in
|
||
458 | * {@link Geometry.SUBTYPES}
|
||
459 | * @return Instance of GeometryType associated to the Geometry
|
||
460 | * implementation class
|
||
461 | * geomClass
|
||
462 | * @throws IllegalArgumentException
|
||
463 | * If geomClass is null or does not implement Geometry
|
||
464 | */
|
||
465 | public GeometryType registerGeometryType(Class geomClass, String name, |
||
466 | int type, int subType, int superType, int superSubType); |
||
467 | |||
468 | /**
|
||
469 | * <p>
|
||
470 | * Registers a Geometry implementation class with a predefined geometry type
|
||
471 | * and returns the associated GeometryType instance. Available predefined
|
||
472 | * types are defined in {@link Geometry.TYPES} and the subtypes are defined
|
||
473 | * in {@link Geometry.SUBTYPES}.
|
||
474 | * </p>
|
||
475 | * <p>
|
||
476 | * It adds also the super type of the geometry, that can be used to
|
||
477 | * check if the type inherits of other type.
|
||
478 | * </p>
|
||
479 | * <p>
|
||
480 | * How to register a geometry class with a predefined type:
|
||
481 | *
|
||
482 | * <pre>
|
||
483 | *
|
||
484 | * GeometryType geomType = GeometryLocator.getGeometryManager()
|
||
485 | * .registerBasicGeometryType(Arc3D.class, "Arc3D", Geometry.TYPES.ARC,
|
||
486 | * Geometry.SYBTYPES.GEOM3D, Geometry.TYPES.CURVE);
|
||
487 | * </pre>
|
||
488 | *
|
||
489 | * </p>
|
||
490 | *
|
||
491 | * @param geomClass
|
||
492 | * Geometry subclass. It must not be null and must implement
|
||
493 | * Geometry, otherwise an exception
|
||
494 | * is raised.
|
||
495 | * @param name
|
||
496 | * Symbolic name for the geometry type, it can be null. If it is
|
||
497 | * null then the symbolic name
|
||
498 | * will be the simple class name.
|
||
499 | * @param type
|
||
500 | * Type of geometry. Must be a value defined in
|
||
501 | * {@link Geometry.TYPES}
|
||
502 | * @param subType
|
||
503 | * SubType of geometry. Must be a value defined in
|
||
504 | * {@link Geometry.SUBTYPES}
|
||
505 | * @param superType
|
||
506 | * Super type of a geometry. Must be a value defined in
|
||
507 | * {@link Geometry.TYPES}
|
||
508 | * @return Instance of GeometryType associated to the Geometry
|
||
509 | * implementation class
|
||
510 | * geomClass
|
||
511 | * @throws IllegalArgumentException
|
||
512 | * If geomClass is null or does not implement Geometry
|
||
513 | */
|
||
514 | public GeometryType registerGeometryType(Class geomClass, String name, |
||
515 | int type, int subType, int superType); |
||
516 | |||
517 | /**
|
||
518 | * <p>
|
||
519 | * Registers a Geometry implementation class with a predefined geometry type
|
||
520 | * and returns the associated GeometryType instance. Available predefined
|
||
521 | * types are defined in {@link Geometry.TYPES} and the subtypes are defined
|
||
522 | * in {@link Geometry.SUBTYPES}.
|
||
523 | * </p>
|
||
524 | * <p>
|
||
525 | * It adds also the super types and the super subTypes of the geometry, that
|
||
526 | * can be used to check if the type (or the subtype) inherits of other
|
||
527 | * types (or subTypes)
|
||
528 | * </p>
|
||
529 | * <p>
|
||
530 | * How to register a geometry class with a predefined type:
|
||
531 | *
|
||
532 | * <pre>
|
||
533 | *
|
||
534 | * GeometryType geomType = GeometryLocator.getGeometryManager()
|
||
535 | * .registerBasicGeometryType(Circle3DM.class, "Circle3DM", Geometry.TYPES.CIRCLE,
|
||
536 | * Geometry.SYBTYPES.GEOM3DM,
|
||
537 | * new int[]{Geometry.TYPES.CURVE, Geometry.TYPES.GEOMETRY},
|
||
538 | * new int[]{Geometry.SYBTYPES.GEOM2D, Geometry.SYBTYPES.GEOM3D});
|
||
539 | * </pre>
|
||
540 | *
|
||
541 | * </p>
|
||
542 | *
|
||
543 | * @param geomClass
|
||
544 | * Geometry subclass. It must not be null and must implement
|
||
545 | * Geometry, otherwise an exception
|
||
546 | * is raised.
|
||
547 | * @param name
|
||
548 | * Symbolic name for the geometry type, it can be null. If it is
|
||
549 | * null then the symbolic name
|
||
550 | * will be the simple class name.
|
||
551 | * @param type
|
||
552 | * Type of geometry. Must be a value defined in
|
||
553 | * {@link Geometry.TYPES}
|
||
554 | * @param subType
|
||
555 | * SubType of geometry. Must be a value defined in
|
||
556 | * {@link Geometry.SUBTYPES}
|
||
557 | * @param superTypes
|
||
558 | * List of the super types of a geometry. Must be a value defined in
|
||
559 | * {@link Geometry.TYPES}
|
||
560 | * @param superSubTypes
|
||
561 | * List of the super subType of a geometry. Must be a value defined in
|
||
562 | * {@link Geometry.SUBTYPES}
|
||
563 | * @return Instance of GeometryType associated to the Geometry
|
||
564 | * implementation class
|
||
565 | * geomClass
|
||
566 | * @throws IllegalArgumentException
|
||
567 | * If geomClass is null or does not implement Geometry
|
||
568 | */
|
||
569 | public GeometryType registerGeometryType(Class geomClass, String name, |
||
570 | int type, int subType, int[] superTypes, int superSubTypes[]); |
||
571 | |||
572 | /**
|
||
573 | * <p>
|
||
574 | * Registers a Geometry implementation class with a predefined geometry type
|
||
575 | * and returns the associated GeometryType instance. Available predefined
|
||
576 | * types are defined in {@link Geometry.TYPES} and the subtypes are defined
|
||
577 | * in {@link Geometry.SUBTYPES}.
|
||
578 | * </p>
|
||
579 | * <p>
|
||
580 | * It adds also the super types and the super subTypes of the geometry, that
|
||
581 | * can be used to check if the type inherits of other types.
|
||
582 | * </p>
|
||
583 | * <p>
|
||
584 | * How to register a geometry class with a predefined type:
|
||
585 | *
|
||
586 | * <pre>
|
||
587 | *
|
||
588 | * GeometryType geomType = GeometryLocator.getGeometryManager()
|
||
589 | * .registerBasicGeometryType(Circle2D.class, "Circle2DM", Geometry.TYPES.CIRCLE,
|
||
590 | * Geometry.SYBTYPES.GEOM2D,
|
||
591 | * new int[]{Geometry.TYPES.CURVE, Geometry.TYPES.SURFACE});
|
||
592 | * </pre>
|
||
593 | *
|
||
594 | * </p>
|
||
595 | *
|
||
596 | * @param geomClass
|
||
597 | * Geometry subclass. It must not be null and must implement
|
||
598 | * Geometry, otherwise an exception
|
||
599 | * is raised.
|
||
600 | * @param name
|
||
601 | * Symbolic name for the geometry type, it can be null. If it is
|
||
602 | * null then the symbolic name
|
||
603 | * will be the simple class name.
|
||
604 | * @param type
|
||
605 | * Type of geometry. Must be a value defined in
|
||
606 | * {@link Geometry.TYPES}
|
||
607 | * @param subType
|
||
608 | * SubType of geometry. Must be a value defined in
|
||
609 | * {@link Geometry.SUBTYPES}
|
||
610 | * @param superTypes
|
||
611 | * List of the super types of a geometry. Must be a value defined in
|
||
612 | * {@link Geometry.TYPES}
|
||
613 | * @return Instance of GeometryType associated to the Geometry
|
||
614 | * implementation class
|
||
615 | * geomClass
|
||
616 | * @throws IllegalArgumentException
|
||
617 | * If geomClass is null or does not implement Geometry
|
||
618 | */
|
||
619 | public GeometryType registerGeometryType(Class geomClass, String name, |
||
620 | int type, int subType, int[] superTypes); |
||
621 | |||
622 | /**
|
||
623 | * <p>
|
||
624 | * Registers a Geometry implementation class with a predefined geometry type
|
||
625 | * and returns the associated GeometryType instance. Available predefined
|
||
626 | * types are defined in {@link Geometry.TYPES} and the subtypes are defined
|
||
627 | * in {@link Geometry.SUBTYPES}.
|
||
628 | * </p>
|
||
629 | * <p>
|
||
630 | * In this case the symbolic name will be the geometry's simple class name
|
||
631 | * </p>
|
||
632 | * How to register a new geometry type:
|
||
633 | *
|
||
634 | * <pre>
|
||
635 | *
|
||
636 | * GeometryType geomType = GeometryLocator.getGeometryManager()
|
||
637 | * .registerBasicGeometryType(Point2D.class, Geometry.TYPES.POINT,
|
||
638 | * Geometry.SYBTYPES.GEOM2D);
|
||
639 | * </pre>
|
||
640 | *
|
||
641 | * @param geomClass
|
||
642 | * Geometry implementation class. It must not be null and must
|
||
643 | * implement Geometry,
|
||
644 | * otherwise an exception is thrown.
|
||
645 | * @param type
|
||
646 | * Type of geometry. Must be a value defined in
|
||
647 | * {@link Geometry.TYPES}
|
||
648 | * @param subType
|
||
649 | * SubType of geometry. Must be a value defined in
|
||
650 | * {@link Geometry.SUBTYPES}
|
||
651 | * @return Instance of GeometryType associated to the Geometry
|
||
652 | * implementation class
|
||
653 | * @throws IllegalArgumentException
|
||
654 | * If geomClass is null or does not implement Geometry
|
||
655 | */
|
||
656 | public GeometryType registerGeometryType(Class geomClass, int type, |
||
657 | int subType);
|
||
658 | |||
659 | /**
|
||
660 | * <p>
|
||
661 | * Returns an instance of GeometryType given the Geometry type and the
|
||
662 | * subtype.
|
||
663 | * </p>
|
||
664 | *
|
||
665 | * @param type
|
||
666 | * Type of geometry. Must be a value defined in
|
||
667 | * {@link Geometry.TYPES}
|
||
668 | * @param subType
|
||
669 | * SubType of geometry. Must be a value defined in
|
||
670 | * {@link Geometry.SUBTYPES}
|
||
671 | * @return Instance of GeometryType associated to the type and the subtype
|
||
672 | * @throws GeometryTypeNotSupportedException
|
||
673 | * Returns this exception if there is not a registered geometry
|
||
674 | * with
|
||
675 | * these type and subtype
|
||
676 | * @throws GeometryTypeNotValidException
|
||
677 | * Returns if the type and subtype are not valid
|
||
678 | */
|
||
679 | public GeometryType getGeometryType(int type, int subType) |
||
680 | throws GeometryTypeNotSupportedException, GeometryTypeNotValidException;
|
||
681 | |||
682 | /**
|
||
683 | * <p>
|
||
684 | * This method creates a {@link Geometry} with the type specified by this
|
||
685 | * GeometryType. The geometry is empty, and all the internal attributes must
|
||
686 | * be assigned to a value when the geometry has been created.
|
||
687 | * </p>
|
||
688 | * <p>
|
||
689 | * This example creates a point2D and sets the coordinates to 1,1:
|
||
690 | *
|
||
691 | * <pre>
|
||
692 | * Point point =
|
||
693 | * (Point) GeometryLocator.getGeometryManager().create(GEOMETRY.TYPES.POINT,
|
||
694 | * GEOMETRY.SUBTYPES.GEOM2D);
|
||
695 | * point.setX(1);
|
||
696 | * point.setY(1);
|
||
697 | * </pre>
|
||
698 | *
|
||
699 | * </p>
|
||
700 | *
|
||
701 | * @param geomType
|
||
702 | * The geometry type
|
||
703 | * @return
|
||
704 | * A instance of a geometry.
|
||
705 | * @throws CreateGeometryException
|
||
706 | * This exception is thrown when the manager can not create
|
||
707 | * the geometry.
|
||
708 | */
|
||
709 | public Geometry create(GeometryType geomType)
|
||
710 | throws CreateGeometryException;
|
||
711 | |||
712 | /**
|
||
713 | * <p>
|
||
714 | * Creates a Envelope with a concrete subtype. The envelope is empty and it
|
||
715 | * have to be filled with the corners once has been created.
|
||
716 | * </p>
|
||
717 | *
|
||
718 | * @param subType
|
||
719 | * SubType of envelope. Must be a value defined in
|
||
720 | * {@link Geometry.SUBTYPES}
|
||
721 | * @return
|
||
722 | * A Envelope
|
||
723 | * @throws CreateEnvelopeException
|
||
724 | * If it is not possible to create the envelope.
|
||
725 | */
|
||
726 | public Envelope createEnvelope(int subType) throws CreateEnvelopeException; |
||
727 | |||
728 | /**
|
||
729 | * <p>
|
||
730 | * Creates a Envelope with a concrete subtype. It sets the values for the
|
||
731 | * lower corner and the upper corner (in 2D) using the method parameters.
|
||
732 | * </p>
|
||
733 | *
|
||
734 | * @param minX
|
||
735 | * The minimum value for the X coordinate.
|
||
736 | * @param minY
|
||
737 | * The minimum value for the Y coordinate.
|
||
738 | * @param maxX
|
||
739 | * The maximum value for the X coordinate.
|
||
740 | * @param maxY
|
||
741 | * The maximum value for the Y coordinate.
|
||
742 | * @param subType
|
||
743 | * SubType of envelope. Must be a value defined in
|
||
744 | * {@link Geometry.SUBTYPES}
|
||
745 | * @return
|
||
746 | * @throws CreateEnvelopeException
|
||
747 | */
|
||
748 | public Envelope createEnvelope(double minX, double minY, double maxX, |
||
749 | double maxY, int subType) throws CreateEnvelopeException; |
||
750 | |||
751 | /**
|
||
752 | * <p>
|
||
753 | * This method creates a {@link Geometry} with the type specified by this
|
||
754 | * name. If a geometry with this name doesn't exist, a
|
||
755 | * {@link IllegalArgumentException} is thrown. The geometry is empty, and
|
||
756 | * all the internal attributes must be assigned to a value when the geometry
|
||
757 | * has been created.
|
||
758 | * </p>
|
||
759 | * <p>
|
||
760 | * This example creates a point2D and sets the coordinates to 1,1: It
|
||
761 | * supposes that there is a Point2D class with name "Point2D".
|
||
762 | * </p>
|
||
763 | *
|
||
764 | * <pre>
|
||
765 | * Point point = (Point) GeometryLocator.getGeometryManager().create("Point2D");
|
||
766 | * point.setX(1);
|
||
767 | * point.setY(1);
|
||
768 | * </pre>
|
||
769 | *
|
||
770 | * @param name
|
||
771 | * The name of the geometry type
|
||
772 | * @return
|
||
773 | * A instance of a geometry.
|
||
774 | * @throws CreateGeometryException
|
||
775 | * This exception is thrown when the manager can not create
|
||
776 | * the geometry.
|
||
777 | */
|
||
778 | public Geometry create(String name) throws CreateGeometryException; |
||
779 | |||
780 | /**
|
||
781 | * Create a geometry from a WKT definition.
|
||
782 | *
|
||
783 | * This is a utility method to wrap the invocation to the operation
|
||
784 | * {@link OPERATIONS#FROMWKT}.
|
||
785 | *
|
||
786 | * @param wkt
|
||
787 | * geometry in Well-known text format
|
||
788 | *
|
||
789 | * @return the geometry as a Geometry
|
||
790 | *
|
||
791 | * @throws CreateGeometryException
|
||
792 | * @throws GeometryException
|
||
793 | */
|
||
794 | public Geometry createFrom(String wkt, String srs) |
||
795 | throws CreateGeometryException, GeometryException;
|
||
796 | |||
797 | public Geometry createFrom(String wkt) throws CreateGeometryException, |
||
798 | GeometryException; |
||
799 | |||
800 | /**
|
||
801 | * Create a geometry from a WKB definition.
|
||
802 | *
|
||
803 | * This is a utility method to wrap the invocation to the operation
|
||
804 | * {@link OPERATIONS#FROMWKB}.
|
||
805 | *
|
||
806 | * @param wkb
|
||
807 | * geometry in well-known binary format
|
||
808 | *
|
||
809 | * @return the geometry as a Geometry
|
||
810 | *
|
||
811 | * @throws CreateGeometryException
|
||
812 | * @throws GeometryException
|
||
813 | */
|
||
814 | public Geometry createFrom(byte[] wkb) throws CreateGeometryException, |
||
815 | GeometryException; |
||
816 | |||
817 | /**
|
||
818 | * <p>
|
||
819 | * This method creates a {@link Geometry} with a concrete type and subtype.
|
||
820 | * The geometry is empty, and all the internal attributes must be assigned
|
||
821 | * to a value when the geometry has been created.
|
||
822 | * </p>
|
||
823 | * <p>
|
||
824 | * This example creates a point2D and sets the coordinates to 1,1. It
|
||
825 | * supposes that there is a Point2D class with the id 1.
|
||
826 | * </p>
|
||
827 | *
|
||
828 | * <pre>
|
||
829 | * Point point =
|
||
830 | * (Point) GeometryLocator.getGeometryManager().create(Geometry.TYPES.POINT,
|
||
831 | * Geometry.SYBTYPES.GEOM2D);
|
||
832 | * point.setX(1);
|
||
833 | * point.setY(1);
|
||
834 | * </pre>
|
||
835 | *
|
||
836 | * @param type
|
||
837 | * Type of geometry. Must be a value defined in
|
||
838 | * {@link Geometry.TYPES}
|
||
839 | * @param subType
|
||
840 | * SubType of geometry. Must be a value defined in
|
||
841 | * {@link Geometry.SUBTYPES}
|
||
842 | * @return
|
||
843 | * A instance of a geometry.
|
||
844 | * @throws CreateGeometryException
|
||
845 | * This exception is thrown when the manager can not create
|
||
846 | * the geometry.
|
||
847 | */
|
||
848 | public Geometry create(int type, int subType) |
||
849 | throws CreateGeometryException;
|
||
850 | |||
851 | /**
|
||
852 | * <p>
|
||
853 | * It creates a null geometry with a concrete subtype.
|
||
854 | * <p>
|
||
855 | *
|
||
856 | * @param subType
|
||
857 | * SubType of geometry. Must be a value defined in
|
||
858 | * {@link Geometry.SUBTYPES}
|
||
859 | * @return
|
||
860 | * A NullGeometry
|
||
861 | * @throws CreateGeometryException
|
||
862 | * This exception is thrown when the manager can not create
|
||
863 | * the geometry.
|
||
864 | */
|
||
865 | public NullGeometry createNullGeometry(int subType) |
||
866 | throws CreateGeometryException;
|
||
867 | |||
868 | /**
|
||
869 | * <p>
|
||
870 | * Create a new point with a concrete type and sets the value for the X and
|
||
871 | * the Y.
|
||
872 | * </p>
|
||
873 | *
|
||
874 | * @param x
|
||
875 | * The X coordinate
|
||
876 | * @param y
|
||
877 | * The y coordinate
|
||
878 | * @param subType
|
||
879 | * SubType of geometry. Must be a value defined in
|
||
880 | * {@link Geometry.SUBTYPES}
|
||
881 | * @throws CreateGeometryException
|
||
882 | * This exception is thrown when the manager can not create
|
||
883 | * the geometry.
|
||
884 | * @return
|
||
885 | * The Point
|
||
886 | */
|
||
887 | public Point createPoint(double x, double y, int subType) |
||
888 | throws CreateGeometryException;
|
||
889 | |||
890 | /**
|
||
891 | * Create a new curve with a concrete type. Use later addVertex to add
|
||
892 | * vertex to te curve.
|
||
893 | *
|
||
894 | * @param subType SubType of geometry. Must be a value defined in {@link Geometry.SUBTYPES}
|
||
895 | * @return a curve
|
||
896 | * @throws CreateGeometryException
|
||
897 | * This exception is thrown when the manager can not create
|
||
898 | * the geometry.
|
||
899 | */
|
||
900 | public Curve createCurve(int subType) throws CreateGeometryException; |
||
901 | |||
902 | |||
903 | /**
|
||
904 | * Create a new multicurve with a concrete type
|
||
905 | * Use addPrimitive and addVertex to populate the multicurve.
|
||
906 | *
|
||
907 | * @param subType
|
||
908 | * SubType of geometry. Must be a value defined in
|
||
909 | * {@link Geometry.SUBTYPES}
|
||
910 | * @return A multicurve
|
||
911 | * @throws CreateGeometryException
|
||
912 | * This exception is thrown when the manager can not create the
|
||
913 | * geometry.
|
||
914 | */
|
||
915 | public MultiCurve createMultiCurve(int subType) throws CreateGeometryException; |
||
916 | |||
917 | /**
|
||
918 | * Create a new surface with a concrete type.
|
||
919 | * Use later addVertex to add vertex to te surface-
|
||
920 | *
|
||
921 | * @param subType
|
||
922 | * SubType of geometry. Must be a value defined in
|
||
923 | * {@link Geometry.SUBTYPES}
|
||
924 | * @return
|
||
925 | * A surface
|
||
926 | * @throws CreateGeometryException
|
||
927 | * This exception is thrown when the manager can not create
|
||
928 | * the geometry.
|
||
929 | */
|
||
930 | public Surface createSurface(int subType) |
||
931 | throws CreateGeometryException;
|
||
932 | |||
933 | /**
|
||
934 | * Create a new multisurface with a concrete type
|
||
935 | * Use later addPrimitive and addvertex to populate.
|
||
936 | *
|
||
937 | * @param subType
|
||
938 | * SubType of geometry. Must be a value defined in
|
||
939 | * {@link Geometry.SUBTYPES}
|
||
940 | * @return A multisurface
|
||
941 | * @throws CreateGeometryException
|
||
942 | * This exception is thrown when the manager can not create the
|
||
943 | * geometry.
|
||
944 | */
|
||
945 | public MultiSurface createMultiSurface(int subType) throws CreateGeometryException; |
||
946 | |||
947 | /**
|
||
948 | * <p>
|
||
949 | * Returns an operation given the Geometry type, the Geometry subtype and
|
||
950 | * and the operation code. If opCode corresponds to a common operation (a
|
||
951 | * common operation is an operation registered for all geometries), then
|
||
952 | * this method returns the common operation.
|
||
953 | * </p>
|
||
954 | * <p>
|
||
955 | * For better performance, if you need to call an operation multiple times,
|
||
956 | * use this method only once and keep the returned object in a local
|
||
957 | * variable over which you can iterate. For instance:
|
||
958 | *
|
||
959 | * <pre>
|
||
960 | * // Get the operation you need
|
||
961 | * GeometryManager gm = GeometryLocator.getGeometryManager()
|
||
962 | * GeometryOperation geomOp = null;
|
||
963 | * try {
|
||
964 | * geomOp = gm.getGeometryOperation(Draw2D.CODE, Geometry.TYPES.POINT,
|
||
965 | * Geometry.SUBTYPES.GEOM2D);
|
||
966 | * } catch (GeometryTypeNotSupportedException gtnse) {
|
||
967 | * // treat exception
|
||
968 | * } catch (GeometryOperationNotSupportedException gonse) {
|
||
969 | * // treat exception
|
||
970 | * }
|
||
971 | *
|
||
972 | * // Fill the operation context with required params
|
||
973 | * GeometryOperationContext ctx = new GeometryOperationContext();
|
||
974 | *
|
||
975 | * // Here is the main loop where you call the operation
|
||
976 | * for (int i=0; i<myGeometries.length; i++) {
|
||
977 | * Object result = geomOp.invoke(myGeometries[i], ctx);
|
||
978 | * }
|
||
979 | * </pre>
|
||
980 | *
|
||
981 | * </p>
|
||
982 | *
|
||
983 | * @param opCode
|
||
984 | * The operation code
|
||
985 | * @param type
|
||
986 | * Type of geometry. Must be a value defined in
|
||
987 | * {@link Geometry.TYPES}
|
||
988 | * @param subType
|
||
989 | * SubType of geometry. Must be a value defined in
|
||
990 | * {@link Geometry.SUBTYPES}
|
||
991 | * @return Geometry operation
|
||
992 | * @throws GeometryTypeNotSupportedException
|
||
993 | * Returns this exception if there is not a registered geometry
|
||
994 | * with
|
||
995 | * these type and subtype
|
||
996 | * @throws GeometryTypeNotValidException
|
||
997 | * Returns this exception if the type and subtype are not valid
|
||
998 | * @throws GeometryOperationNotSupportedException
|
||
999 | * Returns this exception if there is not a registered operation
|
||
1000 | * with
|
||
1001 | * this operation code
|
||
1002 | */
|
||
1003 | public GeometryOperation getGeometryOperation(int opCode, int type, |
||
1004 | int subType) throws GeometryTypeNotSupportedException, |
||
1005 | GeometryOperationNotSupportedException, GeometryTypeNotValidException; |
||
1006 | |||
1007 | /**
|
||
1008 | * <p>
|
||
1009 | * Returns an common operation with given operation code. A common operation
|
||
1010 | * is an operation registered for all geometries.
|
||
1011 | * </p>
|
||
1012 | * <p>
|
||
1013 | * For better performance, if you need to call an operation multiple times,
|
||
1014 | * use this method only once and keep the returned object in a local
|
||
1015 | * variable over which you can iterate. For instance:
|
||
1016 | *
|
||
1017 | * <pre>
|
||
1018 | * // Get the operation you need
|
||
1019 | * GeometryManager gm = GeometryLocator.getGeometryManager()
|
||
1020 | * GeometryOperation geomOp = null;
|
||
1021 | * try {
|
||
1022 | * geomOp = gm.getGeometryOperation(FromWKB.CODE);
|
||
1023 | * } catch (GeometryOperationNotSupportedException gonse) {
|
||
1024 | * // treat exception
|
||
1025 | * }
|
||
1026 | *
|
||
1027 | * // Fill the operation context with required params
|
||
1028 | * FromWKBGeometryOperationContext ctx = new FromWKBGeometryOperationContext();
|
||
1029 | *
|
||
1030 | * // Here is the main loop where you call the operation
|
||
1031 | * for (int i=0; i<myGeometriesWKB.length; i++) {
|
||
1032 | * ctx.setData(myGeometriesWKB[i]);
|
||
1033 | * Object result = geomOp.invoke(null, ctx);
|
||
1034 | * }
|
||
1035 | * </pre>
|
||
1036 | *
|
||
1037 | * </p>
|
||
1038 | *
|
||
1039 | * @param opCode
|
||
1040 | * The operation code
|
||
1041 | * @return Geometry operation
|
||
1042 | * @throws GeometryOperationNotSupportedException
|
||
1043 | * Returns this exception if there is not a registered operation
|
||
1044 | * with
|
||
1045 | * this operation code
|
||
1046 | */
|
||
1047 | public GeometryOperation getGeometryOperation(int opCode) |
||
1048 | throws GeometryOperationNotSupportedException;
|
||
1049 | |||
1050 | /**
|
||
1051 | * <p>
|
||
1052 | * Invokes an operation given its code, the geometry and the operation
|
||
1053 | * context holding the parameters required for the operation.
|
||
1054 | * </p>
|
||
1055 | *
|
||
1056 | * @param opCode
|
||
1057 | * Operation code.
|
||
1058 | * @param geom
|
||
1059 | * Geometry to which apply the operation
|
||
1060 | * @param ctx
|
||
1061 | * Context holding the operation parameters
|
||
1062 | * @return
|
||
1063 | * The object returned by an operation, depends on each operation.
|
||
1064 | */
|
||
1065 | public Object invokeOperation(int opCode, Geometry geom, |
||
1066 | GeometryOperationContext ctx) |
||
1067 | throws GeometryOperationNotSupportedException,
|
||
1068 | GeometryOperationException; |
||
1069 | |||
1070 | /**
|
||
1071 | * <p>
|
||
1072 | * Invokes an operation given its code, the geometry and the operation
|
||
1073 | * context holding the parameters required for the operation.
|
||
1074 | * </p>
|
||
1075 | *
|
||
1076 | * @param geomOpName
|
||
1077 | * Operation name.
|
||
1078 | * @param geom
|
||
1079 | * Geometry to which apply the operation
|
||
1080 | * @param ctx
|
||
1081 | * Context holding the operation parameters
|
||
1082 | * @return
|
||
1083 | * The object returned by an operation, depends on each operation.
|
||
1084 | */
|
||
1085 | public Object invokeOperation(String geomOpName, Geometry geom, |
||
1086 | GeometryOperationContext ctx) |
||
1087 | throws GeometryOperationNotSupportedException,
|
||
1088 | GeometryOperationException; |
||
1089 | |||
1090 | /**
|
||
1091 | * <p>
|
||
1092 | * Invokes an operation given its code, and the operation context holding
|
||
1093 | * the parameters required for the operation.
|
||
1094 | * </p>
|
||
1095 | *
|
||
1096 | * @param geomOpName
|
||
1097 | * Operation name.
|
||
1098 | * @param ctx
|
||
1099 | * Context holding the operation parameters
|
||
1100 | * @return
|
||
1101 | * The object returned by an operation, depends on each operation.
|
||
1102 | */
|
||
1103 | public Object invokeOperation(String geomOpName, |
||
1104 | GeometryOperationContext ctx) |
||
1105 | throws GeometryOperationNotSupportedException,
|
||
1106 | GeometryOperationException; |
||
1107 | |||
1108 | /**
|
||
1109 | * <p>
|
||
1110 | * Registers the unique name of one operation. If it already exists then
|
||
1111 | * this method does nothing but returning the name's corresponding index.
|
||
1112 | * </p>
|
||
1113 | * <p>
|
||
1114 | * By convention this method is used to set the value of the final and
|
||
1115 | * static variable that is located in the classes that implements the
|
||
1116 | * operation:<BR>
|
||
1117 | *
|
||
1118 | * <pre>
|
||
1119 | *
|
||
1120 | * public class MyOperation extends GeometryOperation {
|
||
1121 | *
|
||
1122 | * public static final int CODE = GeometryLocator.getGeometryManager()
|
||
1123 | * .getGeometryOperationCode("MyOperation");
|
||
1124 | * }
|
||
1125 | * </pre>
|
||
1126 | *
|
||
1127 | * </p>
|
||
1128 | *
|
||
1129 | * @param geomOpName
|
||
1130 | * Name used to register the geometry operation
|
||
1131 | * @return
|
||
1132 | * Index assigned to the operation name passed as parameter
|
||
1133 | */
|
||
1134 | public int getGeometryOperationCode(String geomOpName); |
||
1135 | |||
1136 | /**
|
||
1137 | * Returns a list with the name of the operations that have been
|
||
1138 | * registered.
|
||
1139 | *
|
||
1140 | * @return
|
||
1141 | * A list of the registered operations.
|
||
1142 | */
|
||
1143 | public List getGeometryOperationNames(); |
||
1144 | |||
1145 | /**
|
||
1146 | * Returns the flatness used to convert a curve is a set
|
||
1147 | * of points.
|
||
1148 | *
|
||
1149 | * @return
|
||
1150 | * The flatness.
|
||
1151 | */
|
||
1152 | public double getFlatness(); |
||
1153 | |||
1154 | /**
|
||
1155 | * Sets the application flatness.
|
||
1156 | *
|
||
1157 | * @param flatness
|
||
1158 | * The flatness to set
|
||
1159 | */
|
||
1160 | public void setFlatness(double flatness); |
||
1161 | |||
1162 | /**
|
||
1163 | * Create a memory spatial index with the default implementation.
|
||
1164 | *
|
||
1165 | * @return a new SpatialIndex
|
||
1166 | */
|
||
1167 | public SpatialIndex createDefaultMemorySpatialIndex() throws GeometryException; |
||
1168 | |||
1169 | |||
1170 | /**
|
||
1171 | * Create a GeneralPathX to populate a geometry.
|
||
1172 | * This method is deprecated, instead use OrientablePrimitive#addVertex(Point) to add vertex to
|
||
1173 | * primitive geometries or {@link MultiPrimitive#addPrimitive(org.gvsig.fmap.geom.primitive.Primitive)} to add geometries to an aggregate.
|
||
1174 | *
|
||
1175 | * @param rule
|
||
1176 | * @param initialCapacity
|
||
1177 | * @param pathIterator , can be null
|
||
1178 | * @return a GeneralPathX
|
||
1179 | * @deprecated use method of Geometry to handle this
|
||
1180 | * @see OrientablePrimitive#addVertex(Point) or {@link MultiPrimitive#addPrimitive(org.gvsig.fmap.geom.primitive.Primitive)}
|
||
1181 | *
|
||
1182 | */
|
||
1183 | public GeneralPathX createGeneralPath(int rule, PathIterator pathIterator); |
||
1184 | |||
1185 | /**
|
||
1186 | * <p>
|
||
1187 | * Create a new curve with a concrete type and sets the value for the
|
||
1188 | * coordinates using a GeneralPathX.
|
||
1189 | * </p>
|
||
1190 | *
|
||
1191 | * @param generalPathX
|
||
1192 | * It is used to set the values for the X and Y coordinates.
|
||
1193 | * @param subType
|
||
1194 | * SubType of geometry. Must be a value defined in
|
||
1195 | * {@link Geometry.SUBTYPES}
|
||
1196 | * @return
|
||
1197 | * A curve
|
||
1198 | * @throws CreateGeometryException
|
||
1199 | * This exception is thrown when the manager can not create
|
||
1200 | * the geometry.
|
||
1201 | * @deprecated use {@link #createCurve(int)} and OrientablePrimitive#addVertex(Point)
|
||
1202 | */
|
||
1203 | public Curve createCurve(GeneralPathX generalPathX, int subType) |
||
1204 | throws CreateGeometryException;
|
||
1205 | |||
1206 | /**
|
||
1207 | * <p>
|
||
1208 | * Create a new multicurve with a concrete type and sets the value for the
|
||
1209 | * coordinates using a GeneralPathX.
|
||
1210 | * </p>
|
||
1211 | *
|
||
1212 | * @param generalPathX
|
||
1213 | * It is used to set the values for the X and Y coordinates.
|
||
1214 | * @param subType
|
||
1215 | * SubType of geometry. Must be a value defined in
|
||
1216 | * {@link Geometry.SUBTYPES}
|
||
1217 | * @return A multicurve
|
||
1218 | * @throws CreateGeometryException
|
||
1219 | * This exception is thrown when the manager can not create the
|
||
1220 | * geometry.
|
||
1221 | * @deprecated use {@link #createMultiCurve(int)} and {@link MultiPrimitive#addPrimitive(org.gvsig.fmap.geom.primitive.Primitive)}
|
||
1222 | */
|
||
1223 | public MultiCurve createMultiCurve(GeneralPathX generalPathX, int subType) |
||
1224 | throws CreateGeometryException;
|
||
1225 | |||
1226 | /**
|
||
1227 | * <p>
|
||
1228 | * Create a new surface with a concrete type and sets the value for the
|
||
1229 | * coordinates using a GeneralPathX.
|
||
1230 | * </p>
|
||
1231 | *
|
||
1232 | * @param generalPathX
|
||
1233 | * It is used to set the values for the X and Y coordinates.
|
||
1234 | * @param subType
|
||
1235 | * SubType of geometry. Must be a value defined in
|
||
1236 | * {@link Geometry.SUBTYPES}
|
||
1237 | * @return
|
||
1238 | * A surface
|
||
1239 | * @throws CreateGeometryException
|
||
1240 | * This exception is thrown when the manager can not create
|
||
1241 | * the geometry.
|
||
1242 | * @deprecated use {@link #createSurface(int)} and OrientablePrimitive#addVertex(Point)
|
||
1243 | */
|
||
1244 | public Surface createSurface(GeneralPathX generalPathX, int subType) |
||
1245 | throws CreateGeometryException;
|
||
1246 | |||
1247 | /**
|
||
1248 | * <p>
|
||
1249 | * Create a new multisurface with a concrete type and sets the value for the
|
||
1250 | * coordinates using a GeneralPathX.
|
||
1251 | * </p>
|
||
1252 | *
|
||
1253 | * @param generalPathX
|
||
1254 | * It is used to set the values for the X and Y coordinates.
|
||
1255 | * @param subType
|
||
1256 | * SubType of geometry. Must be a value defined in
|
||
1257 | * {@link Geometry.SUBTYPES}
|
||
1258 | * @return A multisurface
|
||
1259 | * @throws CreateGeometryException
|
||
1260 | * This exception is thrown when the manager can not create the
|
||
1261 | * geometry.
|
||
1262 | * @deprecated use {@link #createMultiSurface(int)} and {@link MultiPrimitive#addPrimitive(org.gvsig.fmap.geom.primitive.Primitive)}
|
||
1263 | */
|
||
1264 | public MultiSurface createMultiSurface(GeneralPathX generalPathX,
|
||
1265 | int subType) throws CreateGeometryException; |
||
1266 | |||
1267 | } |