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

History | View | Annotate | Download (33 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.fmap.geom;
25

    
26
import java.awt.Shape;
27
import java.awt.geom.AffineTransform;
28
import java.awt.geom.PathIterator;
29
import java.awt.geom.Rectangle2D;
30
import java.io.Serializable;
31

    
32
import org.cresques.cts.ICoordTrans;
33
import org.cresques.cts.IProjection;
34

    
35
import org.gvsig.fmap.geom.aggregate.MultiLine;
36
import org.gvsig.fmap.geom.aggregate.MultiPoint;
37
import org.gvsig.fmap.geom.aggregate.MultiPolygon;
38
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
 *
72
 * @see <a href="http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=26012"
73
 * >ISO 19107</a>
74
 */
75
public interface Geometry extends Shape, Serializable, Comparable, Cloneable {
76
    
77
    /**
78
     * Specifies a round join style for buffer.
79
     */
80
    public static final int JOIN_STYLE_ROUND = 1;
81
    /**
82
     * Specifies a mitre join style for buffer.
83
     */
84
    public static final int JOIN_STYLE_MITRE = 2;
85
    /**
86
     * Specifies a bevel join style for buffer.
87
     */
88
    public static final int JOIN_STYLE_BEVEL = 3;
89

    
90

    
91
    /**
92
     * Predefined geometry types in the model.
93
     */
94
    public interface TYPES {
95

    
96
        public final static int UNKNOWN = -1;
97
        /**
98
         * Any geometry.
99
         */
100
        public final static int GEOMETRY = 0;
101

    
102
        /**
103
         * A geometric element that has zero dimensions and a location
104
         * determinable by an ordered set of coordinates.
105
         */
106
        public final static int POINT = 1;
107

    
108
        /**
109
         * A straight or curved geometric element that is generated by a moving
110
         * point and that has extension only along the path of the point.
111
         */
112
        public final static int CURVE = 2;
113

    
114
        /**
115
         * A closed plane figure bounded by straight lines.
116
         */
117
        public final static int SURFACE = 3;
118

    
119
        /**
120
         * Solids in 3D.
121
         */
122
        public final static int SOLID = 4;
123

    
124
        /**
125
         * A set that can contain points, lines and polygons. This is usual in
126
         * <i>CAD</i> layers <i>(dxf, dgn, dwg)</i>.
127
         */
128
        public final static int AGGREGATE = 6;
129
        /**
130
         * A set of points.
131
         */
132
        public final static int MULTIPOINT = 7;
133

    
134
        /**
135
         * A set of lines.
136
         */
137
        public final static int MULTICURVE = 8;
138

    
139
        /**
140
         * A set of polygons.
141
         */
142
        public final static int MULTISURFACE = 9;
143

    
144
        /**
145
         * A set of solids.
146
         */
147
        public final static int MULTISOLID = 10;
148

    
149
        /**
150
         * A closed plane curve every point of which is equidistant from a fixed
151
         * point within the curve.
152
         */
153
        public final static int CIRCLE = 11;
154

    
155
        /**
156
         * A continuous portion (as of a circle or ellipse) of a curved line.
157
         */
158
        public final static int ARC = 12;
159

    
160
        /**
161
         * A closed plane curve generated by a point moving in such a way that
162
         * the sums of its distances from two fixed points is a constant : a
163
         * plane section of a right circular cone that is a closed curve.
164
         */
165
        public final static int ELLIPSE = 13;
166

    
167
        public final static int SPLINE = 14;
168

    
169
        public final static int ELLIPTICARC = 15;
170

    
171
        /**
172
         * NO DATA geometry.
173
         */
174
        @Deprecated
175
        public final static int NULL = 16;
176

    
177
        public final static int COMPLEX = 17;
178

    
179
        public final static int LINE = 18;
180

    
181
        public final static int POLYGON = 19;
182

    
183
        public final static int RING = 20;
184

    
185
        public final static int MULTILINE = 21;
186

    
187
        public final static int MULTIPOLYGON = 22;
188

    
189
        public final static int CIRCUMFERENCE = 23;
190

    
191
        public final static int PERIELLIPSE = 24;
192

    
193
        public final static int FILLEDSPLINE = 25;
194

    
195
    }
196

    
197
    public interface DIMENSIONS {
198

    
199
        public final static int X = 0;
200
        public final static int Y = 1;
201
        public final static int Z = 2;
202
    }
203

    
204
    /**
205
     * The subtype of a geometry is related with the dimension of the geometry,
206
     * that is a combination between the spatial dimension (2D, 2ZD, 3D) and the
207
     * M coordinate or "measure".
208
     *
209
     * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
210
     */
211
    public interface SUBTYPES {
212

    
213
        /**
214
         * Geometries with two dimensions.
215
         */
216
        public final static int GEOM2D = 0;
217

    
218
        /**
219
         * Geometries with three dimensions.
220
         */
221
        public final static int GEOM3D = 1;
222

    
223
        /**
224
         * Geometries with two dimensions and with the M coordinate.
225
         */
226
        public final static int GEOM2DM = 2;
227

    
228
        /**
229
         * Geometries with three dimensions and with the M coordinate.
230
         */
231
        public final static int GEOM3DM = 3;
232

    
233
        /**
234
         * The subtype us unknown.
235
         */
236
        public final static int UNKNOWN = 4;
237
    }
238

    
239
    /**
240
     * Initial value for new geometry types (it must not overlap with the basic
241
     * ones defined in TYPES).
242
     */
243
    public static final int EXTENDED_GEOMTYPE_OFFSET = 17;
244

    
245
    /**
246
     * Initial value for new geometry subtypes (it must not overlap with the
247
     * basic ones defined in SUBTYPES).
248
     */
249
    public static final int EXTENDED_GEOMSUBTYPE_OFFSET = 6;
250

    
251
    public interface OPERATIONS {
252

    
253
        public final static String CONVERTTOWKT = "toWKT";
254
        public final static String CONVERTTOWKB = "toWKB";
255
        public final static String BUFFER = "buffer";
256
        public final static String DISTANCE = "Distance";
257
        public final static String CONTAINS = "Contains";
258
        public final static String OVERLAPS = "OVERLAPS";
259
        public final static String CONVEXHULL = "ConvexHull";
260
        public final static String COVERS = "Covers";
261
        public final static String CROSSES = "Crosses";
262
        public final static String DIFFERENCE = "Difference";
263
        public final static String DISJOIN = "Disjoin";
264
        public final static String INTERSECTION = "Intersaction";
265
        public final static String INTERSECTS = "Intersects";
266
        public final static String TOUCHES = "Touches";
267
        public final static String UNION = "Union";
268
        public final static String WITHIN = "Within";
269
        public final static String COVEREDBY = "CoveredBy";
270
        public final static String BOUNDARY = "Boundary";
271
    }
272

    
273
    public interface ValidationStatus {
274

    
275
        public static final int VALID = 0;
276
        public static final int CURRUPTED = 1;
277
        public static final int UNKNOW = 2;
278
        public static final int DISCONNECTED_INTERIOR = 10;
279
        public static final int DUPLICATE_RINGS = 11;
280
        public static final int HOLE_OUTSIDE_SHELL = 12;
281
        public static final int INVALID_COORDINATE = 13;
282
        public static final int NESTED_HOLES = 14;
283
        public static final int NESTED_SHELLS = 15;
284
        public static final int RING_NOT_CLOSED = 17;
285
        public static final int RING_SELF_INTERSECTION = 18;
286
        public static final int SELF_INTERSECTION = 19;
287
        public static final int TOO_FEW_POINTS = 20;
288

    
289
        /**
290
         * True if the geoemtry are valid.
291
         *
292
         * @return true form valid geometries
293
         */
294
        public boolean isValid();
295

    
296
        /**
297
         * Return the status code results of validate the geometry.
298
         *
299
         * @return validation code
300
         */
301
        public int getStatusCode();
302

    
303
        /**
304
         * Return the nearest point to the problem when validate the geometry.
305
         *
306
         * If the geometry is valid, this return null.
307
         *
308
         * @return the nearest point to the problem or null.
309
         */
310
        public Point getProblemLocation();
311

    
312
        /**
313
         * Return a human readable message explaining the cause of the problem.
314
         *
315
         * If the geometry is valid this is null.
316
         *
317
         * @return the message cause of the problem.
318
         */
319
        public String getMessage();
320
    }
321

    
322
    public static int BEST = 0;
323
    /**
324
     * North.
325
     */
326
    public static int N = 1;
327

    
328
    /**
329
     * North - East.
330
     */
331
    public static int NE = 2;
332

    
333
    /**
334
     * East.
335
     */
336
    public static int E = 3;
337

    
338
    /**
339
     * South - East.
340
     */
341
    public static int SE = 4;
342

    
343
    /**
344
     * South.
345
     */
346
    public static int S = 5;
347

    
348
    /**
349
     * South - West.
350
     */
351
    public static int SW = 6;
352

    
353
    /**
354
     * West.
355
     */
356
    public static int W = 7;
357

    
358
    /**
359
     * North - West.
360
     */
361
    public static int NW = 8;
362

    
363
    public static int SELECTHANDLER = 0;
364
    public static int STRETCHINGHANDLER = 1;
365

    
366
    /**
367
     * If this geometry is a predefined interface then this method returns one
368
     * of {@link Geometry.TYPES} contants.<br>
369
     * If this geometry is an extended type then this method returns a runtime
370
     * constant that identifies its type. By convention this value is stored in
371
     * a constant called .CODE within the geometry class, for instance:
372
     * Point2D.CODE.
373
     *
374
     * @return If this geometry is a predefined interface then one of
375
     * {@link Geometry.TYPES} or a runtime constant if it is an extended type.
376
     */
377
    public int getType();
378

    
379
    /**
380
     * Creates a clone of this geometry.
381
     *
382
     * @return A clone of this geometry.
383
     */
384
    public Geometry cloneGeometry();
385
    
386
    public Geometry clone() throws CloneNotSupportedException;
387

    
388
    /**
389
     * Returns true if this geometry intersects the rectangle passed as
390
     * parameter.
391
     *
392
     * @param r Rectangle.
393
     *
394
     * @return True, if <code>this</code> intersects <code>r</code>.
395
     */
396
    @Override
397
    public boolean intersects(Rectangle2D r);
398

    
399
    /**
400
     * Used by the drawing strategies to quickly test whether this geometry
401
     * intersects with the visible rectangle.
402
     *
403
     * @param x The minimum X coordinate.
404
     * @param y The minimum Y coordinate.
405
     * @param w The width of the envelope.
406
     * @param h The height of the envelope.
407
     * @return true if <code>this</code> intersects the rectangle defined by the
408
     * parameters.
409
     */
410
    public boolean fastIntersects(double x, double y, double w, double h);
411

    
412
    /**
413
     * <p>
414
     * Returns the minimum bounding box for this Geometry. This shall be the
415
     * coordinate region spanning the minimum and maximum value for each
416
     * ordinate taken on by DirectPositions in this Geometry. The simplest
417
     * representation for an envelope consists of two DirectPositions, the first
418
     * one containing all the minimums for each ordinate, and second one
419
     * containing all the maximums.
420
     * </p>
421
     *
422
     * @return The minimum bounding box for this Geometry.
423
     */
424
    public Envelope getEnvelope();
425

    
426
    /**
427
     * Reprojects this geometry by the coordinate transformer passed as
428
     * parameter.
429
     *
430
     * @param ct Coordinate Transformer.
431
     */
432
    public void reProject(ICoordTrans ct);
433

    
434
    /**
435
     * It applies an affine transformation to the geometry. If parameter value
436
     * is null, it will be considered an empty transformation, therefore
437
     * equivalent to the identity transformation.
438
     *
439
     * @param at The transformation to apply.
440
     */
441
    public void transform(AffineTransform at);
442

    
443
    /**
444
     * Returns the largest number n such that each direct position in a
445
     * geometric set can be associated with a subset that has the direct
446
     * position in its interior and is similar (isomorphic) to Rn, Euclidean
447
     * n-space.
448
     *
449
     * @return The dimension.
450
     */
451
    public int getDimension();
452

    
453
    /**
454
     * Returns <code>true</code> if this Geometry has no interior point of
455
     * self-intersection or self-tangency. In mathematical formalisms, this
456
     * means that every point in the interior of the object must have a metric
457
     * neighborhood whose intersection with the object is isomorphic to an
458
     * n-sphere, where n is the dimension of this Geometry.
459
     *
460
     * @return If the geometry is simple.
461
     */
462
    public boolean isSimple();
463

    
464
    public boolean isCCW()
465
            throws GeometryOperationNotSupportedException,
466
            GeometryOperationException;
467

    
468
    /**
469
     * Invokes a geometry operation given its index and context.
470
     *
471
     * @param index Unique index of the operation. Operation code.
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(int index, GeometryOperationContext ctx)
480
            throws GeometryOperationNotSupportedException,
481
            GeometryOperationException;
482

    
483
    /**
484
     * Invokes a geometry operation given its name and context.
485
     *
486
     * @param opName Operation name.
487
     * @param ctx The context of the geometry operation.
488
     * @return Object returned by the operation.
489
     * @throws GeometryOperationNotSupportedException It is thrown when the
490
     * operation has been not registered for this geometry.
491
     * @throws GeometryOperationException It is thrown when there is an error
492
     * executing the operation.
493
     */
494
    public Object invokeOperation(String opName, GeometryOperationContext ctx)
495
            throws GeometryOperationNotSupportedException,
496
            GeometryOperationException;
497

    
498
    /**
499
     * Instance of the GeometryType associated to this geometry.
500
     *
501
     * @return The geometry type.
502
     */
503
    public GeometryType getGeometryType();
504

    
505
    public Object convertTo(String format) throws GeometryOperationNotSupportedException,
506
            GeometryOperationException;
507

    
508
    /**
509
     * Return a byte array with the equivalent in WKB format of the Geometry.
510
     *
511
     * Utility method to wrap the invocation to the operation
512
     * {@link OPERATIONS#CONVERTTOWKB}.
513
     *
514
     * @return the WKB version of the geometry
515
     * @throws org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException
516
     * @throws org.gvsig.fmap.geom.operation.GeometryOperationException
517
     */
518
    public byte[] convertToWKB() throws GeometryOperationNotSupportedException,
519
            GeometryOperationException;
520

    
521
    public String convertToHexEWKB() throws GeometryOperationNotSupportedException,
522
            GeometryOperationException;
523
    
524
    public String convertToHexWKB() throws GeometryOperationNotSupportedException,
525
            GeometryOperationException;
526

    
527
    public byte[] convertToWKBQuietly();
528

    
529
    public String convertToHexWKBQuietly();
530

    
531
    public String convertToHexEWKBQuietly();
532

    
533
    public byte[] convertToWKB(int srs)
534
            throws GeometryOperationNotSupportedException, GeometryOperationException;
535

    
536
    public byte[] convertToWKBForcingType(int srs, int type)
537
            throws GeometryOperationNotSupportedException, GeometryOperationException;
538

    
539
    /**
540
     * Return a byte array with the equivalent in EWKB format of the Geometry.
541
     *
542
     * Utility method to wrap the invocation to the operation
543
     * {@link OPERATIONS#CONVERTTOEWKB}.
544
     *
545
     * @return the EWKB version of the geometry
546
     * @throws org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException
547
     * @throws org.gvsig.fmap.geom.operation.GeometryOperationException
548
     */
549
    public byte[] convertToEWKB() throws GeometryOperationNotSupportedException, GeometryOperationException;
550

    
551
    public byte[] convertToEWKB(int srs)
552
            throws GeometryOperationNotSupportedException, GeometryOperationException;
553

    
554
    public byte[] convertToEWKBForcingType(int srs, int type)
555
            throws GeometryOperationNotSupportedException, GeometryOperationException;
556

    
557
    /**
558
     * Return a string with the equivalent in WKT format of the Geometry.
559
     *
560
     * This is a utility method to wrap the invocation to the operation
561
     * {@link OPERATIONS#CONVERTTOWKT}.
562
     *
563
     * @return the WKT version of the geometry.
564
     *
565
     * @throws GeometryOperationNotSupportedException
566
     * @throws GeometryOperationException
567
     */
568
    public String convertToWKT() throws GeometryOperationNotSupportedException,
569
            GeometryOperationException;
570

    
571
    public String convertToWKTQuietly();
572
    
573
    /**
574
     * Computes a buffer area around this geometry having the given width
575
     *
576
     * This is a utility method to wrap the invocation to the operation
577
     * {@link OPERATIONS#BUFFER}.
578
     *
579
     * @param distance the width of the buffer
580
     *
581
     * @return a new Geometry with the computed buffer.
582
     *
583
     * @throws GeometryOperationNotSupportedException
584
     * @throws GeometryOperationException
585
     */
586
    public Geometry buffer(double distance)
587
            throws GeometryOperationNotSupportedException,
588
            GeometryOperationException;
589

    
590

    
591

    
592
    /**
593
     * Computes a buffer area around this geometry having the given width, the joinStyle and the capButt
594
     *
595
     * This is a utility method to wrap the invocation to the operation
596
     * {@link OPERATIONS#BUFFER}.
597
     *
598
     * @param distance the width of the buffer
599
     * @param joinStyle the join style can be JOIN_STYLE_ROUND, JOIN_STYLE_MITRE, JOIN_STYLE_BEVEL,
600
     * @param capButt true if not add a cap
601
     *
602
     * @return a new Geometry with the computed buffer.
603
     *
604
     * @throws GeometryOperationNotSupportedException
605
     * @throws GeometryOperationException
606
     */
607
    public Geometry buffer(double distance, int joinStyle, boolean capButt) 
608
            throws GeometryOperationNotSupportedException, 
609
            GeometryOperationException;
610

    
611
    
612
    /**
613
     *
614
     * @param distance
615
     * @return
616
     * @throws GeometryOperationNotSupportedException
617
     * @throws GeometryOperationException
618
     */
619
    public Geometry offset(double distance)
620
            throws GeometryOperationNotSupportedException,
621
            GeometryOperationException;
622

    
623
    /**
624
     *
625
     * @param joinStyle
626
     * @param distance
627
     * @return
628
     * @throws GeometryOperationNotSupportedException
629
     * @throws GeometryOperationException
630
     */
631
    public Geometry offset(int joinStyle, double distance)
632
            throws GeometryOperationNotSupportedException,
633
            GeometryOperationException;
634

    
635
    /**
636
     * Tests whether this geometry contains the specified geometry.
637
     *
638
     * This is a utility method to wrap the invocation to the operation
639
     * {@link OPERATIONS#CONTAINS}.
640
     *
641
     * @param geometry the Geometry with which to compare this Geometry
642
     *
643
     * @return if this Geometry contains the specified geometry
644
     *
645
     * @throws GeometryOperationNotSupportedException
646
     * @throws GeometryOperationException
647
     */
648
    public boolean contains(Geometry geometry)
649
            throws GeometryOperationNotSupportedException,
650
            GeometryOperationException;
651

    
652
    /**
653
     * Returns the minimum distance between this Geometry and the specified
654
     * geometry.
655
     *
656
     * This is a utility method to wrap the invocation to the operation
657
     * {@link OPERATIONS#DISTANCE}.
658
     *
659
     * @param other
660
     * @return the distance between the geometries
661
     *
662
     * @throws GeometryOperationNotSupportedException
663
     * @throws GeometryOperationException
664
     */
665
    public double distance(Geometry other)
666
            throws GeometryOperationNotSupportedException,
667
            GeometryOperationException;
668

    
669
    public Geometry[] closestPoints(Geometry other)
670
            throws GeometryOperationNotSupportedException,
671
            GeometryOperationException;
672

    
673
    boolean isWithinDistance(Geometry other, double distance)
674
            throws GeometryOperationNotSupportedException,
675
            GeometryOperationException;
676

    
677
    /**
678
     * Tests whether this geometry overlaps the specified geometry.
679
     *
680
     * This is a utility method to wrap the invocation to the operation
681
     * {@link OPERATIONS#OVERLAPS}.
682
     *
683
     * @param geometry the Geometry with which to compare this Geometry
684
     *
685
     * @return true if the two geometries overlap.
686
     *
687
     * @throws GeometryOperationNotSupportedException
688
     * @throws GeometryOperationException
689
     */
690
    public boolean overlaps(Geometry geometry)
691
            throws GeometryOperationNotSupportedException,
692
            GeometryOperationException;
693

    
694
    public Geometry convexHull() throws GeometryOperationNotSupportedException,
695
            GeometryOperationException;
696

    
697
    public boolean coveredBy(Geometry geometry)
698
            throws GeometryOperationNotSupportedException,
699
            GeometryOperationException;
700

    
701
    public boolean covers(Geometry geometry)
702
            throws GeometryOperationNotSupportedException,
703
            GeometryOperationException;
704

    
705
    public boolean crosses(Geometry geometry)
706
            throws GeometryOperationNotSupportedException,
707
            GeometryOperationException;
708

    
709
    public Geometry difference(Geometry other)
710
            throws GeometryOperationNotSupportedException,
711
            GeometryOperationException;
712

    
713
    public boolean disjoint(Geometry geometry)
714
            throws GeometryOperationNotSupportedException,
715
            GeometryOperationException;
716

    
717
    public Geometry intersection(Geometry other)
718
            throws GeometryOperationNotSupportedException,
719
            GeometryOperationException;
720

    
721
    public boolean intersects(Geometry geometry)
722
            throws GeometryOperationNotSupportedException,
723
            GeometryOperationException;
724

    
725
    public Geometry snapTo(Geometry other, double snapTolerance)
726
            throws GeometryOperationNotSupportedException,
727
            GeometryOperationException;
728

    
729
    public boolean touches(Geometry geometry)
730
            throws GeometryOperationNotSupportedException,
731
            GeometryOperationException;
732

    
733
    public Geometry union(Geometry other)
734
            throws GeometryOperationNotSupportedException,
735
            GeometryOperationException;
736

    
737
    public boolean within(Geometry geometry)
738
            throws GeometryOperationNotSupportedException,
739
            GeometryOperationException;
740

    
741
    public Point centroid() throws GeometryOperationNotSupportedException, GeometryOperationException;
742

    
743
    /**
744
     * This method returns a point which is inside the geometry. This is useful
745
     * for mathematical purposes but it is very unlikely to be a suitable place
746
     * for a label, for example.
747
     *
748
     *
749
     * @return an interior point
750
     * @throws GeometryOperationNotSupportedException
751
     * @throws GeometryOperationException
752
     */
753
    public Point getInteriorPoint() throws GeometryOperationNotSupportedException, GeometryOperationException;
754

    
755
    public double area() throws GeometryOperationNotSupportedException, GeometryOperationException;
756

    
757
    public double perimeter() throws GeometryOperationNotSupportedException, GeometryOperationException;
758

    
759
    /**
760
     * Rotates the geometry by radAngle radians using the given coordinates as
761
     * center of rotation. Rotating with a positive angle rotates points on the
762
     * positive x axis toward the positive y axis. In most cases, we assume x
763
     * increases rightwards and y increases upwards, so in most cases, a
764
     * positive angle will mean counter-clockwise rotation.
765
     *
766
     * @param radAngle the amount of rotation, in radians
767
     * @param basex x coordinate of center of rotation
768
     * @param basey y coordinate of center of rotation
769
     */
770
    public void rotate(double radAngle, double basex, double basey);
771

    
772
    /**
773
     * Shifts geometry by given amount in x and y axes
774
     *
775
     * @param dx
776
     * @param dy
777
     */
778
    public void move(double dx, double dy);
779

    
780
    /**
781
     * Scales geometry in x and y axes by given scale factors using the given
782
     * point as center of projection.
783
     *
784
     * @param basePoint
785
     * @param sx scale factor in x axis
786
     * @param sy scale factor in y axis
787
     */
788
    public void scale(Point basePoint, double sx, double sy);
789

    
790
    /**
791
     * Check if the geometry is valid.
792
     *
793
     * @return true if the geometry is valid.
794
     */
795
    public boolean isValid();
796

    
797
    /**
798
     * Check if the geometry is valid and returns the validation status.
799
     *
800
     * @return the ValidationStatus
801
     */
802
    public ValidationStatus getValidationStatus();
803

    
804
    /**
805
     * Try to fix the geometry and return the new geometry. If the geometry is
806
     * valid return the same geometry. If the geometry is corrupt or can't fix
807
     * it, return null.
808
     *
809
     * @return the new fixed geometry
810
     */
811
    public Geometry makeValid();
812

    
813
    //
814
    // ===============================================
815
    //
816
    /**
817
     * @param affineTransform
818
     * @return the awt shape used to display the geometry. It applies a
819
     * tranformation before to return the coordinates of the shape
820
     * @deprecated this class inherits of {@link Shape} by historical reasons.
821
     * This method has been added just to control the usage of the {@link Shape}
822
     * class but it will removed in a future.
823
     */
824
    public Shape getShape(AffineTransform affineTransform);
825

    
826
    /**
827
     * @return the awt shape used to display the geometry.
828
     * @deprecated this class inherits of {@link Shape} by historical reasons.
829
     * This method has been added just to control the usage of the {@link Shape}
830
     * class but it will removed in a future.
831
     */
832
    public Shape getShape();
833

    
834
    /**
835
     * Returns this geometry's boundary rectangle.
836
     *
837
     * @deprecated use getEnvelope.
838
     * @return Boundary rectangle.
839
     */
840
    @Override
841
    public Rectangle2D getBounds2D();
842

    
843
    /**
844
     * If applies an affine transformation and returns the GeneralPathXIterator
845
     * with this geometry's information.
846
     *
847
     * @param at The transformation to apply.
848
     * @return The GeneralPathXIterator with this geometry's information.
849
     * @deprecated don't use PathIterator over geometries, use instead specific
850
     * API for each operation. If not has API for that operation let the project
851
     * team.
852
     *
853
     */
854
    @Override
855
    public PathIterator getPathIterator(AffineTransform at);
856

    
857
    /**
858
     * It returns the handlers of the geometry, these they can be of two types
859
     * is straightening and of selection.
860
     *
861
     * @param type Type of handlers.
862
     *
863
     * @deprecated don't use Handlers over geometries, use instead specific API
864
     * for each operation. If not has API for that operation let the project
865
     * team.
866
     * @return The handlers.
867
     */
868
    public Handler[] getHandlers(int type);
869

    
870
    /**
871
     * If applies an affine transformation and returns the GeneralPathXIterator
872
     * with this geometry's information.
873
     *
874
     * @param at The affine transformation.
875
     * @param flatness
876
     *
877
     * @return The GeneralPathXIterator with this geometry's information.
878
     * @deprecated don't use PathIterator over geometries, use instead specific
879
     * API for each operation. If not has API for that operation let the project
880
     * team.
881
     */
882
    @Override
883
    PathIterator getPathIterator(AffineTransform at, double flatness);
884

    
885
    /**
886
     * Useful to have the real shape behind the scenes. May be uses to edit it
887
     * knowing it it is a Circle, Ellipse, etc.
888
     *
889
     * @return The awt shape
890
     * @deprecated
891
     */
892
    public Shape getInternalShape();
893

    
894
    /**
895
     * Get GeneralPathIterator, to do registered operations to it.
896
     *
897
     * @return The GeneralPathX.
898
     * @deprecated don't use GeneralPathX over geometries, use instead specific
899
     * API for each operation. If not has API for that operation let the project
900
     * team.
901
     */
902
    public GeneralPathX getGeneralPath();
903

    
904
    /**
905
     * Converts the geometry to be points and makes with them a multiPoint
906
     *
907
     * @return MultiPoint
908
     * @throws GeometryException
909
     */
910
    public MultiPoint toPoints() throws GeometryException;
911

    
912
    /**
913
     * Converts the geometry to be lines and makes with them a multiLine
914
     *
915
     * @return
916
     * @throws GeometryException
917
     */
918
    public MultiLine toLines() throws GeometryException;
919

    
920
    /**
921
     * Converts the geometry to be polygons and makes with them a multiPolygon
922
     *
923
     * @return
924
     * @throws GeometryException
925
     */
926
    public MultiPolygon toPolygons() throws GeometryException;
927

    
928
    /**
929
     * Flip the coordinates of the geometry. If the geometry is aggregate also
930
     * revert the primitives collection.
931
     *
932
     * @throws GeometryOperationNotSupportedException
933
     * @throws GeometryOperationException
934
     */
935
    public void flip() throws GeometryOperationNotSupportedException, GeometryOperationException;
936

    
937
    /**
938
     * Ensures the orientation of the geometry according to the parameter,
939
     * flipping it if necessary. If the geometry is a polygon, ensures the
940
     * orientation of its perimeter and ensures the opposite orientation of
941
     * their holes.
942
     *
943
     * @param ccw
944
     * @return
945
     * @throws GeometryOperationNotSupportedException
946
     * @throws GeometryOperationException
947
     */
948
    public boolean ensureOrientation(boolean ccw) throws GeometryOperationNotSupportedException, GeometryOperationException;
949

    
950
    /**
951
     * Returns true if passed as a parameter geometry is completely out of
952
     * geometry.
953
     *
954
     * @param geometry
955
     * @return
956
     * @throws GeometryOperationNotSupportedException
957
     * @throws GeometryOperationException
958
     */
959
    public boolean out(Geometry geometry) throws GeometryOperationNotSupportedException, GeometryOperationException;
960

    
961
    /**
962
     * 
963
     * @return
964
     * @throws GeometryOperationNotSupportedException
965
     * @throws GeometryOperationException 
966
     * @deprecated use forceSubtype(Geometry.SUBTYPES.GEOM2D)
967
     */
968
    public Geometry force2D() throws GeometryOperationNotSupportedException, GeometryOperationException;
969
    
970
//    public Geometry force2DM() throws GeometryOperationNotSupportedException, GeometryOperationException;
971
//    
972
//    public Geometry force3D() throws GeometryOperationNotSupportedException, GeometryOperationException;
973
//    
974
//    public Geometry force3DM() throws GeometryOperationNotSupportedException, GeometryOperationException;
975

    
976
    public Geometry forceSubtype(int subtype) throws GeometryOperationNotSupportedException, GeometryOperationException;
977
    
978
    /**
979
     * Return true if the geometry can be transformed by the affine transform
980
     *
981
     * @param at the affine transform
982
     * @return
983
     */
984
    public boolean canBeTransformed(AffineTransform at);
985

    
986
    /**
987
     * Return true if the geometry can be reprojected by the coordinate
988
     * transformation
989
     *
990
     * @param ct the coordinate transformation
991
     * @return
992
     */
993
    public boolean canBeReprojected(ICoordTrans ct);
994

    
995
    public void setProjection(String projection);
996

    
997
    public void setProjection(IProjection projection);
998

    
999
    public void setProjectionIffNull(IProjection projection);
1000

    
1001
    public IProjection getProjection();
1002
    
1003
    /**
1004
     * Return the boundary 
1005
     * @return 
1006
     */
1007
    public Geometry boundary();
1008
    
1009
    @Override
1010
    public boolean equals(Object obj);
1011
    
1012
    public Geometry fix();
1013

    
1014
    public boolean isEmpty();
1015
    
1016
}