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