|
1 |
/**
|
|
2 |
* gvSIG. Desktop Geographic Information System.
|
|
3 |
*
|
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
|
5 |
*
|
|
6 |
* This program is free software; you can redistribute it and/or
|
|
7 |
* modify it under the terms of the GNU General Public License
|
|
8 |
* as published by the Free Software Foundation; either version 3
|
|
9 |
* of the License, or (at your option) any later version.
|
|
10 |
*
|
|
11 |
* This program is distributed in the hope that it will be useful,
|
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14 |
* GNU General Public License for more details.
|
|
15 |
*
|
|
16 |
* You should have received a copy of the GNU General Public License
|
|
17 |
* along with this program; if not, write to the Free Software
|
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
19 |
* MA 02110-1301, USA.
|
|
20 |
*
|
|
21 |
* For any additional information, do not hesitate to contact us
|
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
|
23 |
*/
|
|
24 |
package org.gvsig.fmap.geom;
|
|
25 |
|
|
26 |
import java.awt.geom.PathIterator;
|
|
27 |
import java.util.List;
|
|
28 |
|
|
29 |
import org.gvsig.fmap.geom.aggregate.MultiCurve;
|
|
30 |
import org.gvsig.fmap.geom.aggregate.MultiLine;
|
|
31 |
import org.gvsig.fmap.geom.aggregate.MultiPoint;
|
|
32 |
import org.gvsig.fmap.geom.aggregate.MultiPolygon;
|
|
33 |
import org.gvsig.fmap.geom.aggregate.MultiPrimitive;
|
|
34 |
import org.gvsig.fmap.geom.aggregate.MultiSurface;
|
|
35 |
import org.gvsig.fmap.geom.exception.CreateEnvelopeException;
|
|
36 |
import org.gvsig.fmap.geom.exception.CreateGeometryException;
|
|
37 |
import org.gvsig.fmap.geom.operation.GeometryOperation;
|
|
38 |
import org.gvsig.fmap.geom.operation.GeometryOperationContext;
|
|
39 |
import org.gvsig.fmap.geom.operation.GeometryOperationException;
|
|
40 |
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException;
|
|
41 |
import org.gvsig.fmap.geom.primitive.Curve;
|
|
42 |
import org.gvsig.fmap.geom.primitive.Envelope;
|
|
43 |
import org.gvsig.fmap.geom.primitive.GeneralPathX;
|
|
44 |
import org.gvsig.fmap.geom.primitive.IGeneralPathX;
|
|
45 |
import org.gvsig.fmap.geom.primitive.Line;
|
|
46 |
import org.gvsig.fmap.geom.primitive.NullGeometry;
|
|
47 |
import org.gvsig.fmap.geom.primitive.OrientablePrimitive;
|
|
48 |
import org.gvsig.fmap.geom.primitive.Point;
|
|
49 |
import org.gvsig.fmap.geom.primitive.Polygon;
|
|
50 |
import org.gvsig.fmap.geom.primitive.Surface;
|
|
51 |
import org.gvsig.fmap.geom.type.GeometryType;
|
|
52 |
import org.gvsig.fmap.geom.type.GeometryTypeNotSupportedException;
|
|
53 |
import org.gvsig.fmap.geom.type.GeometryTypeNotValidException;
|
|
54 |
import org.gvsig.tools.dynobject.DynObject;
|
|
55 |
import org.gvsig.tools.service.Manager;
|
|
56 |
import org.gvsig.tools.service.ServiceException;
|
|
57 |
import org.gvsig.tools.service.spi.ServiceManager;
|
|
58 |
|
|
59 |
/**
|
|
60 |
* This singleton provides a centralized access to gvSIG's Geometry Model.
|
|
61 |
* Its responsibilities are:<br>
|
|
62 |
*
|
|
63 |
* <ul>
|
|
64 |
* <li>Offering a set of convenient methods for registering and retrieving
|
|
65 |
* geometry types.
|
|
66 |
* <li>Offering a set of convenient methods for registering and retrieving
|
|
67 |
* geometry operations associated to one or more geometry types.
|
|
68 |
* <li>Offering a set of convenient methods for registering and retrieving new
|
|
69 |
* geometries.
|
|
70 |
* </ul>
|
|
71 |
*
|
|
72 |
* @author jiyarza
|
|
73 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
|
|
74 |
*/
|
|
75 |
public interface GeometryManager extends Manager, ServiceManager {
|
|
76 |
|
|
77 |
public interface OPERATIONS {
|
|
78 |
|
|
79 |
public final static String FROMWKT = "FromWKT";
|
|
80 |
public final static String FROMWKB = "FromWKB";
|
|
81 |
}
|
|
82 |
|
|
83 |
/**
|
|
84 |
* <p>
|
|
85 |
* Registers a GeometryOperation associated to a GeometryType. Returns an
|
|
86 |
* unique index that is used later to identify and invoke the operation.
|
|
87 |
* </p>
|
|
88 |
* <p>
|
|
89 |
* By convention this index should be in a final and static variable in the
|
|
90 |
* class that implements the operation. The value of this variable must be
|
|
91 |
* set using the method
|
|
92 |
* {@link GeometryManager#getGeometryOperationCode(String)}:<BR>
|
|
93 |
*
|
|
94 |
* <pre>
|
|
95 |
*
|
|
96 |
* public class MyOperation extends GeometryOperation {
|
|
97 |
*
|
|
98 |
* public static final int CODE = GeometryLocator.getGeometryManager()
|
|
99 |
* .getGeometryOperationCode("MyOperation");
|
|
100 |
* }
|
|
101 |
* </pre>
|
|
102 |
*
|
|
103 |
* </p>
|
|
104 |
*
|
|
105 |
* @param geomOpName
|
|
106 |
* Operation's unique name
|
|
107 |
* @param geomOp
|
|
108 |
* Specific GeometryOperation's instance implementing this
|
|
109 |
* operation
|
|
110 |
* @param geomType
|
|
111 |
* GeometryType instance to which this operation should be
|
|
112 |
* associated
|
|
113 |
* @return Index assigned to this operation. This index is used later to
|
|
114 |
* access the operation.
|
|
115 |
*
|
|
116 |
*/
|
|
117 |
public int registerGeometryOperation(String geomOpName,
|
|
118 |
GeometryOperation geomOp, GeometryType geomType);
|
|
119 |
|
|
120 |
/**
|
|
121 |
* <p>
|
|
122 |
* Registers a GeometryOperation that is common for all GeometryType
|
|
123 |
* (registered yet or not). Returns an unique index that is used later to
|
|
124 |
* identify and invoke the operation.
|
|
125 |
* </p>
|
|
126 |
* <p>
|
|
127 |
* By convention this index should be in a final and static variable in the
|
|
128 |
* class that implements the operation. The value of this variable must be
|
|
129 |
* set using the method
|
|
130 |
* {@link GeometryManager#getGeometryOperationCode(String)}:<BR>
|
|
131 |
*
|
|
132 |
* <pre>
|
|
133 |
*
|
|
134 |
* public class MyOperation extends GeometryOperation {
|
|
135 |
*
|
|
136 |
* public static final int CODE = GeometryLocator.getGeometryManager()
|
|
137 |
* .getGeometryOperationCode("MyOperation");
|
|
138 |
* }
|
|
139 |
* </pre>
|
|
140 |
*
|
|
141 |
* </p>
|
|
142 |
*
|
|
143 |
* @param geomOpName
|
|
144 |
* Operation's unique name
|
|
145 |
* @param geomOp
|
|
146 |
* Specific GeometryOperation's instance implementing this
|
|
147 |
* operation
|
|
148 |
* @return Index assigned to this operation. This index is used later to
|
|
149 |
* access the operation.
|
|
150 |
*/
|
|
151 |
public int registerGeometryOperation(String geomOpName,
|
|
152 |
GeometryOperation geomOp);
|
|
153 |
|
|
154 |
/**
|
|
155 |
* <p>
|
|
156 |
* Registers a GeometryOperation associated to a GeometryType, that has been
|
|
157 |
* specified using the type code and the subtype code. Returns an unique
|
|
158 |
* index that is used later to identify and invoke the operation.
|
|
159 |
* </p>
|
|
160 |
* <p>
|
|
161 |
* By convention this index should be in a final and static variable in the
|
|
162 |
* class that implements the operation. The value of this variable must be
|
|
163 |
* set using the method
|
|
164 |
* {@link GeometryManager#getGeometryOperationCode(String)}:<BR>
|
|
165 |
*
|
|
166 |
* <pre>
|
|
167 |
*
|
|
168 |
* public class MyOperation extends GeometryOperation {
|
|
169 |
*
|
|
170 |
* public static final int CODE = GeometryLocator.getGeometryManager()
|
|
171 |
* .getGeometryOperationCode("MyOperation");
|
|
172 |
* }
|
|
173 |
* </pre>
|
|
174 |
*
|
|
175 |
* </p>
|
|
176 |
* <p>
|
|
177 |
* This method is only used if you have not a reference to the GeometryType
|
|
178 |
* associated to the geometry class. If you have such reference then it is
|
|
179 |
* slightly faster to use the method that receives the GeometryType.<br>
|
|
180 |
* </p>
|
|
181 |
*
|
|
182 |
* @param geomOpName
|
|
183 |
* Operation's unique name
|
|
184 |
* @param geomOp
|
|
185 |
* Specific GeometryOperation's instance implementing this
|
|
186 |
* operation
|
|
187 |
* @param type
|
|
188 |
* Type of geometry. Must be a value defined in
|
|
189 |
* {@link Geometry.TYPES}
|
|
190 |
* @param subType
|
|
191 |
* SubType of geometry. Must be a value defined in
|
|
192 |
* {@link Geometry.SUBTYPES}
|
|
193 |
* @return Index assigned to this operation. This index is used later to
|
|
194 |
* access the operation.
|
|
195 |
* @throws GeometryTypeNotSupportedException
|
|
196 |
* Returns this exception if there is not a registered geometry
|
|
197 |
* with
|
|
198 |
* these type and subtype
|
|
199 |
* @throws GeometryTypeNotValidException
|
|
200 |
* Returns if the type and subtype are not valid
|
|
201 |
*/
|
|
202 |
public int registerGeometryOperation(String geomOpName,
|
|
203 |
GeometryOperation geomOp, int type, int subType)
|
|
204 |
throws GeometryTypeNotSupportedException, GeometryTypeNotValidException;
|
|
205 |
|
|
206 |
/**
|
|
207 |
* <p>
|
|
208 |
* Registers a GeometryOperation associated to all the geometries with a
|
|
209 |
* concrete type. Returns an unique index that is used later to identify and
|
|
210 |
* invoke the operation.<br>
|
|
211 |
* </p>
|
|
212 |
* <p>
|
|
213 |
* By convention this index should be in a final and static variable in the
|
|
214 |
* class that implements the operation. The value of this variable must be
|
|
215 |
* set using the method
|
|
216 |
* {@link GeometryManager#getGeometryOperationCode(String)}:<BR>
|
|
217 |
*
|
|
218 |
* <pre>
|
|
219 |
*
|
|
220 |
* public class MyOperation extends GeometryOperation {
|
|
221 |
*
|
|
222 |
* public static final int CODE = GeometryLocator.getGeometryManager()
|
|
223 |
* .getGeometryOperationCode("MyOperation");
|
|
224 |
* }
|
|
225 |
* </pre>
|
|
226 |
*
|
|
227 |
* </p>
|
|
228 |
*
|
|
229 |
* @param geomOpName
|
|
230 |
* Operation's unique name
|
|
231 |
* @param geomOp
|
|
232 |
* Specific GeometryOperation's instance implementing this
|
|
233 |
* operation
|
|
234 |
* @param type
|
|
235 |
* Type of geometry. Must be a value defined in
|
|
236 |
* {@link Geometry.TYPES}
|
|
237 |
* @return Index assigned to this operation. This index is used later to
|
|
238 |
* access the operation.
|
|
239 |
*/
|
|
240 |
public int registerGeometryOperation(String geomOpName,
|
|
241 |
GeometryOperation geomOp, int type);
|
|
242 |
|
|
243 |
/**
|
|
244 |
* <p>
|
|
245 |
* Registers a GeometryOperation associated to all the geometries which
|
|
246 |
* super type matches with a concrete type. Returns an unique index that
|
|
247 |
* is used later to identify and invoke the operation.<br>
|
|
248 |
* </p>
|
|
249 |
* <p>
|
|
250 |
* By convention this index should be in a final and static variable in the
|
|
251 |
* class that implements the operation. The value of this variable must be
|
|
252 |
* set using the method
|
|
253 |
* {@link GeometryManager#getGeometryOperationCode(String)}:<BR>
|
|
254 |
*
|
|
255 |
* <pre>
|
|
256 |
*
|
|
257 |
* public class MyOperation extends GeometryOperation {
|
|
258 |
*
|
|
259 |
* public static final int CODE = GeometryLocator.getGeometryManager()
|
|
260 |
* .getGeometryOperationCode("MyOperation");
|
|
261 |
* }
|
|
262 |
* </pre>
|
|
263 |
*
|
|
264 |
* </p>
|
|
265 |
*
|
|
266 |
* @param geomOpName
|
|
267 |
* Operation's unique name
|
|
268 |
* @param geomOp
|
|
269 |
* Specific GeometryOperation's instance implementing this
|
|
270 |
* operation
|
|
271 |
* @param superType
|
|
272 |
* super type of geometries that is used to register
|
|
273 |
* the operation. Must be a value defined in
|
|
274 |
* {@link Geometry.TYPES}
|
|
275 |
* @return Index assigned to this operation. This index is used later to
|
|
276 |
* access the operation.
|
|
277 |
*/
|
|
278 |
public int registerGeometryOperationBySuperType(String geomOpName,
|
|
279 |
GeometryOperation geomOp, int superType);
|
|
280 |
|
|
281 |
/**
|
|
282 |
* <p>
|
|
283 |
* Registers a GeometryOperation associated to all the geometries which
|
|
284 |
* super subType matches with a concrete subType. Returns an unique index that
|
|
285 |
* is used later to identify and invoke the operation.<br>
|
|
286 |
* </p>
|
|
287 |
* <p>
|
|
288 |
* By convention this index should be in a final and static variable in the
|
|
289 |
* class that implements the operation. The value of this variable must be
|
|
290 |
* set using the method
|
|
291 |
* {@link GeometryManager#getGeometryOperationCode(String)}:<BR>
|
|
292 |
*
|
|
293 |
* <pre>
|
|
294 |
*
|
|
295 |
* public class MyOperation extends GeometryOperation {
|
|
296 |
*
|
|
297 |
* public static final int CODE = GeometryLocator.getGeometryManager()
|
|
298 |
* .getGeometryOperationCode("MyOperation");
|
|
299 |
* }
|
|
300 |
* </pre>
|
|
301 |
*
|
|
302 |
* </p>
|
|
303 |
*
|
|
304 |
* @param geomOpName
|
|
305 |
* Operation's unique name
|
|
306 |
* @param geomOp
|
|
307 |
* Specific GeometryOperation's instance implementing this
|
|
308 |
* operation
|
|
309 |
* @param superSubType
|
|
310 |
* super subType of geometries that is used to register
|
|
311 |
* the operation. Must be a value defined in
|
|
312 |
* {@link Geometry.SUBTYPES}
|
|
313 |
* @return Index assigned to this operation. This index is used later to
|
|
314 |
* access the operation.
|
|
315 |
*/
|
|
316 |
public int registerGeometryOperationBySuperSubType(String geomOpName,
|
|
317 |
GeometryOperation geomOp, int superSubType);
|
|
318 |
|
|
319 |
/**
|
|
320 |
* <p>
|
|
321 |
* Registers a GeometryOperation associated to all the geometries with a
|
|
322 |
* concrete subtype. Returns an unique index that is used later to identify
|
|
323 |
* and invoke the operation.<br>
|
|
324 |
* </p>
|
|
325 |
* <p>
|
|
326 |
* By convention this index should be in a final and static variable in the
|
|
327 |
* class that implements the operation. The value of this variable must be
|
|
328 |
* set using the method
|
|
329 |
* {@link GeometryManager#getGeometryOperationCode(String)}:<BR>
|
|
330 |
*
|
|
331 |
* <pre>
|
|
332 |
*
|
|
333 |
* public class MyOperation extends GeometryOperation {
|
|
334 |
*
|
|
335 |
* public static final int CODE = GeometryLocator.getGeometryManager()
|
|
336 |
* .getGeometryOperationCode("MyOperation");
|
|
337 |
* }
|
|
338 |
* </pre>
|
|
339 |
*
|
|
340 |
* </p>
|
|
341 |
*
|
|
342 |
* @param geomOpName
|
|
343 |
* Operation's unique name
|
|
344 |
* @param geomOp
|
|
345 |
* Specific GeometryOperation's instance implementing this
|
|
346 |
* operation
|
|
347 |
* @param subType
|
|
348 |
* SubType of geometry. Must be a value defined in
|
|
349 |
* {@link Geometry.SUBTYPES}
|
|
350 |
* @return Index assigned to this operation. This index is used later to
|
|
351 |
* access the operation.
|
|
352 |
*/
|
|
353 |
public int registerGeometryOperationBySubtype(String geomOpName,
|
|
354 |
GeometryOperation geomOp, int subType);
|
|
355 |
|
|
356 |
/**
|
|
357 |
* <p>
|
|
358 |
* Registers a GeometryType instance.
|
|
359 |
* </p>
|
|
360 |
*
|
|
361 |
* @param geometryType
|
|
362 |
* A {@link GeometryType} instance to create {@link Geometry} objects
|
|
363 |
*/
|
|
364 |
public void registerGeometryType(GeometryType geometryType);
|
|
365 |
|
|
366 |
/**
|
|
367 |
* <p>
|
|
368 |
* Registers a Geometry implementation class with a predefined geometry type
|
|
369 |
* and returns the associated GeometryType instance. Available predefined
|
|
370 |
* types are defined in {@link Geometry.TYPES} and the subtypes are defined
|
|
371 |
* in {@link Geometry.SUBTYPES}.
|
|
372 |
* </p>
|
|
373 |
* <p>
|
|
374 |
* How to register a geometry class with a predefined type:
|
|
375 |
*
|
|
376 |
* <pre>
|
|
377 |
*
|
|
378 |
* GeometryType geomType = GeometryLocator.getGeometryManager()
|
|
379 |
* .registerBasicGeometryType(Point2D.class, "Point2D", Geometry.TYPES.POINT,
|
|
380 |
* Geometry.SYBTYPES.GEOM2D);
|
|
381 |
* </pre>
|
|
382 |
*
|
|
383 |
* </p>
|
|
384 |
*
|
|
385 |
* @param geomClass
|
|
386 |
* Geometry subclass. It must not be null and must implement
|
|
387 |
* Geometry, otherwise an exception
|
|
388 |
* is raised.
|
|
389 |
* @param name
|
|
390 |
* Symbolic name for the geometry type, it can be null. If it is
|
|
391 |
* null then the symbolic name
|
|
392 |
* will be the simple class name.
|
|
393 |
* @param type
|
|
394 |
* Type of geometry. Must be a value defined in
|
|
395 |
* {@link Geometry.TYPES}
|
|
396 |
* @param subType
|
|
397 |
* SubType of geometry. Must be a value defined in
|
|
398 |
* {@link Geometry.SUBTYPES}
|
|
399 |
* @return Instance of GeometryType associated to the Geometry
|
|
400 |
* implementation class
|
|
401 |
* geomClass
|
|
402 |
* @throws IllegalArgumentException
|
|
403 |
* If geomClass is null or does not implement Geometry
|
|
404 |
*/
|
|
405 |
public GeometryType registerGeometryType(Class geomClass, String name,
|
|
406 |
int type, int subType);
|
|
407 |
|
|
408 |
/**
|
|
409 |
* <p>
|
|
410 |
* Registers a Geometry implementation class with a predefined geometry type
|
|
411 |
* and returns the associated GeometryType instance. Available predefined
|
|
412 |
* types are defined in {@link Geometry.TYPES} and the subtypes are defined
|
|
413 |
* in {@link Geometry.SUBTYPES}.
|
|
414 |
* </p>
|
|
415 |
* <p>
|
|
416 |
* It adds also the super type and the super subType of the geometry, that
|
|
417 |
* can be used to check if the type (or the subtype) inherits of other
|
|
418 |
* type (or subType)
|
|
419 |
* </p>
|
|
420 |
* <p>
|
|
421 |
* How to register a geometry class with a predefined type:
|
|
422 |
*
|
|
423 |
* <pre>
|
|
424 |
*
|
|
425 |
* GeometryType geomType = GeometryLocator.getGeometryManager()
|
|
426 |
* .registerBasicGeometryType(Arc3D.class, "Arc3D", Geometry.TYPES.ARC,
|
|
427 |
* Geometry.SYBTYPES.GEOM3D, Geometry.TYPES.CURVE, Geometry.SYBTYPES.GEOM2D);
|
|
428 |
* </pre>
|
|
429 |
*
|
|
430 |
* </p>
|
|
431 |
*
|
|
432 |
* @param geomClass
|
|
433 |
* Geometry subclass. It must not be null and must implement
|
|
434 |
* Geometry, otherwise an exception
|
|
435 |
* is raised.
|
|
436 |
* @param name
|
|
437 |
* Symbolic name for the geometry type, it can be null. If it is
|
|
438 |
* null then the symbolic name
|
|
439 |
* will be the simple class name.
|
|
440 |
* @param type
|
|
441 |
* Type of geometry. Must be a value defined in
|
|
442 |
* {@link Geometry.TYPES}
|
|
443 |
* @param subType
|
|
444 |
* SubType of geometry. Must be a value defined in
|
|
445 |
* {@link Geometry.SUBTYPES}
|
|
446 |
* @param superType
|
|
447 |
* Super type of a geometry. Must be a value defined in
|
|
448 |
* {@link Geometry.TYPES}
|
|
449 |
* @param superSubType
|
|
450 |
* Super subType of a geometry. Must be a value defined in
|
|
451 |
* {@link Geometry.SUBTYPES}
|
|
452 |
* @return Instance of GeometryType associated to the Geometry
|
|
453 |
* implementation class
|
|
454 |
* geomClass
|
|
455 |
* @throws IllegalArgumentException
|
|
456 |
* If geomClass is null or does not implement Geometry
|
|
457 |
*/
|
|
458 |
public GeometryType registerGeometryType(Class geomClass, String name,
|
|
459 |
int type, int subType, int superType, int superSubType);
|
|
460 |
|
|
461 |
/**
|
|
462 |
* <p>
|
|
463 |
* Registers a Geometry implementation class with a predefined geometry type
|
|
464 |
* and returns the associated GeometryType instance. Available predefined
|
|
465 |
* types are defined in {@link Geometry.TYPES} and the subtypes are defined
|
|
466 |
* in {@link Geometry.SUBTYPES}.
|
|
467 |
* </p>
|
|
468 |
* <p>
|
|
469 |
* It adds also the super type of the geometry, that can be used to
|
|
470 |
* check if the type inherits of other type.
|
|
471 |
* </p>
|
|
472 |
* <p>
|
|
473 |
* How to register a geometry class with a predefined type:
|
|
474 |
*
|
|
475 |
* <pre>
|
|
476 |
*
|
|
477 |
* GeometryType geomType = GeometryLocator.getGeometryManager()
|
|
478 |
* .registerBasicGeometryType(Arc3D.class, "Arc3D", Geometry.TYPES.ARC,
|
|
479 |
* Geometry.SYBTYPES.GEOM3D, Geometry.TYPES.CURVE);
|
|
480 |
* </pre>
|
|
481 |
*
|
|
482 |
* </p>
|
|
483 |
*
|
|
484 |
* @param geomClass
|
|
485 |
* Geometry subclass. It must not be null and must implement
|
|
486 |
* Geometry, otherwise an exception
|
|
487 |
* is raised.
|
|
488 |
* @param name
|
|
489 |
* Symbolic name for the geometry type, it can be null. If it is
|
|
490 |
* null then the symbolic name
|
|
491 |
* will be the simple class name.
|
|
492 |
* @param type
|
|
493 |
* Type of geometry. Must be a value defined in
|
|
494 |
* {@link Geometry.TYPES}
|
|
495 |
* @param subType
|
|
496 |
* SubType of geometry. Must be a value defined in
|
|
497 |
* {@link Geometry.SUBTYPES}
|
|
498 |
* @param superType
|
|
499 |
* Super type of a geometry. Must be a value defined in
|
|
500 |
* {@link Geometry.TYPES}
|
|
501 |
* @return Instance of GeometryType associated to the Geometry
|
|
502 |
* implementation class
|
|
503 |
* geomClass
|
|
504 |
* @throws IllegalArgumentException
|
|
505 |
* If geomClass is null or does not implement Geometry
|
|
506 |
*/
|
|
507 |
public GeometryType registerGeometryType(Class geomClass, String name,
|
|
508 |
int type, int subType, int superType);
|
|
509 |
|
|
510 |
/**
|
|
511 |
* <p>
|
|
512 |
* Registers a Geometry implementation class with a predefined geometry type
|
|
513 |
* and returns the associated GeometryType instance. Available predefined
|
|
514 |
* types are defined in {@link Geometry.TYPES} and the subtypes are defined
|
|
515 |
* in {@link Geometry.SUBTYPES}.
|
|
516 |
* </p>
|
|
517 |
* <p>
|
|
518 |
* It adds also the super types and the super subTypes of the geometry, that
|
|
519 |
* can be used to check if the type (or the subtype) inherits of other
|
|
520 |
* types (or subTypes)
|
|
521 |
* </p>
|
|
522 |
* <p>
|
|
523 |
* How to register a geometry class with a predefined type:
|
|
524 |
*
|
|
525 |
* <pre>
|
|
526 |
*
|
|
527 |
* GeometryType geomType = GeometryLocator.getGeometryManager()
|
|
528 |
* .registerBasicGeometryType(Circle3DM.class, "Circle3DM", Geometry.TYPES.CIRCLE,
|
|
529 |
* Geometry.SYBTYPES.GEOM3DM,
|
|
530 |
* new int[]{Geometry.TYPES.CURVE, Geometry.TYPES.GEOMETRY},
|
|
531 |
* new int[]{Geometry.SYBTYPES.GEOM2D, Geometry.SYBTYPES.GEOM3D});
|
|
532 |
* </pre>
|
|
533 |
*
|
|
534 |
* </p>
|
|
535 |
*
|
|
536 |
* @param geomClass
|
|
537 |
* Geometry subclass. It must not be null and must implement
|
|
538 |
* Geometry, otherwise an exception
|
|
539 |
* is raised.
|
|
540 |
* @param name
|
|
541 |
* Symbolic name for the geometry type, it can be null. If it is
|
|
542 |
* null then the symbolic name
|
|
543 |
* will be the simple class name.
|
|
544 |
* @param type
|
|
545 |
* Type of geometry. Must be a value defined in
|
|
546 |
* {@link Geometry.TYPES}
|
|
547 |
* @param subType
|
|
548 |
* SubType of geometry. Must be a value defined in
|
|
549 |
* {@link Geometry.SUBTYPES}
|
|
550 |
* @param superTypes
|
|
551 |
* List of the super types of a geometry. Must be a value defined in
|
|
552 |
* {@link Geometry.TYPES}
|
|
553 |
* @param superSubTypes
|
|
554 |
* List of the super subType of a geometry. Must be a value defined in
|
|
555 |
* {@link Geometry.SUBTYPES}
|
|
556 |
* @return Instance of GeometryType associated to the Geometry
|
|
557 |
* implementation class
|
|
558 |
* geomClass
|
|
559 |
* @throws IllegalArgumentException
|
|
560 |
* If geomClass is null or does not implement Geometry
|
|
561 |
*/
|
|
562 |
public GeometryType registerGeometryType(Class geomClass, String name,
|
|
563 |
int type, int subType, int[] superTypes, int superSubTypes[]);
|
|
564 |
|
|
565 |
/**
|
|
566 |
* <p>
|
|
567 |
* Registers a Geometry implementation class with a predefined geometry type
|
|
568 |
* and returns the associated GeometryType instance. Available predefined
|
|
569 |
* types are defined in {@link Geometry.TYPES} and the subtypes are defined
|
|
570 |
* in {@link Geometry.SUBTYPES}.
|
|
571 |
* </p>
|
|
572 |
* <p>
|
|
573 |
* It adds also the super types and the super subTypes of the geometry, that
|
|
574 |
* can be used to check if the type inherits of other types.
|
|
575 |
* </p>
|
|
576 |
* <p>
|
|
577 |
* How to register a geometry class with a predefined type:
|
|
578 |
*
|
|
579 |
* <pre>
|
|
580 |
*
|
|
581 |
* GeometryType geomType = GeometryLocator.getGeometryManager()
|
|
582 |
* .registerBasicGeometryType(Circle2D.class, "Circle2DM", Geometry.TYPES.CIRCLE,
|
|
583 |
* Geometry.SYBTYPES.GEOM2D,
|
|
584 |
* new int[]{Geometry.TYPES.CURVE, Geometry.TYPES.SURFACE});
|
|
585 |
* </pre>
|
|
586 |
*
|
|
587 |
* </p>
|
|
588 |
*
|
|
589 |
* @param geomClass
|
|
590 |
* Geometry subclass. It must not be null and must implement
|
|
591 |
* Geometry, otherwise an exception
|
|
592 |
* is raised.
|
|
593 |
* @param name
|
|
594 |
* Symbolic name for the geometry type, it can be null. If it is
|
|
595 |
* null then the symbolic name
|
|
596 |
* will be the simple class name.
|
|
597 |
* @param type
|
|
598 |
* Type of geometry. Must be a value defined in
|
|
599 |
* {@link Geometry.TYPES}
|
|
600 |
* @param subType
|
|
601 |
* SubType of geometry. Must be a value defined in
|
|
602 |
* {@link Geometry.SUBTYPES}
|
|
603 |
* @param superTypes
|
|
604 |
* List of the super types of a geometry. Must be a value defined in
|
|
605 |
* {@link Geometry.TYPES}
|
|
606 |
* @return Instance of GeometryType associated to the Geometry
|
|
607 |
* implementation class
|
|
608 |
* geomClass
|
|
609 |
* @throws IllegalArgumentException
|
|
610 |
* If geomClass is null or does not implement Geometry
|
|
611 |
*/
|
|
612 |
public GeometryType registerGeometryType(Class geomClass, String name,
|
|
613 |
int type, int subType, int[] superTypes);
|
|
614 |
|
|
615 |
/**
|
|
616 |
* <p>
|
|
617 |
* Registers a Geometry implementation class with a predefined geometry type
|
|
618 |
* and returns the associated GeometryType instance. Available predefined
|
|
619 |
* types are defined in {@link Geometry.TYPES} and the subtypes are defined
|
|
620 |
* in {@link Geometry.SUBTYPES}.
|
|
621 |
* </p>
|
|
622 |
* <p>
|
|
623 |
* In this case the symbolic name will be the geometry's simple class name
|
|
624 |
* </p>
|
|
625 |
* How to register a new geometry type:
|
|
626 |
*
|
|
627 |
* <pre>
|
|
628 |
*
|
|
629 |
* GeometryType geomType = GeometryLocator.getGeometryManager()
|
|
630 |
* .registerBasicGeometryType(Point2D.class, Geometry.TYPES.POINT,
|
|
631 |
* Geometry.SYBTYPES.GEOM2D);
|
|
632 |
* </pre>
|
|
633 |
*
|
|
634 |
* @param geomClass
|
|
635 |
* Geometry implementation class. It must not be null and must
|
|
636 |
* implement Geometry,
|
|
637 |
* otherwise an exception is thrown.
|
|
638 |
* @param type
|
|
639 |
* Type of geometry. Must be a value defined in
|
|
640 |
* {@link Geometry.TYPES}
|
|
641 |
* @param subType
|
|
642 |
* SubType of geometry. Must be a value defined in
|
|
643 |
* {@link Geometry.SUBTYPES}
|
|
644 |
* @return Instance of GeometryType associated to the Geometry
|
|
645 |
* implementation class
|
|
646 |
* @throws IllegalArgumentException
|
|
647 |
* If geomClass is null or does not implement Geometry
|
|
648 |
*/
|
|
649 |
public GeometryType registerGeometryType(Class geomClass, int type,
|
|
650 |
int subType);
|
|
651 |
|
|
652 |
/**
|
|
653 |
* <p>
|
|
654 |
* Returns an instance of GeometryType given the Geometry type and the
|
|
655 |
* subtype.
|
|
656 |
* </p>
|
|
657 |
*
|
|
658 |
* @param type
|
|
659 |
* Type of geometry. Must be a value defined in
|
|
660 |
* {@link Geometry.TYPES}
|
|
661 |
* @param subType
|
|
662 |
* SubType of geometry. Must be a value defined in
|
|
663 |
* {@link Geometry.SUBTYPES}
|
|
664 |
* @return Instance of GeometryType associated to the type and the subtype
|
|
665 |
* @throws GeometryTypeNotSupportedException
|
|
666 |
* Returns this exception if there is not a registered geometry
|
|
667 |
* with
|
|
668 |
* these type and subtype
|
|
669 |
* @throws GeometryTypeNotValidException
|
|
670 |
* Returns if the type and subtype are not valid
|
|
671 |
*/
|
|
672 |
public GeometryType getGeometryType(int type, int subType)
|
|
673 |
throws GeometryTypeNotSupportedException, GeometryTypeNotValidException;
|
|
674 |
|
|
675 |
/**
|
|
676 |
* <p>
|
|
677 |
* This method creates a {@link Geometry} with the type specified by this
|
|
678 |
* GeometryType. The geometry is empty, and all the internal attributes must
|
|
679 |
* be assigned to a value when the geometry has been created.
|
|
680 |
* </p>
|
|
681 |
* <p>
|
|
682 |
* This example creates a point2D and sets the coordinates to 1,1:
|
|
683 |
*
|
|
684 |
* <pre>
|
|
685 |
* Point point =
|
|
686 |
* (Point) GeometryLocator.getGeometryManager().create(GEOMETRY.TYPES.POINT,
|
|
687 |
* GEOMETRY.SUBTYPES.GEOM2D);
|
|
688 |
* point.setX(1);
|
|
689 |
* point.setY(1);
|
|
690 |
* </pre>
|
|
691 |
*
|
|
692 |
* </p>
|
|
693 |
*
|
|
694 |
* @param geomType
|
|
695 |
* The geometry type
|
|
696 |
* @return
|
|
697 |
* A instance of a geometry.
|
|
698 |
* @throws CreateGeometryException
|
|
699 |
* This exception is thrown when the manager can not create
|
|
700 |
* the geometry.
|
|
701 |
*/
|
|
702 |
public Geometry create(GeometryType geomType)
|
|
703 |
throws CreateGeometryException;
|
|
704 |
|
|
705 |
/**
|
|
706 |
* <p>
|
|
707 |
* Creates a Envelope with a concrete subtype. The envelope is empty and it
|
|
708 |
* have to be filled with the corners once has been created.
|
|
709 |
* </p>
|
|
710 |
*
|
|
711 |
* @param subType
|
|
712 |
* SubType of envelope. Must be a value defined in
|
|
713 |
* {@link Geometry.SUBTYPES}
|
|
714 |
* @return
|
|
715 |
* A Envelope
|
|
716 |
* @throws CreateEnvelopeException
|
|
717 |
* If it is not possible to create the envelope.
|
|
718 |
*/
|
|
719 |
public Envelope createEnvelope(int subType) throws CreateEnvelopeException;
|
|
720 |
|
|
721 |
/**
|
|
722 |
* <p>
|
|
723 |
* Creates a Envelope with a concrete subtype. It sets the values for the
|
|
724 |
* lower corner and the upper corner (in 2D) using the method parameters.
|
|
725 |
* </p>
|
|
726 |
*
|
|
727 |
* @param minX
|
|
728 |
* The minimum value for the X coordinate.
|
|
729 |
* @param minY
|
|
730 |
* The minimum value for the Y coordinate.
|
|
731 |
* @param maxX
|
|
732 |
* The maximum value for the X coordinate.
|
|
733 |
* @param maxY
|
|
734 |
* The maximum value for the Y coordinate.
|
|
735 |
* @param subType
|
|
736 |
* SubType of envelope. Must be a value defined in
|
|
737 |
* {@link Geometry.SUBTYPES}
|
|
738 |
* @return
|
|
739 |
* @throws CreateEnvelopeException
|
|
740 |
*/
|
|
741 |
public Envelope createEnvelope(double minX, double minY, double maxX,
|
|
742 |
double maxY, int subType) throws CreateEnvelopeException;
|
|
743 |
|
|
744 |
/**
|
|
745 |
* <p>
|
|
746 |
* This method creates a {@link Geometry} with the type specified by this
|
|
747 |
* name. If a geometry with this name doesn't exist, a
|
|
748 |
* {@link IllegalArgumentException} is thrown. The geometry is empty, and
|
|
749 |
* all the internal attributes must be assigned to a value when the geometry
|
|
750 |
* has been created.
|
|
751 |
* </p>
|
|
752 |
* <p>
|
|
753 |
* This example creates a point2D and sets the coordinates to 1,1: It
|
|
754 |
* supposes that there is a Point2D class with name "Point2D".
|
|
755 |
* </p>
|
|
756 |
*
|
|
757 |
* <pre>
|
|
758 |
* Point point = (Point) GeometryLocator.getGeometryManager().create("Point2D");
|
|
759 |
* point.setX(1);
|
|
760 |
* point.setY(1);
|
|
761 |
* </pre>
|
|
762 |
*
|
|
763 |
* @param name
|
|
764 |
* The name of the geometry type
|
|
765 |
* @return
|
|
766 |
* A instance of a geometry.
|
|
767 |
* @throws CreateGeometryException
|
|
768 |
* This exception is thrown when the manager can not create
|
|
769 |
* the geometry.
|
|
770 |
*/
|
|
771 |
public Geometry create(String name) throws CreateGeometryException;
|
|
772 |
|
|
773 |
/**
|
|
774 |
* Create a geometry from a WKT definition.
|
|
775 |
*
|
|
776 |
* This is a utility method to wrap the invocation to the operation
|
|
777 |
* {@link OPERATIONS#FROMWKT}.
|
|
778 |
*
|
|
779 |
* @param wkt
|
|
780 |
* geometry in Well-known text format
|
|
781 |
*
|
|
782 |
* @return the geometry as a Geometry
|
|
783 |
*
|
|
784 |
* @throws CreateGeometryException
|
|
785 |
* @throws GeometryException
|
|
786 |
*/
|
|
787 |
public Geometry createFrom(String wkt, String srs)
|
|
788 |
throws CreateGeometryException, GeometryException;
|
|
789 |
|
|
790 |
public Geometry createFrom(String wkt) throws CreateGeometryException,
|
|
791 |
GeometryException;
|
|
792 |
|
|
793 |
/**
|
|
794 |
* Create a geometry from a WKB definition.
|
|
795 |
*
|
|
796 |
* This is a utility method to wrap the invocation to the operation
|
|
797 |
* {@link OPERATIONS#FROMWKB}.
|
|
798 |
*
|
|
799 |
* @param wkb
|
|
800 |
* geometry in well-known binary format
|
|
801 |
*
|
|
802 |
* @return the geometry as a Geometry
|
|
803 |
*
|
|
804 |
* @throws CreateGeometryException
|
|
805 |
* @throws GeometryException
|
|
806 |
*/
|
|
807 |
public Geometry createFrom(byte[] wkb) throws CreateGeometryException,
|
|
808 |
GeometryException;
|
|
809 |
|
|
810 |
/**
|
|
811 |
* <p>
|
|
812 |
* This method creates a {@link Geometry} with a concrete type and subtype.
|
|
813 |
* The geometry is empty, and all the internal attributes must be assigned
|
|
814 |
* to a value when the geometry has been created.
|
|
815 |
* </p>
|
|
816 |
* <p>
|
|
817 |
* This example creates a point2D and sets the coordinates to 1,1. It
|
|
818 |
* supposes that there is a Point2D class with the id 1.
|
|
819 |
* </p>
|
|
820 |
*
|
|
821 |
* <pre>
|
|
822 |
* Point point =
|
|
823 |
* (Point) GeometryLocator.getGeometryManager().create(Geometry.TYPES.POINT,
|
|
824 |
* Geometry.SYBTYPES.GEOM2D);
|
|
825 |
* point.setX(1);
|
|
826 |
* point.setY(1);
|
|
827 |
* </pre>
|
|
828 |
*
|
|
829 |
* @param type
|
|
830 |
* Type of geometry. Must be a value defined in
|
|
831 |
* {@link Geometry.TYPES}
|
|
832 |
* @param subType
|
|
833 |
* SubType of geometry. Must be a value defined in
|
|
834 |
* {@link Geometry.SUBTYPES}
|
|
835 |
* @return
|
|
836 |
* A instance of a geometry.
|
|
837 |
* @throws CreateGeometryException
|
|
838 |
* This exception is thrown when the manager can not create
|
|
839 |
* the geometry.
|
|
840 |
*/
|
|
841 |
public Geometry create(int type, int subType)
|
|
842 |
throws CreateGeometryException;
|
|
843 |
|
|
844 |
/**
|
|
845 |
* <p>
|
|
846 |
* It creates a null geometry with a concrete subtype.
|
|
847 |
* <p>
|
|
848 |
*
|
|
849 |
* @param subType
|
|
850 |
* SubType of geometry. Must be a value defined in
|
|
851 |
* {@link Geometry.SUBTYPES}
|
|
852 |
* @return
|
|
853 |
* A NullGeometry
|
|
854 |
* @throws CreateGeometryException
|
|
855 |
* This exception is thrown when the manager can not create
|
|
856 |
* the geometry.
|
|
857 |
* @deprecated use null instead. This method can be removed in next revisions
|
|
858 |
*/
|
|
859 |
public NullGeometry createNullGeometry(int subType)
|
|
860 |
throws CreateGeometryException;
|
|
861 |
|
|
862 |
/**
|
|
863 |
* <p>
|
|
864 |
* Create a new point with a concrete type and sets the value for the X and
|
|
865 |
* the Y.
|
|
866 |
* </p>
|
|
867 |
*
|
|
868 |
* @param x
|
|
869 |
* The X coordinate
|
|
870 |
* @param y
|
|
871 |
* The y coordinate
|
|
872 |
* @param subType
|
|
873 |
* SubType of geometry. Must be a value defined in
|
|
874 |
* {@link Geometry.SUBTYPES}
|
|
875 |
* @throws CreateGeometryException
|
|
876 |
* This exception is thrown when the manager can not create
|
|
877 |
* the geometry.
|
|
878 |
* @return
|
|
879 |
* The Point
|
|
880 |
*/
|
|
881 |
public Point createPoint(double x, double y, int subType)
|
|
882 |
throws CreateGeometryException;
|
|
883 |
|
|
884 |
/**
|
|
885 |
* Create a new line with a concrete type. Use later addVertex to add
|
|
886 |
* vertex to te line.
|
|
887 |
*
|
|
888 |
* @param subType SubType of geometry. Must be a value defined in {@link Geometry.SUBTYPES}
|
|
889 |
* @return a line
|
|
890 |
* @throws CreateGeometryException
|
|
891 |
* This exception is thrown when the manager can not create
|
|
892 |
* the geometry.
|
|
893 |
*/
|
|
894 |
public Line createLine(int subType) throws CreateGeometryException;
|
|
895 |
|
|
896 |
/**
|
|
897 |
* @deprecated use createLine
|
|
898 |
*/
|
|
899 |
public Curve createCurve(int subType) throws CreateGeometryException;
|
|
900 |
|
|
901 |
/**
|
|
902 |
* Create a new polygon with a concrete type.
|
|
903 |
* Use later addVertex to add vertex to te polygon.
|
|
904 |
*
|
|
905 |
* @param subType
|
|
906 |
* SubType of geometry. Must be a value defined in
|
|
907 |
* {@link Geometry.SUBTYPES}
|
|
908 |
* @return
|
|
909 |
* A polygon
|
|
910 |
* @throws CreateGeometryException
|
|
911 |
* This exception is thrown when the manager can not create
|
|
912 |
* the geometry.
|
|
913 |
*/
|
|
914 |
public Polygon createPolygon(int subType)
|
|
915 |
throws CreateGeometryException;
|
|
916 |
|
|
917 |
/**
|
|
918 |
* @deprecated use createPolygon
|
|
919 |
*/
|
|
920 |
public Surface createSurface(int subType)
|
|
921 |
throws CreateGeometryException;
|
|
922 |
|
|
923 |
/**
|
|
924 |
* Create a new multipoint with a concrete subtype.
|
|
925 |
* Use addPrimitive to populate the multipoint.
|
|
926 |
*
|
|
927 |
* @param subType
|
|
928 |
* SubType of geometry. Must be a value defined in
|
|
929 |
* {@link Geometry.SUBTYPES}
|
|
930 |
* @return A multipoint
|
|
931 |
* @throws CreateGeometryException
|
|
932 |
* This exception is thrown when the manager can not create the
|
|
933 |
* geometry.
|
|
934 |
*/
|
|
935 |
public MultiPoint createMultiPoint(int subType)
|
|
936 |
throws CreateGeometryException;
|
|
937 |
|
|
938 |
/**
|
|
939 |
* Create a new multicurve with a concrete subtype.
|
|
940 |
* Use addPrimitive to populate the multicurve.
|
|
941 |
*
|
|
942 |
* @param subType
|
|
943 |
* SubType of geometry. Must be a value defined in
|
|
944 |
* {@link Geometry.SUBTYPES}
|