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