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