root / branches / v2_0_0_prep / libraries / libFMap_geometries / src / org / gvsig / fmap / geom / Geometry.java @ 31020
History | View | Annotate | Download (12.2 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
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 2
|
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 |
*/
|
22 |
|
23 |
/*
|
24 |
* AUTHORS (In addition to CIT):
|
25 |
* 2009 {Iver T.I.} {Task}
|
26 |
*/
|
27 |
|
28 |
package org.gvsig.fmap.geom; |
29 |
|
30 |
import java.awt.Shape; |
31 |
import java.awt.geom.AffineTransform; |
32 |
import java.awt.geom.PathIterator; |
33 |
import java.awt.geom.Rectangle2D; |
34 |
import java.io.Serializable; |
35 |
|
36 |
import org.cresques.cts.ICoordTrans; |
37 |
import org.gvsig.fmap.geom.handler.Handler; |
38 |
import org.gvsig.fmap.geom.operation.GeometryOperationContext; |
39 |
import org.gvsig.fmap.geom.operation.GeometryOperationException; |
40 |
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException; |
41 |
import org.gvsig.fmap.geom.primitive.Envelope; |
42 |
import org.gvsig.fmap.geom.primitive.GeneralPathX; |
43 |
import org.gvsig.fmap.geom.type.GeometryType; |
44 |
|
45 |
/**
|
46 |
* <p>
|
47 |
* This interface is equivalent to the GM_Object specified in
|
48 |
* <a href="http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=26012">ISO 19107</a>.
|
49 |
* It is the root class of the geometric object taxonomy and supports
|
50 |
* interfaces common to all geographically referenced geometric objects.
|
51 |
* </p>
|
52 |
* <p>
|
53 |
* Geometry instances are sets of direct positions in a particular
|
54 |
* coordinate reference system. A Geometry can be regarded as an
|
55 |
* infinite set of points that satisfies the set operation interfaces
|
56 |
* for a set of direct positions.
|
57 |
* </p>
|
58 |
* <p>
|
59 |
* A geometric object shall be a combination of a coordinate geometry
|
60 |
* and a coordinate reference system. In all of the operations,
|
61 |
* all geometric calculations shall be done in the coordinate
|
62 |
* reference system of the first geometric object accessed,
|
63 |
* which is normally the object whose operation is being invoked.
|
64 |
* Returned objects shall be in the coordinate reference system in which
|
65 |
* the calculations are done unless explicitly stated otherwise.
|
66 |
* </p>
|
67 |
* @see <a href="http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=26012">ISO 19107</a>
|
68 |
*/
|
69 |
public interface Geometry extends Shape, Serializable, Comparable { |
70 |
|
71 |
/**
|
72 |
* Predefined geometry types in the model.
|
73 |
*/
|
74 |
public interface TYPES { |
75 |
|
76 |
/**
|
77 |
* Any geometry.
|
78 |
*/
|
79 |
|
80 |
public final static int GEOMETRY = 0; |
81 |
|
82 |
/**
|
83 |
* A geometric element that has zero dimensions and a location determinable by an ordered set
|
84 |
* of coordinates.
|
85 |
*/
|
86 |
public final static int POINT = 1; |
87 |
|
88 |
/**
|
89 |
* A straight or curved geometric element that is generated by a moving point and that has extension
|
90 |
* only along the path of the point.
|
91 |
*/
|
92 |
public final static int CURVE = 2; |
93 |
|
94 |
/**
|
95 |
* A closed plane figure bounded by straight lines.
|
96 |
*/
|
97 |
public final static int SURFACE = 3; |
98 |
|
99 |
/**
|
100 |
* Solids in 3D.
|
101 |
*/
|
102 |
public final static int SOLID = 4; |
103 |
|
104 |
/**
|
105 |
* Words, symbols and form of a written or printed work.
|
106 |
*/
|
107 |
public final static int TEXT = 5; |
108 |
|
109 |
/**
|
110 |
* A set that can contain points, lines and polygons. This is usual in <i>CAD</i> layers <i>(dxf, dgn, dwg)</i>.
|
111 |
*/
|
112 |
public final static int AGGREGATE = 6; |
113 |
/**
|
114 |
* A set of points.
|
115 |
*/
|
116 |
public final static int MULTIPOINT = 7; |
117 |
|
118 |
/**
|
119 |
* A set of lines.
|
120 |
*/
|
121 |
public final static int MULTICURVE = 8; |
122 |
|
123 |
/**
|
124 |
* A set of polygons.
|
125 |
*/
|
126 |
public final static int MULTISURFACE = 9; |
127 |
|
128 |
/**
|
129 |
* A set of solids.
|
130 |
*/
|
131 |
public final static int MULTISOLID = 10; |
132 |
|
133 |
/**
|
134 |
* A closed plane curve every point of which is equidistant from a fixed point within the curve.
|
135 |
*/
|
136 |
public final static int CIRCLE = 11; |
137 |
|
138 |
/**
|
139 |
* A continuous portion (as of a circle or ellipse) of a curved line.
|
140 |
*/
|
141 |
public final static int ARC = 12; |
142 |
|
143 |
/**
|
144 |
* A closed plane curve generated by a point moving in such a way that the sums of its distances
|
145 |
* from two fixed points is a constant : a plane section of a right circular cone that is a closed
|
146 |
* curve.
|
147 |
*/
|
148 |
public final static int ELLIPSE = 13; |
149 |
|
150 |
public final static int SPLINE = 14; |
151 |
|
152 |
public final static int ELLIPTICARC = 15; |
153 |
|
154 |
/**
|
155 |
* NO DATA geometry.
|
156 |
*/
|
157 |
public final static int NULL = 16; |
158 |
} |
159 |
|
160 |
/**
|
161 |
* The subtype of a geometry is related with the dimension
|
162 |
* of the geometry, that is a combination between the
|
163 |
* spatial dimension (2D, 2ZD, 3D) and the M coordinate
|
164 |
* or "measure".
|
165 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
|
166 |
*/
|
167 |
public interface SUBTYPES{ |
168 |
|
169 |
/**
|
170 |
* Geometries with two dimensions.
|
171 |
*/
|
172 |
public final static int GEOM2D = 0; |
173 |
|
174 |
/**
|
175 |
* Geometries with two dimensions and with a value
|
176 |
* for the elevation.
|
177 |
*/
|
178 |
public final static int GEOM2DZ = 1; |
179 |
|
180 |
/**
|
181 |
* Geometries with three dimensions.
|
182 |
*/
|
183 |
public final static int GEOM3D = 2; |
184 |
|
185 |
/**
|
186 |
* Geometries with two dimensions and with the
|
187 |
* M coordinate.
|
188 |
*/
|
189 |
public final static int GEOM2DM = 3; |
190 |
|
191 |
/**
|
192 |
* Geometries with three dimensions and with the
|
193 |
* M coordinate.
|
194 |
*/
|
195 |
public final static int GEOM3DM = 4; |
196 |
|
197 |
/**
|
198 |
* The subtype us unknown.
|
199 |
*/
|
200 |
public final static int UNKNOWN = 5; |
201 |
} |
202 |
|
203 |
/**
|
204 |
* Initial value for new geometry types (it must not overlap with the basic
|
205 |
* ones defined in TYPES).
|
206 |
*/
|
207 |
public static final int EXTENDED_GEOMTYPE_OFFSET = 17; |
208 |
|
209 |
/**
|
210 |
* Initial value for new geometry subtypes (it must not overlap with the
|
211 |
* basic ones defined in SUBTYPES).
|
212 |
*/
|
213 |
public static final int EXTENDED_GEOMSUBTYPE_OFFSET = 6; |
214 |
|
215 |
public static int BEST = 0; |
216 |
/**
|
217 |
* North.
|
218 |
*/
|
219 |
public static int N = 1; |
220 |
|
221 |
/**
|
222 |
* North - East.
|
223 |
*/
|
224 |
public static int NE = 2; |
225 |
|
226 |
/**
|
227 |
* East.
|
228 |
*/
|
229 |
public static int E = 3; |
230 |
|
231 |
/**
|
232 |
* South - East.
|
233 |
*/
|
234 |
public static int SE = 4; |
235 |
|
236 |
/**
|
237 |
* South.
|
238 |
*/
|
239 |
public static int S = 5; |
240 |
|
241 |
/**
|
242 |
* South - West.
|
243 |
*/
|
244 |
public static int SW = 6; |
245 |
|
246 |
/**
|
247 |
* West.
|
248 |
*/
|
249 |
public static int W = 7; |
250 |
|
251 |
/**
|
252 |
* North - West.
|
253 |
*/
|
254 |
public static int NW = 8; |
255 |
|
256 |
public static int SELECTHANDLER=0; |
257 |
public static int STRETCHINGHANDLER=1; |
258 |
|
259 |
/**
|
260 |
* If this geometry is a predefined interface then this method returns one of {@link Geometry.TYPES} contants.<br>
|
261 |
* If this geometry is an extended type then this method returns a runtime constant that identifies its type.
|
262 |
* By convention this value is stored in a constant called .CODE within the geometry class, for instance: Point2D.CODE.
|
263 |
*
|
264 |
* @return If this geometry is a predefined interface then one of {@link Geometry.TYPES} or a runtime constant if
|
265 |
* it is an extended type.
|
266 |
*/
|
267 |
public int getType(); |
268 |
|
269 |
/**
|
270 |
* Creates a clone of this geometry.
|
271 |
*
|
272 |
* @return A clone of this geometry.
|
273 |
*/
|
274 |
public Geometry cloneGeometry();
|
275 |
|
276 |
/**
|
277 |
* Returns true if this geometry intersects the rectangle passed as parameter.
|
278 |
*
|
279 |
* @param r Rectangle.
|
280 |
*
|
281 |
* @return True, if <code>this</code> intersects <code>r</code>.
|
282 |
*/
|
283 |
public boolean intersects(Rectangle2D r); |
284 |
|
285 |
/**
|
286 |
* Used by the drawing strategies to quickly test whether this geometry
|
287 |
* intersects with the visible rectangle.
|
288 |
*
|
289 |
* @param x
|
290 |
* The minimum X coordinate.
|
291 |
* @param y
|
292 |
* The minimum Y coordinate.
|
293 |
* @param w
|
294 |
* The width of the envelope.
|
295 |
* @param h
|
296 |
* The height of the envelope.
|
297 |
* @return true if <code>this</code> intersects the rectangle defined by the parameters.
|
298 |
*/
|
299 |
public boolean fastIntersects(double x, double y, double w, double h); |
300 |
|
301 |
/**
|
302 |
* Returns this geometry's boundary rectangle.
|
303 |
* @deprecated use getEnvelope.
|
304 |
* @return Boundary rectangle.
|
305 |
*/
|
306 |
public Rectangle2D getBounds2D(); |
307 |
|
308 |
/**
|
309 |
* <p>
|
310 |
* Returns the minimum bounding box for this Geometry. This shall
|
311 |
* be the coordinate region spanning the minimum and maximum value
|
312 |
* for each ordinate taken on by DirectPositions in this Geometry.
|
313 |
* The simplest representation for an envelope consists of two
|
314 |
* DirectPositions, the first one containing all the minimums for
|
315 |
* each ordinate, and second one containing all the maximums.
|
316 |
* </p>
|
317 |
* @return
|
318 |
* The minimum bounding box for this Geometry.
|
319 |
*/
|
320 |
public Envelope getEnvelope();
|
321 |
|
322 |
/**
|
323 |
* Reprojects this geometry by the coordinate transformer
|
324 |
* passed as parameter.
|
325 |
*
|
326 |
* @param ct
|
327 |
* Coordinate Transformer.
|
328 |
*/
|
329 |
public void reProject(ICoordTrans ct); |
330 |
|
331 |
/**
|
332 |
* If applies an affine transformation and
|
333 |
* returns the GeneralPathXIterator with this geometry's information.
|
334 |
* @param at
|
335 |
* The transformation to apply.
|
336 |
* @return
|
337 |
* The GeneralPathXIterator with this geometry's information.
|
338 |
*/
|
339 |
public PathIterator getPathIterator(AffineTransform at); |
340 |
|
341 |
/**
|
342 |
* It returns the handlers of the geometry,
|
343 |
* these they can be of two types is straightening and of selection.
|
344 |
*
|
345 |
* @param type
|
346 |
* Type of handlers.
|
347 |
*
|
348 |
* @return
|
349 |
* The handlers.
|
350 |
*/
|
351 |
public Handler[] getHandlers(int type); |
352 |
|
353 |
/**
|
354 |
* It applies an affine transformation to the geometry.
|
355 |
*
|
356 |
* @param at
|
357 |
* The transformation to apply.
|
358 |
*/
|
359 |
public void transform(AffineTransform at); |
360 |
|
361 |
/**
|
362 |
* If applies an affine transformation and
|
363 |
* returns the GeneralPathXIterator with this geometry's information.
|
364 |
* @param at
|
365 |
* The affine transformation.
|
366 |
* @param flatness
|
367 |
*
|
368 |
* @return
|
369 |
* The GeneralPathXIterator with this geometry's information.
|
370 |
*/
|
371 |
PathIterator getPathIterator(AffineTransform at, double flatness); |
372 |
|
373 |
/**
|
374 |
* Useful to have the real shape behind the scenes.
|
375 |
* May be uses to edit it knowing it it is a Circle, Ellipse, etc.
|
376 |
* @return
|
377 |
* The awt shape
|
378 |
*/
|
379 |
public Shape getInternalShape(); |
380 |
|
381 |
/**
|
382 |
* Returns the largest number n such that each direct position
|
383 |
* in a geometric set can be associated with a subset
|
384 |
* that has the direct position in its interior and
|
385 |
* is similar (isomorphic) to Rn, Euclidean n-space.
|
386 |
* @return
|
387 |
* The dimension.
|
388 |
*/
|
389 |
public int getDimension(); |
390 |
|
391 |
/**
|
392 |
* Returns <code>true</code> if this Geometry has no interior point
|
393 |
* of self-intersection or self-tangency. In mathematical
|
394 |
* formalisms, this means that every point in the
|
395 |
* interior of the object must have a metric neighborhood
|
396 |
* whose intersection with the object is isomorphic to an
|
397 |
* n-sphere, where n is the dimension of this Geometry.
|
398 |
* @return
|
399 |
* If the geometry is simple.
|
400 |
*/
|
401 |
public boolean isSimple(); |
402 |
|
403 |
/**
|
404 |
* Invokes a geometry operation given its index and context.
|
405 |
* @param index
|
406 |
* Unique index of the operation. Operation code.
|
407 |
* @param ctx
|
408 |
* The context of the geometry operation.
|
409 |
* @return
|
410 |
* Object returned by the operation.
|
411 |
* @throws GeometryOperationNotSupportedException
|
412 |
* It is thrown when the operation has been not registered for this geometry.
|
413 |
* @throws GeometryOperationException
|
414 |
* It is thrown when there is an error executing the operation.
|
415 |
*/
|
416 |
public Object invokeOperation(int index, GeometryOperationContext ctx) throws GeometryOperationNotSupportedException, GeometryOperationException; |
417 |
|
418 |
/**
|
419 |
* Invokes a geometry operation given its name and context.
|
420 |
* @param opName
|
421 |
* Operation name.
|
422 |
* @param ctx
|
423 |
* The context of the geometry operation.
|
424 |
* @return
|
425 |
* Object returned by the operation.
|
426 |
* @throws GeometryOperationNotSupportedException
|
427 |
* It is thrown when the operation has been not registered for this geometry.
|
428 |
* @throws GeometryOperationException
|
429 |
* It is thrown when there is an error executing the operation.
|
430 |
*/
|
431 |
public Object invokeOperation(String opName, GeometryOperationContext ctx) throws GeometryOperationNotSupportedException, GeometryOperationException; |
432 |
|
433 |
/**
|
434 |
* Instance of the GeometryType associated to this geometry.
|
435 |
* @return
|
436 |
* The geometry type.
|
437 |
*/
|
438 |
public GeometryType getGeometryType();
|
439 |
|
440 |
/**
|
441 |
* Get GeneralPathIterator, to do registered operations to it.
|
442 |
* @return
|
443 |
* The GeneralPathX.
|
444 |
*/
|
445 |
public GeneralPathX getGeneralPath();
|
446 |
} |