Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_geometries / src / org / gvsig / fmap / geom / Geometry.java @ 29018

History | View | Annotate | Download (11.4 KB)

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