Statistics
| Revision:

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 @ 43002

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