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