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