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

History | View | Annotate | Download (31.5 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
    }
271

    
272
    public interface ValidationStatus {
273

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
467
    /**
468
     * Invokes a geometry operation given its index and context.
469
     *
470
     * @param index Unique index of the operation. Operation code.
471
     * @param ctx The context of the geometry operation.
472
     * @return Object returned by the operation.
473
     * @throws GeometryOperationNotSupportedException It is thrown when the
474
     * operation has been not registered for this geometry.
475
     * @throws GeometryOperationException It is thrown when there is an error
476
     * executing the operation.
477
     */
478
    public Object invokeOperation(int index, GeometryOperationContext ctx)
479
            throws GeometryOperationNotSupportedException,
480
            GeometryOperationException;
481

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

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

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

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

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

    
526
    public byte[] convertToWKBQuietly();
527

    
528
    public String convertToHexWKBQuietly();
529

    
530
    public byte[] convertToWKB(int srs)
531
            throws GeometryOperationNotSupportedException, GeometryOperationException;
532

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

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

    
548
    public byte[] convertToEWKB(int srs)
549
            throws GeometryOperationNotSupportedException, GeometryOperationException;
550

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

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

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

    
587

    
588

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

    
608
    
609
    public Geometry offset(double distance)
610
            throws GeometryOperationNotSupportedException,
611
            GeometryOperationException;
612

    
613
    /**
614
     * Tests whether this geometry contains the specified geometry.
615
     *
616
     * This is a utility method to wrap the invocation to the operation
617
     * {@link OPERATIONS#CONTAINS}.
618
     *
619
     * @param geometry the Geometry with which to compare this Geometry
620
     *
621
     * @return if this Geometry contains the specified geometry
622
     *
623
     * @throws GeometryOperationNotSupportedException
624
     * @throws GeometryOperationException
625
     */
626
    public boolean contains(Geometry geometry)
627
            throws GeometryOperationNotSupportedException,
628
            GeometryOperationException;
629

    
630
    /**
631
     * Returns the minimum distance between this Geometry and the specified
632
     * geometry.
633
     *
634
     * This is a utility method to wrap the invocation to the operation
635
     * {@link OPERATIONS#DISTANCE}.
636
     *
637
     * @param other
638
     * @return the distance between the geometries
639
     *
640
     * @throws GeometryOperationNotSupportedException
641
     * @throws GeometryOperationException
642
     */
643
    public double distance(Geometry other)
644
            throws GeometryOperationNotSupportedException,
645
            GeometryOperationException;
646

    
647
    public Geometry[] closestPoints(Geometry other)
648
            throws GeometryOperationNotSupportedException,
649
            GeometryOperationException;
650

    
651
    boolean isWithinDistance(Geometry other, double distance)
652
            throws GeometryOperationNotSupportedException,
653
            GeometryOperationException;
654

    
655
    /**
656
     * Tests whether this geometry overlaps the specified geometry.
657
     *
658
     * This is a utility method to wrap the invocation to the operation
659
     * {@link OPERATIONS#OVERLAPS}.
660
     *
661
     * @param geometry the Geometry with which to compare this Geometry
662
     *
663
     * @return true if the two geometries overlap.
664
     *
665
     * @throws GeometryOperationNotSupportedException
666
     * @throws GeometryOperationException
667
     */
668
    public boolean overlaps(Geometry geometry)
669
            throws GeometryOperationNotSupportedException,
670
            GeometryOperationException;
671

    
672
    public Geometry convexHull() throws GeometryOperationNotSupportedException,
673
            GeometryOperationException;
674

    
675
    public boolean coveredBy(Geometry geometry)
676
            throws GeometryOperationNotSupportedException,
677
            GeometryOperationException;
678

    
679
    public boolean covers(Geometry geometry)
680
            throws GeometryOperationNotSupportedException,
681
            GeometryOperationException;
682

    
683
    public boolean crosses(Geometry geometry)
684
            throws GeometryOperationNotSupportedException,
685
            GeometryOperationException;
686

    
687
    public Geometry difference(Geometry other)
688
            throws GeometryOperationNotSupportedException,
689
            GeometryOperationException;
690

    
691
    public boolean disjoint(Geometry geometry)
692
            throws GeometryOperationNotSupportedException,
693
            GeometryOperationException;
694

    
695
    public Geometry intersection(Geometry other)
696
            throws GeometryOperationNotSupportedException,
697
            GeometryOperationException;
698

    
699
    public boolean intersects(Geometry geometry)
700
            throws GeometryOperationNotSupportedException,
701
            GeometryOperationException;
702

    
703
    public Geometry snapTo(Geometry other, double snapTolerance)
704
            throws GeometryOperationNotSupportedException,
705
            GeometryOperationException;
706

    
707
    public boolean touches(Geometry geometry)
708
            throws GeometryOperationNotSupportedException,
709
            GeometryOperationException;
710

    
711
    public Geometry union(Geometry other)
712
            throws GeometryOperationNotSupportedException,
713
            GeometryOperationException;
714

    
715
    public boolean within(Geometry geometry)
716
            throws GeometryOperationNotSupportedException,
717
            GeometryOperationException;
718

    
719
    public Point centroid() throws GeometryOperationNotSupportedException, GeometryOperationException;
720

    
721
    /**
722
     * This method returns a point which is inside the geometry. This is useful
723
     * for mathematical purposes but it is very unlikely to be a suitable place
724
     * for a label, for example.
725
     *
726
     *
727
     * @return an interior point
728
     * @throws GeometryOperationNotSupportedException
729
     * @throws GeometryOperationException
730
     */
731
    public Point getInteriorPoint() throws GeometryOperationNotSupportedException, GeometryOperationException;
732

    
733
    public double area() throws GeometryOperationNotSupportedException, GeometryOperationException;
734

    
735
    public double perimeter() throws GeometryOperationNotSupportedException, GeometryOperationException;
736

    
737
    /**
738
     * Rotates the geometry by radAngle radians using the given coordinates as
739
     * center of rotation. Rotating with a positive angle rotates points on the
740
     * positive x axis toward the positive y axis. In most cases, we assume x
741
     * increases rightwards and y increases upwards, so in most cases, a
742
     * positive angle will mean counter-clockwise rotation.
743
     *
744
     * @param radAngle the amount of rotation, in radians
745
     * @param basex x coordinate of center of rotation
746
     * @param basey y coordinate of center of rotation
747
     */
748
    public void rotate(double radAngle, double basex, double basey);
749

    
750
    /**
751
     * Shifts geometry by given amount in x and y axes
752
     *
753
     * @param dx
754
     * @param dy
755
     */
756
    public void move(double dx, double dy);
757

    
758
    /**
759
     * Scales geometry in x and y axes by given scale factors using the given
760
     * point as center of projection.
761
     *
762
     * @param basePoint
763
     * @param sx scale factor in x axis
764
     * @param sy scale factor in y axis
765
     */
766
    public void scale(Point basePoint, double sx, double sy);
767

    
768
    /**
769
     * Check if the geometry is valid.
770
     *
771
     * @return true if the geometry is valid.
772
     */
773
    public boolean isValid();
774

    
775
    /**
776
     * Check if the geometry is valid and returns the validation status.
777
     *
778
     * @return the ValidationStatus
779
     */
780
    public ValidationStatus getValidationStatus();
781

    
782
    /**
783
     * Try to fix the geometry and return the new geometry. If the geometry is
784
     * valid return the same geometry. If the geometry is corrupt or can't fix
785
     * it, return null.
786
     *
787
     * @return the new fixed geometry
788
     */
789
    public Geometry makeValid();
790

    
791
    //
792
    // ===============================================
793
    //
794
    /**
795
     * @param affineTransform
796
     * @return the awt shape used to display the geometry. It applies a
797
     * tranformation before to return the coordinates of the shape
798
     * @deprecated this class inherits of {@link Shape} by historical reasons.
799
     * This method has been added just to control the usage of the {@link Shape}
800
     * class but it will removed in a future.
801
     */
802
    public Shape getShape(AffineTransform affineTransform);
803

    
804
    /**
805
     * @return the awt shape used to display the geometry.
806
     * @deprecated this class inherits of {@link Shape} by historical reasons.
807
     * This method has been added just to control the usage of the {@link Shape}
808
     * class but it will removed in a future.
809
     */
810
    public Shape getShape();
811

    
812
    /**
813
     * Returns this geometry's boundary rectangle.
814
     *
815
     * @deprecated use getEnvelope.
816
     * @return Boundary rectangle.
817
     */
818
    @Override
819
    public Rectangle2D getBounds2D();
820

    
821
    /**
822
     * If applies an affine transformation and returns the GeneralPathXIterator
823
     * with this geometry's information.
824
     *
825
     * @param at The transformation to apply.
826
     * @return The GeneralPathXIterator with this geometry's information.
827
     * @deprecated don't use PathIterator over geometries, use instead specific
828
     * API for each operation. If not has API for that operation let the project
829
     * team.
830
     *
831
     */
832
    @Override
833
    public PathIterator getPathIterator(AffineTransform at);
834

    
835
    /**
836
     * It returns the handlers of the geometry, these they can be of two types
837
     * is straightening and of selection.
838
     *
839
     * @param type Type of handlers.
840
     *
841
     * @deprecated don't use Handlers over geometries, use instead specific API
842
     * for each operation. If not has API for that operation let the project
843
     * team.
844
     * @return The handlers.
845
     */
846
    public Handler[] getHandlers(int type);
847

    
848
    /**
849
     * If applies an affine transformation and returns the GeneralPathXIterator
850
     * with this geometry's information.
851
     *
852
     * @param at The affine transformation.
853
     * @param flatness
854
     *
855
     * @return The GeneralPathXIterator with this geometry's information.
856
     * @deprecated don't use PathIterator over geometries, use instead specific
857
     * API for each operation. If not has API for that operation let the project
858
     * team.
859
     */
860
    @Override
861
    PathIterator getPathIterator(AffineTransform at, double flatness);
862

    
863
    /**
864
     * Useful to have the real shape behind the scenes. May be uses to edit it
865
     * knowing it it is a Circle, Ellipse, etc.
866
     *
867
     * @return The awt shape
868
     * @deprecated
869
     */
870
    public Shape getInternalShape();
871

    
872
    /**
873
     * Get GeneralPathIterator, to do registered operations to it.
874
     *
875
     * @return The GeneralPathX.
876
     * @deprecated don't use GeneralPathX over geometries, use instead specific
877
     * API for each operation. If not has API for that operation let the project
878
     * team.
879
     */
880
    public GeneralPathX getGeneralPath();
881

    
882
    /**
883
     * Converts the geometry to be points and makes with them a multiPoint
884
     *
885
     * @return MultiPoint
886
     * @throws GeometryException
887
     */
888
    public MultiPoint toPoints() throws GeometryException;
889

    
890
    /**
891
     * Converts the geometry to be lines and makes with them a multiLine
892
     *
893
     * @return
894
     * @throws GeometryException
895
     */
896
    public MultiLine toLines() throws GeometryException;
897

    
898
    /**
899
     * Converts the geometry to be polygons and makes with them a multiPolygon
900
     *
901
     * @return
902
     * @throws GeometryException
903
     */
904
    public MultiPolygon toPolygons() throws GeometryException;
905

    
906
    /**
907
     * Flip the coordinates of the geometry. If the geometry is aggregate also
908
     * revert the primitives collection.
909
     *
910
     * @throws GeometryOperationNotSupportedException
911
     * @throws GeometryOperationException
912
     */
913
    public void flip() throws GeometryOperationNotSupportedException, GeometryOperationException;
914

    
915
    /**
916
     * Ensures the orientation of the geometry according to the parameter,
917
     * flipping it if necessary. If the geometry is a polygon, ensures the
918
     * orientation of its perimeter and ensures the opposite orientation of
919
     * their holes.
920
     *
921
     * @param ccw
922
     * @return
923
     * @throws GeometryOperationNotSupportedException
924
     * @throws GeometryOperationException
925
     */
926
    public boolean ensureOrientation(boolean ccw) throws GeometryOperationNotSupportedException, GeometryOperationException;
927

    
928
    /**
929
     * Returns true if passed as a parameter geometry is completely out of
930
     * geometry.
931
     *
932
     * @param geometry
933
     * @return
934
     * @throws GeometryOperationNotSupportedException
935
     * @throws GeometryOperationException
936
     */
937
    public boolean out(Geometry geometry) throws GeometryOperationNotSupportedException, GeometryOperationException;
938

    
939
    public Geometry force2D() throws GeometryOperationNotSupportedException, GeometryOperationException;
940
    
941
    /**
942
     * Return true if the geometry can be transformed by the affine transform
943
     *
944
     * @param at the affine transform
945
     * @return
946
     */
947
    public boolean canBeTransformed(AffineTransform at);
948

    
949
    /**
950
     * Return true if the geometry can be reprojected by the coordinate
951
     * transformation
952
     *
953
     * @param ct the coordinate transformation
954
     * @return
955
     */
956
    public boolean canBeReprojected(ICoordTrans ct);
957

    
958
    public void setProjection(String projection);
959

    
960
    public void setProjection(IProjection projection);
961

    
962
    public void setProjectionIffNull(IProjection projection);
963

    
964
    public IProjection getProjection();
965
}