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