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 / Geometry.java @ 43785
History | View | Annotate | Download (27.7 KB)
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 |
|
25 |
package org.gvsig.fmap.geom; |
26 |
|
27 |
import java.awt.Shape; |
28 |
import java.awt.geom.AffineTransform; |
29 |
import java.awt.geom.PathIterator; |
30 |
import java.awt.geom.Rectangle2D; |
31 |
import java.io.Serializable; |
32 |
|
33 |
import org.cresques.cts.ICoordTrans; |
34 |
import org.cresques.cts.IProjection; |
35 |
|
36 |
import org.gvsig.fmap.geom.aggregate.MultiLine; |
37 |
import org.gvsig.fmap.geom.aggregate.MultiPoint; |
38 |
import org.gvsig.fmap.geom.aggregate.MultiPolygon; |
39 |
import org.gvsig.fmap.geom.handler.Handler; |
40 |
import org.gvsig.fmap.geom.operation.GeometryOperationContext; |
41 |
import org.gvsig.fmap.geom.operation.GeometryOperationException; |
42 |
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException; |
43 |
import org.gvsig.fmap.geom.primitive.Envelope; |
44 |
import org.gvsig.fmap.geom.primitive.GeneralPathX; |
45 |
import org.gvsig.fmap.geom.primitive.Point; |
46 |
import org.gvsig.fmap.geom.type.GeometryType; |
47 |
|
48 |
/**
|
49 |
* <p>
|
50 |
* This interface is equivalent to the GM_Object specified in <a href="http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=26012"
|
51 |
* >ISO 19107</a>. It is the root class of the geometric object taxonomy and
|
52 |
* supports interfaces common to all geographically referenced geometric
|
53 |
* objects.
|
54 |
* </p>
|
55 |
* <p>
|
56 |
* Geometry instances are sets of direct positions in a particular coordinate
|
57 |
* reference system. A Geometry can be regarded as an infinite set of points
|
58 |
* that satisfies the set operation interfaces for a set of direct positions.
|
59 |
* </p>
|
60 |
* <p>
|
61 |
* A geometric object shall be a combination of a coordinate geometry and a
|
62 |
* coordinate reference system. In all of the operations, all geometric
|
63 |
* calculations shall be done in the coordinate reference system of the first
|
64 |
* geometric object accessed, which is normally the object whose operation is
|
65 |
* being invoked. Returned objects shall be in the coordinate reference system
|
66 |
* in which the calculations are done unless explicitly stated otherwise.
|
67 |
* </p>
|
68 |
* <p>
|
69 |
* This class extends of the {@link Shape} class by historical reasons but this
|
70 |
* inheritance will disappear in future versions.
|
71 |
* </p>
|
72 |
* @see <a href="http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=26012"
|
73 |
* >ISO 19107< /a>
|
74 |
*/
|
75 |
public interface Geometry extends Shape, Serializable, Comparable { |
76 |
|
77 |
/**
|
78 |
* Predefined geometry types in the model.
|
79 |
*/
|
80 |
public interface TYPES { |
81 |
|
82 |
/**
|
83 |
* Any geometry.
|
84 |
*/
|
85 |
|
86 |
public final static int GEOMETRY = 0; |
87 |
|
88 |
/**
|
89 |
* A geometric element that has zero dimensions and a location
|
90 |
* determinable by an ordered set of coordinates.
|
91 |
*/
|
92 |
public final static int POINT = 1; |
93 |
|
94 |
/**
|
95 |
* A straight or curved geometric element that is generated by a moving
|
96 |
* point and that has extension only along the path of the point.
|
97 |
*/
|
98 |
public final static int CURVE = 2; |
99 |
|
100 |
/**
|
101 |
* A closed plane figure bounded by straight lines.
|
102 |
*/
|
103 |
public final static int SURFACE = 3; |
104 |
|
105 |
/**
|
106 |
* Solids in 3D.
|
107 |
*/
|
108 |
public final static int SOLID = 4; |
109 |
|
110 |
/**
|
111 |
* A set that can contain points, lines and polygons. This is usual in
|
112 |
* <i>CAD</i> layers <i>(dxf, dgn, dwg)</i>.
|
113 |
*/
|
114 |
public final static int AGGREGATE = 6; |
115 |
/**
|
116 |
* A set of points.
|
117 |
*/
|
118 |
public final static int MULTIPOINT = 7; |
119 |
|
120 |
/**
|
121 |
* A set of lines.
|
122 |
*/
|
123 |
public final static int MULTICURVE = 8; |
124 |
|
125 |
/**
|
126 |
* A set of polygons.
|
127 |
*/
|
128 |
public final static int MULTISURFACE = 9; |
129 |
|
130 |
/**
|
131 |
* A set of solids.
|
132 |
*/
|
133 |
public final static int MULTISOLID = 10; |
134 |
|
135 |
/**
|
136 |
* A closed plane curve every point of which is equidistant from a fixed
|
137 |
* point within the curve.
|
138 |
*/
|
139 |
public final static int CIRCLE = 11; |
140 |
|
141 |
/**
|
142 |
* A continuous portion (as of a circle or ellipse) of a curved line.
|
143 |
*/
|
144 |
public final static int ARC = 12; |
145 |
|
146 |
/**
|
147 |
* A closed plane curve generated by a point moving in such a way that
|
148 |
* the sums of its distances from two fixed points is a constant : a
|
149 |
* plane section of a right circular cone that is a closed curve.
|
150 |
*/
|
151 |
public final static int ELLIPSE = 13; |
152 |
|
153 |
public final static int SPLINE = 14; |
154 |
|
155 |
public final static int ELLIPTICARC = 15; |
156 |
|
157 |
/**
|
158 |
* NO DATA geometry.
|
159 |
*/
|
160 |
public final static int NULL = 16; |
161 |
|
162 |
public final static int COMPLEX = 17; |
163 |
|
164 |
public final static int LINE = 18; |
165 |
|
166 |
public final static int POLYGON = 19; |
167 |
|
168 |
public final static int RING = 20; |
169 |
|
170 |
public final static int MULTILINE = 21; |
171 |
|
172 |
public final static int MULTIPOLYGON = 22; |
173 |
|
174 |
public final static int CIRCUMFERENCE = 23; |
175 |
|
176 |
public final static int PERIELLIPSE = 24; |
177 |
|
178 |
public final static int FILLEDSPLINE = 25; |
179 |
|
180 |
} |
181 |
|
182 |
public interface DIMENSIONS { |
183 |
public final static int X = 0; |
184 |
public final static int Y = 1; |
185 |
public final static int Z = 2; |
186 |
} |
187 |
|
188 |
/**
|
189 |
* The subtype of a geometry is related with the dimension of the geometry,
|
190 |
* that is a combination between the spatial dimension (2D, 2ZD, 3D) and the
|
191 |
* M coordinate or "measure".
|
192 |
*
|
193 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
|
194 |
*/
|
195 |
public interface SUBTYPES { |
196 |
|
197 |
/**
|
198 |
* Geometries with two dimensions.
|
199 |
*/
|
200 |
public final static int GEOM2D = 0; |
201 |
|
202 |
/**
|
203 |
* Geometries with three dimensions.
|
204 |
*/
|
205 |
public final static int GEOM3D = 1; |
206 |
|
207 |
/**
|
208 |
* Geometries with two dimensions and with the M coordinate.
|
209 |
*/
|
210 |
public final static int GEOM2DM = 2; |
211 |
|
212 |
/**
|
213 |
* Geometries with three dimensions and with the M coordinate.
|
214 |
*/
|
215 |
public final static int GEOM3DM = 3; |
216 |
|
217 |
/**
|
218 |
* The subtype us unknown.
|
219 |
*/
|
220 |
public final static int UNKNOWN = 4; |
221 |
} |
222 |
|
223 |
/**
|
224 |
* Initial value for new geometry types (it must not overlap with the basic
|
225 |
* ones defined in TYPES).
|
226 |
*/
|
227 |
public static final int EXTENDED_GEOMTYPE_OFFSET = 17; |
228 |
|
229 |
/**
|
230 |
* Initial value for new geometry subtypes (it must not overlap with the
|
231 |
* basic ones defined in SUBTYPES).
|
232 |
*/
|
233 |
public static final int EXTENDED_GEOMSUBTYPE_OFFSET = 6; |
234 |
|
235 |
public interface OPERATIONS { |
236 |
public final static String CONVERTTOWKT = "toWKT"; |
237 |
public final static String CONVERTTOWKB = "toWKB"; |
238 |
public final static String BUFFER = "buffer"; |
239 |
public final static String DISTANCE = "Distance"; |
240 |
public final static String CONTAINS = "Contains"; |
241 |
public final static String OVERLAPS = "OVERLAPS"; |
242 |
public final static String CONVEXHULL = "ConvexHull"; |
243 |
public final static String COVERS = "Covers"; |
244 |
public final static String CROSSES = "Crosses"; |
245 |
public final static String DIFFERENCE = "Difference"; |
246 |
public final static String DISJOIN = "Disjoin"; |
247 |
public final static String INTERSECTION = "Intersaction"; |
248 |
public final static String INTERSECTS = "Intersects"; |
249 |
public final static String TOUCHES = "Touches"; |
250 |
public final static String UNION = "Union"; |
251 |
public final static String WITHIN = "Within"; |
252 |
public final static String COVEREDBY = "CoveredBy"; |
253 |
} |
254 |
|
255 |
public interface ValidationStatus { |
256 |
|
257 |
public static final int VALID = 0; |
258 |
public static final int CURRUPTED = 1; |
259 |
public static final int UNKNOW = 2; |
260 |
public static final int DISCONNECTED_INTERIOR = 10; |
261 |
public static final int DUPLICATE_RINGS = 11; |
262 |
public static final int HOLE_OUTSIDE_SHELL = 12; |
263 |
public static final int INVALID_COORDINATE = 13; |
264 |
public static final int NESTED_HOLES = 14; |
265 |
public static final int NESTED_SHELLS = 15; |
266 |
public static final int RING_NOT_CLOSED = 17; |
267 |
public static final int RING_SELF_INTERSECTION = 18; |
268 |
public static final int SELF_INTERSECTION = 19; |
269 |
public static final int TOO_FEW_POINTS = 20; |
270 |
|
271 |
/**
|
272 |
* True if the geoemtry are valid.
|
273 |
*
|
274 |
* @return true form valid geometries
|
275 |
*/
|
276 |
public boolean isValid(); |
277 |
|
278 |
/**
|
279 |
* Return the status code results of validate the geometry.
|
280 |
*
|
281 |
* @return validation code
|
282 |
*/
|
283 |
public int getStatusCode(); |
284 |
|
285 |
/**
|
286 |
* Return the nearest point to the problem when validate the geometry.
|
287 |
*
|
288 |
* If the geometry is valid, this return null.
|
289 |
*
|
290 |
* @return the nearest point to the problem or null.
|
291 |
*/
|
292 |
public Point getProblemLocation(); |
293 |
|
294 |
/**
|
295 |
* Return a human readable message explaining the cause of the problem.
|
296 |
*
|
297 |
* If the geometry is valid this is null.
|
298 |
*
|
299 |
* @return the message cause of the problem.
|
300 |
*/
|
301 |
public String getMessage(); |
302 |
} |
303 |
|
304 |
public static int BEST = 0; |
305 |
/**
|
306 |
* North.
|
307 |
*/
|
308 |
public static int N = 1; |
309 |
|
310 |
/**
|
311 |
* North - East.
|
312 |
*/
|
313 |
public static int NE = 2; |
314 |
|
315 |
/**
|
316 |
* East.
|
317 |
*/
|
318 |
public static int E = 3; |
319 |
|
320 |
/**
|
321 |
* South - East.
|
322 |
*/
|
323 |
public static int SE = 4; |
324 |
|
325 |
/**
|
326 |
* South.
|
327 |
*/
|
328 |
public static int S = 5; |
329 |
|
330 |
/**
|
331 |
* South - West.
|
332 |
*/
|
333 |
public static int SW = 6; |
334 |
|
335 |
/**
|
336 |
* West.
|
337 |
*/
|
338 |
public static int W = 7; |
339 |
|
340 |
/**
|
341 |
* North - West.
|
342 |
*/
|
343 |
public static int NW = 8; |
344 |
|
345 |
public static int SELECTHANDLER = 0; |
346 |
public static int STRETCHINGHANDLER = 1; |
347 |
|
348 |
/**
|
349 |
* If this geometry is a predefined interface then this method returns one
|
350 |
* of {@link Geometry.TYPES} contants.<br>
|
351 |
* If this geometry is an extended type then this method returns a runtime
|
352 |
* constant that identifies its type. By convention this value is stored in
|
353 |
* a constant called .CODE within the geometry class, for instance:
|
354 |
* Point2D.CODE.
|
355 |
*
|
356 |
* @return If this geometry is a predefined interface then one of
|
357 |
* {@link Geometry.TYPES} or a runtime constant if it is an extended
|
358 |
* type.
|
359 |
*/
|
360 |
public int getType(); |
361 |
|
362 |
/**
|
363 |
* Creates a clone of this geometry.
|
364 |
*
|
365 |
* @return A clone of this geometry.
|
366 |
*/
|
367 |
public Geometry cloneGeometry();
|
368 |
|
369 |
/**
|
370 |
* Returns true if this geometry intersects the rectangle passed as
|
371 |
* parameter.
|
372 |
*
|
373 |
* @param r
|
374 |
* Rectangle.
|
375 |
*
|
376 |
* @return True, if <code>this</code> intersects <code>r</code>.
|
377 |
*/
|
378 |
public boolean intersects(Rectangle2D r); |
379 |
|
380 |
/**
|
381 |
* Used by the drawing strategies to quickly test whether this geometry
|
382 |
* intersects with the visible rectangle.
|
383 |
*
|
384 |
* @param x
|
385 |
* The minimum X coordinate.
|
386 |
* @param y
|
387 |
* The minimum Y coordinate.
|
388 |
* @param w
|
389 |
* The width of the envelope.
|
390 |
* @param h
|
391 |
* The height of the envelope.
|
392 |
* @return true if <code>this</code> intersects the rectangle defined by the
|
393 |
* parameters.
|
394 |
*/
|
395 |
public boolean fastIntersects(double x, double y, double w, double h); |
396 |
|
397 |
/**
|
398 |
* <p>
|
399 |
* Returns the minimum bounding box for this Geometry. This shall be the
|
400 |
* coordinate region spanning the minimum and maximum value for each
|
401 |
* ordinate taken on by DirectPositions in this Geometry. The simplest
|
402 |
* representation for an envelope consists of two DirectPositions, the first
|
403 |
* one containing all the minimums for each ordinate, and second one
|
404 |
* containing all the maximums.
|
405 |
* </p>
|
406 |
*
|
407 |
* @return The minimum bounding box for this Geometry.
|
408 |
*/
|
409 |
public Envelope getEnvelope();
|
410 |
|
411 |
/**
|
412 |
* Reprojects this geometry by the coordinate transformer passed as
|
413 |
* parameter.
|
414 |
*
|
415 |
* @param ct
|
416 |
* Coordinate Transformer.
|
417 |
*/
|
418 |
public void reProject(ICoordTrans ct); |
419 |
|
420 |
/**
|
421 |
* It applies an affine transformation to the geometry.
|
422 |
* If parameter value is null, it will be considered an
|
423 |
* empty transformation, therefore equivalent to the identity
|
424 |
* transformation.
|
425 |
*
|
426 |
* @param at
|
427 |
* The transformation to apply.
|
428 |
*/
|
429 |
public void transform(AffineTransform at); |
430 |
/**
|
431 |
* Returns the largest number n such that each direct position in a
|
432 |
* geometric set can be associated with a subset that has the direct
|
433 |
* position in its interior and is similar (isomorphic) to Rn, Euclidean
|
434 |
* n-space.
|
435 |
*
|
436 |
* @return The dimension.
|
437 |
*/
|
438 |
public int getDimension(); |
439 |
|
440 |
/**
|
441 |
* Returns <code>true</code> if this Geometry has no interior point of
|
442 |
* self-intersection or self-tangency. In mathematical formalisms, this
|
443 |
* means that every point in the interior of the object must have a metric
|
444 |
* neighborhood whose intersection with the object is isomorphic to an
|
445 |
* n-sphere, where n is the dimension of this Geometry.
|
446 |
*
|
447 |
* @return If the geometry is simple.
|
448 |
*/
|
449 |
public boolean isSimple(); |
450 |
|
451 |
public boolean isCCW() |
452 |
throws GeometryOperationNotSupportedException,
|
453 |
GeometryOperationException; |
454 |
|
455 |
/**
|
456 |
* Invokes a geometry operation given its index and context.
|
457 |
*
|
458 |
* @param index
|
459 |
* Unique index of the operation. Operation code.
|
460 |
* @param ctx
|
461 |
* The context of the geometry operation.
|
462 |
* @return Object returned by the operation.
|
463 |
* @throws GeometryOperationNotSupportedException
|
464 |
* It is thrown when the operation has been not registered for
|
465 |
* this geometry.
|
466 |
* @throws GeometryOperationException
|
467 |
* It is thrown when there is an error executing the operation.
|
468 |
*/
|
469 |
public Object invokeOperation(int index, GeometryOperationContext ctx) |
470 |
throws GeometryOperationNotSupportedException,
|
471 |
GeometryOperationException; |
472 |
|
473 |
/**
|
474 |
* Invokes a geometry operation given its name and context.
|
475 |
*
|
476 |
* @param opName
|
477 |
* Operation name.
|
478 |
* @param ctx
|
479 |
* The context of the geometry operation.
|
480 |
* @return Object returned by the operation.
|
481 |
* @throws GeometryOperationNotSupportedException
|
482 |
* It is thrown when the operation has been not registered for
|
483 |
* this geometry.
|
484 |
* @throws GeometryOperationException
|
485 |
* It is thrown when there is an error executing the operation.
|
486 |
*/
|
487 |
public Object invokeOperation(String opName, GeometryOperationContext ctx) |
488 |
throws GeometryOperationNotSupportedException,
|
489 |
GeometryOperationException; |
490 |
|
491 |
/**
|
492 |
* Instance of the GeometryType associated to this geometry.
|
493 |
*
|
494 |
* @return The geometry type.
|
495 |
*/
|
496 |
public GeometryType getGeometryType();
|
497 |
|
498 |
/**
|
499 |
* Return a byte array with the equivalent in WKB format of the Geometry.
|
500 |
*
|
501 |
* Utility method to wrap the invocation to the operation
|
502 |
* {@link OPERATIONS#CONVERTTOWKB}.
|
503 |
*
|
504 |
* @return the WKB version of the geometry
|
505 |
*/
|
506 |
public byte[] convertToWKB() throws GeometryOperationNotSupportedException, |
507 |
GeometryOperationException; |
508 |
|
509 |
public byte[] convertToWKB(int srs) |
510 |
throws GeometryOperationNotSupportedException, GeometryOperationException;
|
511 |
|
512 |
public byte[] convertToWKBForcingType(int srs, int type) |
513 |
throws GeometryOperationNotSupportedException, GeometryOperationException;
|
514 |
|
515 |
/**
|
516 |
* Return a byte array with the equivalent in EWKB format of the Geometry.
|
517 |
*
|
518 |
* Utility method to wrap the invocation to the operation
|
519 |
* {@link OPERATIONS#CONVERTTOEWKB}.
|
520 |
*
|
521 |
* @return the EWKB version of the geometry
|
522 |
*/
|
523 |
public byte[] convertToEWKB() throws GeometryOperationNotSupportedException, GeometryOperationException; |
524 |
|
525 |
public byte[] convertToEWKB(int srs) |
526 |
throws GeometryOperationNotSupportedException, GeometryOperationException;
|
527 |
|
528 |
public byte[] convertToEWKBForcingType(int srs, int type) |
529 |
throws GeometryOperationNotSupportedException, GeometryOperationException;
|
530 |
|
531 |
|
532 |
/**
|
533 |
* Return a string with the equivalent in WKT format of the Geometry.
|
534 |
*
|
535 |
* This is a utility method to wrap the invocation to the operation
|
536 |
* {@link OPERATIONS#CONVERTTOWKT}.
|
537 |
*
|
538 |
* @return the WKT version of the geometry.
|
539 |
*
|
540 |
* @throws GeometryOperationNotSupportedException
|
541 |
* @throws GeometryOperationException
|
542 |
*/
|
543 |
public String convertToWKT() throws GeometryOperationNotSupportedException, |
544 |
GeometryOperationException; |
545 |
|
546 |
/**
|
547 |
* Computes a buffer area around this geometry having the given width
|
548 |
*
|
549 |
* This is a utility method to wrap the invocation to the operation
|
550 |
* {@link OPERATIONS#BUFFER}.
|
551 |
*
|
552 |
* @param distance
|
553 |
* the width of the buffer
|
554 |
*
|
555 |
* @return a new Geometry with the computed buffer.
|
556 |
*
|
557 |
* @throws GeometryOperationNotSupportedException
|
558 |
* @throws GeometryOperationException
|
559 |
*/
|
560 |
public Geometry buffer(double distance) |
561 |
throws GeometryOperationNotSupportedException,
|
562 |
GeometryOperationException; |
563 |
|
564 |
public Geometry offset(double distance) |
565 |
throws GeometryOperationNotSupportedException,
|
566 |
GeometryOperationException; |
567 |
|
568 |
/**
|
569 |
* Tests whether this geometry contains the specified geometry.
|
570 |
*
|
571 |
* This is a utility method to wrap the invocation to the operation
|
572 |
* {@link OPERATIONS#CONTAINS}.
|
573 |
*
|
574 |
* @param geometry
|
575 |
* the Geometry with which to compare this Geometry
|
576 |
*
|
577 |
* @return if this Geometry contains the specified geometry
|
578 |
*
|
579 |
* @throws GeometryOperationNotSupportedException
|
580 |
* @throws GeometryOperationException
|
581 |
*/
|
582 |
public boolean contains(Geometry geometry) |
583 |
throws GeometryOperationNotSupportedException,
|
584 |
GeometryOperationException; |
585 |
|
586 |
/**
|
587 |
* Returns the minimum distance between this Geometry and the specified
|
588 |
* geometry.
|
589 |
*
|
590 |
* This is a utility method to wrap the invocation to the operation
|
591 |
* {@link OPERATIONS#DISTANCE}.
|
592 |
*
|
593 |
* @param geometry
|
594 |
* the Geometry from which to compute the distance
|
595 |
*
|
596 |
* @return the distance between the geometries
|
597 |
*
|
598 |
* @throws GeometryOperationNotSupportedException
|
599 |
* @throws GeometryOperationException
|
600 |
*/
|
601 |
public double distance(Geometry other) |
602 |
throws GeometryOperationNotSupportedException,
|
603 |
GeometryOperationException; |
604 |
|
605 |
public Geometry[] closestPoints(Geometry other) |
606 |
throws GeometryOperationNotSupportedException,
|
607 |
GeometryOperationException; |
608 |
|
609 |
boolean isWithinDistance(Geometry other, double distance) |
610 |
throws GeometryOperationNotSupportedException,
|
611 |
GeometryOperationException; |
612 |
|
613 |
/**
|
614 |
* Tests whether this geometry overlaps the specified geometry.
|
615 |
*
|
616 |
* This is a utility method to wrap the invocation to the operation
|
617 |
* {@link OPERATIONS#OVERLAPS}.
|
618 |
*
|
619 |
* @param geometry
|
620 |
* the Geometry with which to compare this Geometry
|
621 |
*
|
622 |
* @return true if the two geometries overlap.
|
623 |
*
|
624 |
* @throws GeometryOperationNotSupportedException
|
625 |
* @throws GeometryOperationException
|
626 |
*/
|
627 |
public boolean overlaps(Geometry geometry) |
628 |
throws GeometryOperationNotSupportedException,
|
629 |
GeometryOperationException; |
630 |
|
631 |
public Geometry convexHull() throws GeometryOperationNotSupportedException, |
632 |
GeometryOperationException; |
633 |
|
634 |
public boolean coveredBy(Geometry geometry) |
635 |
throws GeometryOperationNotSupportedException,
|
636 |
GeometryOperationException; |
637 |
|
638 |
public boolean covers(Geometry geometry) |
639 |
throws GeometryOperationNotSupportedException,
|
640 |
GeometryOperationException; |
641 |
|
642 |
public boolean crosses(Geometry geometry) |
643 |
throws GeometryOperationNotSupportedException,
|
644 |
GeometryOperationException; |
645 |
|
646 |
public Geometry difference(Geometry other)
|
647 |
throws GeometryOperationNotSupportedException,
|
648 |
GeometryOperationException; |
649 |
|
650 |
public boolean disjoint(Geometry geometry) |
651 |
throws GeometryOperationNotSupportedException,
|
652 |
GeometryOperationException; |
653 |
|
654 |
public Geometry intersection(Geometry other)
|
655 |
throws GeometryOperationNotSupportedException,
|
656 |
GeometryOperationException; |
657 |
|
658 |
public boolean intersects(Geometry geometry) |
659 |
throws GeometryOperationNotSupportedException,
|
660 |
GeometryOperationException; |
661 |
|
662 |
public Geometry snapTo(Geometry other, double snapTolerance) |
663 |
throws GeometryOperationNotSupportedException,
|
664 |
GeometryOperationException; |
665 |
|
666 |
public boolean touches(Geometry geometry) |
667 |
throws GeometryOperationNotSupportedException,
|
668 |
GeometryOperationException; |
669 |
|
670 |
public Geometry union(Geometry other)
|
671 |
throws GeometryOperationNotSupportedException,
|
672 |
GeometryOperationException; |
673 |
|
674 |
public boolean within(Geometry geometry) |
675 |
throws GeometryOperationNotSupportedException,
|
676 |
GeometryOperationException; |
677 |
|
678 |
public Point centroid() throws GeometryOperationNotSupportedException, GeometryOperationException; |
679 |
|
680 |
/**
|
681 |
* This method returns a point which is inside the geometry.
|
682 |
* This is useful for mathematical purposes but it is very unlikely
|
683 |
* to be a suitable place for a label, for example.
|
684 |
*
|
685 |
*
|
686 |
* @return an interior point
|
687 |
* @throws GeometryOperationNotSupportedException
|
688 |
* @throws GeometryOperationException
|
689 |
*/
|
690 |
public Point getInteriorPoint() throws GeometryOperationNotSupportedException, GeometryOperationException; |
691 |
|
692 |
public double area() throws GeometryOperationNotSupportedException, GeometryOperationException; |
693 |
|
694 |
public double perimeter() throws GeometryOperationNotSupportedException, GeometryOperationException; |
695 |
|
696 |
|
697 |
|
698 |
|
699 |
/**
|
700 |
* Rotates the geometry by radAngle radians using the given
|
701 |
* coordinates as center of rotation. Rotating with a positive
|
702 |
* angle rotates points on the positive x axis toward the
|
703 |
* positive y axis. In most cases, we assume x increases
|
704 |
* rightwards and y increases upwards, so in most cases,
|
705 |
* a positive angle will mean counter-clockwise rotation.
|
706 |
*
|
707 |
* @param radAngle the amount of rotation, in radians
|
708 |
* @param basex x coordinate of center of rotation
|
709 |
* @param basey y coordinate of center of rotation
|
710 |
*/
|
711 |
public void rotate(double radAngle, double basex, double basey); |
712 |
|
713 |
/**
|
714 |
* Shifts geometry by given amount in x and y axes
|
715 |
*
|
716 |
* @param dx
|
717 |
* @param dy
|
718 |
*/
|
719 |
public void move(double dx, double dy); |
720 |
|
721 |
|
722 |
/**
|
723 |
* Scales geometry in x and y axes by given scale factors
|
724 |
* using the given point as center of projection.
|
725 |
*
|
726 |
* @param basePoint
|
727 |
* @param sx scale factor in x axis
|
728 |
* @param sy scale factor in y axis
|
729 |
*/
|
730 |
public void scale(Point basePoint, double sx, double sy); |
731 |
|
732 |
/**
|
733 |
* Check if the geometry is valid.
|
734 |
*
|
735 |
* @return true if the geometry is valid.
|
736 |
*/
|
737 |
public boolean isValid(); |
738 |
|
739 |
/**
|
740 |
* Check if the geometry is valid and returns the validation status.
|
741 |
*
|
742 |
* @return the ValidationStatus
|
743 |
*/
|
744 |
public ValidationStatus getValidationStatus();
|
745 |
|
746 |
/**
|
747 |
* Try to fix the geometry and return the new geometry.
|
748 |
* If the geometry is valid return the same geometry.
|
749 |
* If the geometry is corrupt or can't fix it, return null.
|
750 |
*
|
751 |
* @return the new fixed geometry
|
752 |
*/
|
753 |
public Geometry makeValid();
|
754 |
|
755 |
//
|
756 |
// ===============================================
|
757 |
//
|
758 |
|
759 |
|
760 |
/**
|
761 |
* @return the awt shape used to display the geometry. It
|
762 |
* applies a tranformation before to return the coordinates
|
763 |
* of the shape
|
764 |
* @deprecated this class inherits of {@link Shape} by historical
|
765 |
* reasons. This method has been added just to control the usage of
|
766 |
* the {@link Shape} class but it will removed in a future.
|
767 |
*/
|
768 |
public Shape getShape(AffineTransform affineTransform); |
769 |
|
770 |
/**
|
771 |
* @return the awt shape used to display the geometry.
|
772 |
* @deprecated this class inherits of {@link Shape} by historical
|
773 |
* reasons. This method has been added just to control the usage of
|
774 |
* the {@link Shape} class but it will removed in a future.
|
775 |
*/
|
776 |
public Shape getShape(); |
777 |
|
778 |
/**
|
779 |
* Returns this geometry's boundary rectangle.
|
780 |
*
|
781 |
* @deprecated use getEnvelope.
|
782 |
* @return Boundary rectangle.
|
783 |
*/
|
784 |
public Rectangle2D getBounds2D(); |
785 |
|
786 |
/**
|
787 |
* If applies an affine transformation and returns the GeneralPathXIterator
|
788 |
* with this geometry's information.
|
789 |
*
|
790 |
* @param at
|
791 |
* The transformation to apply.
|
792 |
* @return The GeneralPathXIterator with this geometry's information.
|
793 |
* @deprecated don't use PathIterator over geometries, use instead specific API for each operation. If not has API for that operation let the project team.
|
794 |
*
|
795 |
*/
|
796 |
public PathIterator getPathIterator(AffineTransform at); |
797 |
|
798 |
/**
|
799 |
* It returns the handlers of the geometry, these they can be of two types
|
800 |
* is straightening and of selection.
|
801 |
*
|
802 |
* @param type
|
803 |
* Type of handlers.
|
804 |
*
|
805 |
* @deprecated don't use Handlers over geometries, use instead specific API for each operation. If not has API for that operation let the project team.
|
806 |
* @return The handlers.
|
807 |
*/
|
808 |
public Handler[] getHandlers(int type); |
809 |
|
810 |
|
811 |
/**
|
812 |
* If applies an affine transformation and returns the GeneralPathXIterator
|
813 |
* with this geometry's information.
|
814 |
*
|
815 |
* @param at
|
816 |
* The affine transformation.
|
817 |
* @param flatness
|
818 |
*
|
819 |
* @return The GeneralPathXIterator with this geometry's information.
|
820 |
* @deprecated don't use PathIterator over geometries, use instead specific API for each operation. If not has API for that operation let the project team.
|
821 |
*/
|
822 |
@Override
|
823 |
PathIterator getPathIterator(AffineTransform at, double flatness); |
824 |
|
825 |
/**
|
826 |
* Useful to have the real shape behind the scenes. May be uses to edit it
|
827 |
* knowing it it is a Circle, Ellipse, etc.
|
828 |
*
|
829 |
* @return The awt shape
|
830 |
* @deprecated
|
831 |
*/
|
832 |
public Shape getInternalShape(); |
833 |
|
834 |
|
835 |
/**
|
836 |
* Get GeneralPathIterator, to do registered operations to it.
|
837 |
*
|
838 |
* @return The GeneralPathX.
|
839 |
* @deprecated don't use GeneralPathX over geometries, use instead specific API for each operation. If not has API for that operation let the project team.
|
840 |
*/
|
841 |
public GeneralPathX getGeneralPath();
|
842 |
|
843 |
|
844 |
/**
|
845 |
* Converts the geometry to be points and makes with them a multiPoint
|
846 |
*
|
847 |
* @return MultiPoint
|
848 |
* @throws GeometryException
|
849 |
*/
|
850 |
public MultiPoint toPoints() throws GeometryException; |
851 |
|
852 |
/**
|
853 |
* Converts the geometry to be lines and makes with them a multiLine
|
854 |
* @return
|
855 |
* @throws GeometryException
|
856 |
*/
|
857 |
public MultiLine toLines() throws GeometryException; |
858 |
|
859 |
/**
|
860 |
* Converts the geometry to be polygons and makes with them a multiPolygon
|
861 |
* @return
|
862 |
* @throws GeometryException
|
863 |
*/
|
864 |
public MultiPolygon toPolygons() throws GeometryException; |
865 |
|
866 |
/**
|
867 |
* Flip the coordinates of the geometry.
|
868 |
* If the geometry is aggregate also revert the primitives collection.
|
869 |
*
|
870 |
* @throws GeometryOperationNotSupportedException
|
871 |
* @throws GeometryOperationException
|
872 |
*/
|
873 |
public void flip() throws GeometryOperationNotSupportedException, GeometryOperationException; |
874 |
|
875 |
/**
|
876 |
* Ensures the orientation of the geometry according to the parameter, flipping it if necessary.
|
877 |
* If the geometry is a polygon, ensures the orientation of its perimeter
|
878 |
* and ensures the opposite orientation of their holes.
|
879 |
*
|
880 |
* @param ccw
|
881 |
* @return
|
882 |
* @throws GeometryOperationNotSupportedException
|
883 |
* @throws GeometryOperationException
|
884 |
*/
|
885 |
public boolean ensureOrientation(boolean ccw) throws GeometryOperationNotSupportedException, GeometryOperationException; |
886 |
|
887 |
/**
|
888 |
* Returns true if passed as a parameter geometry is completely out of geometry.
|
889 |
*
|
890 |
* @param geometry
|
891 |
* @return
|
892 |
* @throws GeometryOperationNotSupportedException
|
893 |
* @throws GeometryOperationException
|
894 |
*/
|
895 |
public boolean out(Geometry geometry) throws GeometryOperationNotSupportedException, GeometryOperationException; |
896 |
|
897 |
/**
|
898 |
* Return true if the geometry can be transformed by the affine transform
|
899 |
*
|
900 |
* @param at the affine transform
|
901 |
* @return
|
902 |
*/
|
903 |
public boolean canBeTransformed(AffineTransform at); |
904 |
|
905 |
/**
|
906 |
* Return true if the geometry can be reprojected by the coordinate transformation
|
907 |
*
|
908 |
* @param ct the coordinate transformation
|
909 |
* @return
|
910 |
*/
|
911 |
public boolean canBeReprojected(ICoordTrans ct); |
912 |
|
913 |
public void setProjection(IProjection projection); |
914 |
|
915 |
public void setProjectionIffNull(IProjection projection); |
916 |
|
917 |
public IProjection getProjection();
|
918 |
} |