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

History | View | Annotate | Download (29.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
     * Predefined geometry types in the model.
79
     */
80
    public interface TYPES {
81

    
82
        /**
83
         * Any geometry.
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
        public final static int CIRCLE = 11;
139

    
140
        /**
141
         * A continuous portion (as of a circle or ellipse) of a curved line.
142
         */
143
        public final static int ARC = 12;
144

    
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
        public final static int ELLIPSE = 13;
151

    
152
        public final static int SPLINE = 14;
153

    
154
        public final static int ELLIPTICARC = 15;
155

    
156
        /**
157
         * NO DATA geometry.
158
         */
159
        public final static int NULL = 16;
160

    
161
        public final static int COMPLEX = 17;
162

    
163
        public final static int LINE = 18;
164

    
165
        public final static int POLYGON = 19;
166

    
167
        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
    public interface DIMENSIONS {
182

    
183
        public final static int X = 0;
184
        public final static int Y = 1;
185
        public final static int Z = 2;
186
    }
187

    
188
    /**
189
     * The subtype of a geometry is related with the dimension of the geometry,
190
     * that is a combination between the spatial dimension (2D, 2ZD, 3D) and the
191
     * M coordinate or "measure".
192
     *
193
     * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
194
     */
195
    public interface SUBTYPES {
196

    
197
        /**
198
         * Geometries with two dimensions.
199
         */
200
        public final static int GEOM2D = 0;
201

    
202
        /**
203
         * Geometries with three dimensions.
204
         */
205
        public final static int GEOM3D = 1;
206

    
207
        /**
208
         * Geometries with two dimensions and with the M coordinate.
209
         */
210
        public final static int GEOM2DM = 2;
211

    
212
        /**
213
         * Geometries with three dimensions and with the M coordinate.
214
         */
215
        public final static int GEOM3DM = 3;
216

    
217
        /**
218
         * The subtype us unknown.
219
         */
220
        public final static int UNKNOWN = 4;
221
    }
222

    
223
    /**
224
     * Initial value for new geometry types (it must not overlap with the basic
225
     * ones defined in TYPES).
226
     */
227
    public static final int EXTENDED_GEOMTYPE_OFFSET = 17;
228

    
229
    /**
230
     * Initial value for new geometry subtypes (it must not overlap with the
231
     * basic ones defined in SUBTYPES).
232
     */
233
    public static final int EXTENDED_GEOMSUBTYPE_OFFSET = 6;
234

    
235
    public interface OPERATIONS {
236

    
237
        public final static String CONVERTTOWKT = "toWKT";
238
        public final static String CONVERTTOWKB = "toWKB";
239
        public final static String BUFFER = "buffer";
240
        public final static String DISTANCE = "Distance";
241
        public final static String CONTAINS = "Contains";
242
        public final static String OVERLAPS = "OVERLAPS";
243
        public final static String CONVEXHULL = "ConvexHull";
244
        public final static String COVERS = "Covers";
245
        public final static String CROSSES = "Crosses";
246
        public final static String DIFFERENCE = "Difference";
247
        public final static String DISJOIN = "Disjoin";
248
        public final static String INTERSECTION = "Intersaction";
249
        public final static String INTERSECTS = "Intersects";
250
        public final static String TOUCHES = "Touches";
251
        public final static String UNION = "Union";
252
        public final static String WITHIN = "Within";
253
        public final static String COVEREDBY = "CoveredBy";
254
    }
255

    
256
    public interface ValidationStatus {
257

    
258
        public static final int VALID = 0;
259
        public static final int CURRUPTED = 1;
260
        public static final int UNKNOW = 2;
261
        public static final int DISCONNECTED_INTERIOR = 10;
262
        public static final int DUPLICATE_RINGS = 11;
263
        public static final int HOLE_OUTSIDE_SHELL = 12;
264
        public static final int INVALID_COORDINATE = 13;
265
        public static final int NESTED_HOLES = 14;
266
        public static final int NESTED_SHELLS = 15;
267
        public static final int RING_NOT_CLOSED = 17;
268
        public static final int RING_SELF_INTERSECTION = 18;
269
        public static final int SELF_INTERSECTION = 19;
270
        public static final int TOO_FEW_POINTS = 20;
271

    
272
        /**
273
         * True if the geoemtry are valid.
274
         *
275
         * @return true form valid geometries
276
         */
277
        public boolean isValid();
278

    
279
        /**
280
         * Return the status code results of validate the geometry.
281
         *
282
         * @return validation code
283
         */
284
        public int getStatusCode();
285

    
286
        /**
287
         * Return the nearest point to the problem when validate the geometry.
288
         *
289
         * If the geometry is valid, this return null.
290
         *
291
         * @return the nearest point to the problem or null.
292
         */
293
        public Point getProblemLocation();
294

    
295
        /**
296
         * Return a human readable message explaining the cause of the problem.
297
         *
298
         * If the geometry is valid this is null.
299
         *
300
         * @return the message cause of the problem.
301
         */
302
        public String getMessage();
303
    }
304

    
305
    public static int BEST = 0;
306
    /**
307
     * North.
308
     */
309
    public static int N = 1;
310

    
311
    /**
312
     * North - East.
313
     */
314
    public static int NE = 2;
315

    
316
    /**
317
     * East.
318
     */
319
    public static int E = 3;
320

    
321
    /**
322
     * South - East.
323
     */
324
    public static int SE = 4;
325

    
326
    /**
327
     * South.
328
     */
329
    public static int S = 5;
330

    
331
    /**
332
     * South - West.
333
     */
334
    public static int SW = 6;
335

    
336
    /**
337
     * West.
338
     */
339
    public static int W = 7;
340

    
341
    /**
342
     * North - West.
343
     */
344
    public static int NW = 8;
345

    
346
    public static int SELECTHANDLER = 0;
347
    public static int STRETCHINGHANDLER = 1;
348

    
349
    /**
350
     * If this geometry is a predefined interface then this method returns one
351
     * of {@link Geometry.TYPES} contants.<br>
352
     * If this geometry is an extended type then this method returns a runtime
353
     * constant that identifies its type. By convention this value is stored in
354
     * a constant called .CODE within the geometry class, for instance:
355
     * Point2D.CODE.
356
     *
357
     * @return If this geometry is a predefined interface then one of
358
     * {@link Geometry.TYPES} or a runtime constant if it is an extended type.
359
     */
360
    public int getType();
361

    
362
    /**
363
     * Creates a clone of this geometry.
364
     *
365
     * @return A clone of this geometry.
366
     */
367
    public Geometry cloneGeometry();
368
    
369
    public Geometry clone() throws CloneNotSupportedException;
370

    
371
    /**
372
     * Returns true if this geometry intersects the rectangle passed as
373
     * parameter.
374
     *
375
     * @param r Rectangle.
376
     *
377
     * @return True, if <code>this</code> intersects <code>r</code>.
378
     */
379
    public boolean intersects(Rectangle2D r);
380

    
381
    /**
382
     * Used by the drawing strategies to quickly test whether this geometry
383
     * intersects with the visible rectangle.
384
     *
385
     * @param x The minimum X coordinate.
386
     * @param y The minimum Y coordinate.
387
     * @param w The width of the envelope.
388
     * @param h The height of the envelope.
389
     * @return true if <code>this</code> intersects the rectangle defined by the
390
     * parameters.
391
     */
392
    public boolean fastIntersects(double x, double y, double w, double h);
393

    
394
    /**
395
     * <p>
396
     * Returns the minimum bounding box for this Geometry. This shall be the
397
     * coordinate region spanning the minimum and maximum value for each
398
     * ordinate taken on by DirectPositions in this Geometry. The simplest
399
     * representation for an envelope consists of two DirectPositions, the first
400
     * one containing all the minimums for each ordinate, and second one
401
     * containing all the maximums.
402
     * </p>
403
     *
404
     * @return The minimum bounding box for this Geometry.
405
     */
406
    public Envelope getEnvelope();
407

    
408
    /**
409
     * Reprojects this geometry by the coordinate transformer passed as
410
     * parameter.
411
     *
412
     * @param ct Coordinate Transformer.
413
     */
414
    public void reProject(ICoordTrans ct);
415

    
416
    /**
417
     * It applies an affine transformation to the geometry. If parameter value
418
     * is null, it will be considered an empty transformation, therefore
419
     * equivalent to the identity transformation.
420
     *
421
     * @param at The transformation to apply.
422
     */
423
    public void transform(AffineTransform at);
424

    
425
    /**
426
     * Returns the largest number n such that each direct position in a
427
     * geometric set can be associated with a subset that has the direct
428
     * position in its interior and is similar (isomorphic) to Rn, Euclidean
429
     * n-space.
430
     *
431
     * @return The dimension.
432
     */
433
    public int getDimension();
434

    
435
    /**
436
     * Returns <code>true</code> if this Geometry has no interior point of
437
     * self-intersection or self-tangency. In mathematical formalisms, this
438
     * means that every point in the interior of the object must have a metric
439
     * neighborhood whose intersection with the object is isomorphic to an
440
     * n-sphere, where n is the dimension of this Geometry.
441
     *
442
     * @return If the geometry is simple.
443
     */
444
    public boolean isSimple();
445

    
446
    public boolean isCCW()
447
            throws GeometryOperationNotSupportedException,
448
            GeometryOperationException;
449

    
450
    /**
451
     * Invokes a geometry operation given its index and context.
452
     *
453
     * @param index Unique index of the operation. Operation code.
454
     * @param ctx The context of the geometry operation.
455
     * @return Object returned by the operation.
456
     * @throws GeometryOperationNotSupportedException It is thrown when the
457
     * operation has been not registered for this geometry.
458
     * @throws GeometryOperationException It is thrown when there is an error
459
     * executing the operation.
460
     */
461
    public Object invokeOperation(int index, GeometryOperationContext ctx)
462
            throws GeometryOperationNotSupportedException,
463
            GeometryOperationException;
464

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

    
480
    /**
481
     * Instance of the GeometryType associated to this geometry.
482
     *
483
     * @return The geometry type.
484
     */
485
    public GeometryType getGeometryType();
486

    
487
    public Object convertTo(String format) throws GeometryOperationNotSupportedException,
488
            GeometryOperationException;
489

    
490
    /**
491
     * Return a byte array with the equivalent in WKB format of the Geometry.
492
     *
493
     * Utility method to wrap the invocation to the operation
494
     * {@link OPERATIONS#CONVERTTOWKB}.
495
     *
496
     * @return the WKB version of the geometry
497
     */
498
    public byte[] convertToWKB() throws GeometryOperationNotSupportedException,
499
            GeometryOperationException;
500

    
501
    public byte[] convertToWKB(int srs)
502
            throws GeometryOperationNotSupportedException, GeometryOperationException;
503

    
504
    public byte[] convertToWKBForcingType(int srs, int type)
505
            throws GeometryOperationNotSupportedException, GeometryOperationException;
506

    
507
    /**
508
     * Return a byte array with the equivalent in EWKB format of the Geometry.
509
     *
510
     * Utility method to wrap the invocation to the operation
511
     * {@link OPERATIONS#CONVERTTOEWKB}.
512
     *
513
     * @return the EWKB version of the geometry
514
     */
515
    public byte[] convertToEWKB() throws GeometryOperationNotSupportedException, GeometryOperationException;
516

    
517
    public byte[] convertToEWKB(int srs)
518
            throws GeometryOperationNotSupportedException, GeometryOperationException;
519

    
520
    public byte[] convertToEWKBForcingType(int srs, int type)
521
            throws GeometryOperationNotSupportedException, GeometryOperationException;
522

    
523
    /**
524
     * Return a string with the equivalent in WKT format of the Geometry.
525
     *
526
     * This is a utility method to wrap the invocation to the operation
527
     * {@link OPERATIONS#CONVERTTOWKT}.
528
     *
529
     * @return the WKT version of the geometry.
530
     *
531
     * @throws GeometryOperationNotSupportedException
532
     * @throws GeometryOperationException
533
     */
534
    public String convertToWKT() throws GeometryOperationNotSupportedException,
535
            GeometryOperationException;
536

    
537
    /**
538
     * Computes a buffer area around this geometry having the given width
539
     *
540
     * This is a utility method to wrap the invocation to the operation
541
     * {@link OPERATIONS#BUFFER}.
542
     *
543
     * @param distance the width of the buffer
544
     *
545
     * @return a new Geometry with the computed buffer.
546
     *
547
     * @throws GeometryOperationNotSupportedException
548
     * @throws GeometryOperationException
549
     */
550
    public Geometry buffer(double distance)
551
            throws GeometryOperationNotSupportedException,
552
            GeometryOperationException;
553

    
554
    public Geometry offset(double distance)
555
            throws GeometryOperationNotSupportedException,
556
            GeometryOperationException;
557

    
558
    /**
559
     * Tests whether this geometry contains the specified geometry.
560
     *
561
     * This is a utility method to wrap the invocation to the operation
562
     * {@link OPERATIONS#CONTAINS}.
563
     *
564
     * @param geometry the Geometry with which to compare this Geometry
565
     *
566
     * @return if this Geometry contains the specified geometry
567
     *
568
     * @throws GeometryOperationNotSupportedException
569
     * @throws GeometryOperationException
570
     */
571
    public boolean contains(Geometry geometry)
572
            throws GeometryOperationNotSupportedException,
573
            GeometryOperationException;
574

    
575
    /**
576
     * Returns the minimum distance between this Geometry and the specified
577
     * geometry.
578
     *
579
     * This is a utility method to wrap the invocation to the operation
580
     * {@link OPERATIONS#DISTANCE}.
581
     *
582
     * @param geometry the Geometry from which to compute the distance
583
     *
584
     * @return the distance between the geometries
585
     *
586
     * @throws GeometryOperationNotSupportedException
587
     * @throws GeometryOperationException
588
     */
589
    public double distance(Geometry other)
590
            throws GeometryOperationNotSupportedException,
591
            GeometryOperationException;
592

    
593
    public Geometry[] closestPoints(Geometry other)
594
            throws GeometryOperationNotSupportedException,
595
            GeometryOperationException;
596

    
597
    boolean isWithinDistance(Geometry other, double distance)
598
            throws GeometryOperationNotSupportedException,
599
            GeometryOperationException;
600

    
601
    /**
602
     * Tests whether this geometry overlaps the specified geometry.
603
     *
604
     * This is a utility method to wrap the invocation to the operation
605
     * {@link OPERATIONS#OVERLAPS}.
606
     *
607
     * @param geometry the Geometry with which to compare this Geometry
608
     *
609
     * @return true if the two geometries overlap.
610
     *
611
     * @throws GeometryOperationNotSupportedException
612
     * @throws GeometryOperationException
613
     */
614
    public boolean overlaps(Geometry geometry)
615
            throws GeometryOperationNotSupportedException,
616
            GeometryOperationException;
617

    
618
    public Geometry convexHull() throws GeometryOperationNotSupportedException,
619
            GeometryOperationException;
620

    
621
    public boolean coveredBy(Geometry geometry)
622
            throws GeometryOperationNotSupportedException,
623
            GeometryOperationException;
624

    
625
    public boolean covers(Geometry geometry)
626
            throws GeometryOperationNotSupportedException,
627
            GeometryOperationException;
628

    
629
    public boolean crosses(Geometry geometry)
630
            throws GeometryOperationNotSupportedException,
631
            GeometryOperationException;
632

    
633
    public Geometry difference(Geometry other)
634
            throws GeometryOperationNotSupportedException,
635
            GeometryOperationException;
636

    
637
    public boolean disjoint(Geometry geometry)
638
            throws GeometryOperationNotSupportedException,
639
            GeometryOperationException;
640

    
641
    public Geometry intersection(Geometry other)
642
            throws GeometryOperationNotSupportedException,
643
            GeometryOperationException;
644

    
645
    public boolean intersects(Geometry geometry)
646
            throws GeometryOperationNotSupportedException,
647
            GeometryOperationException;
648

    
649
    public Geometry snapTo(Geometry other, double snapTolerance)
650
            throws GeometryOperationNotSupportedException,
651
            GeometryOperationException;
652

    
653
    public boolean touches(Geometry geometry)
654
            throws GeometryOperationNotSupportedException,
655
            GeometryOperationException;
656

    
657
    public Geometry union(Geometry other)
658
            throws GeometryOperationNotSupportedException,
659
            GeometryOperationException;
660

    
661
    public boolean within(Geometry geometry)
662
            throws GeometryOperationNotSupportedException,
663
            GeometryOperationException;
664

    
665
    public Point centroid() throws GeometryOperationNotSupportedException, GeometryOperationException;
666

    
667
    /**
668
     * This method returns a point which is inside the geometry. This is useful
669
     * for mathematical purposes but it is very unlikely to be a suitable place
670
     * for a label, for example.
671
     *
672
     *
673
     * @return an interior point
674
     * @throws GeometryOperationNotSupportedException
675
     * @throws GeometryOperationException
676
     */
677
    public Point getInteriorPoint() throws GeometryOperationNotSupportedException, GeometryOperationException;
678

    
679
    public double area() throws GeometryOperationNotSupportedException, GeometryOperationException;
680

    
681
    public double perimeter() throws GeometryOperationNotSupportedException, GeometryOperationException;
682

    
683
    /**
684
     * Rotates the geometry by radAngle radians using the given coordinates as
685
     * center of rotation. Rotating with a positive angle rotates points on the
686
     * positive x axis toward the positive y axis. In most cases, we assume x
687
     * increases rightwards and y increases upwards, so in most cases, a
688
     * positive angle will mean counter-clockwise rotation.
689
     *
690
     * @param radAngle the amount of rotation, in radians
691
     * @param basex x coordinate of center of rotation
692
     * @param basey y coordinate of center of rotation
693
     */
694
    public void rotate(double radAngle, double basex, double basey);
695

    
696
    /**
697
     * Shifts geometry by given amount in x and y axes
698
     *
699
     * @param dx
700
     * @param dy
701
     */
702
    public void move(double dx, double dy);
703

    
704
    /**
705
     * Scales geometry in x and y axes by given scale factors using the given
706
     * point as center of projection.
707
     *
708
     * @param basePoint
709
     * @param sx scale factor in x axis
710
     * @param sy scale factor in y axis
711
     */
712
    public void scale(Point basePoint, double sx, double sy);
713

    
714
    /**
715
     * Check if the geometry is valid.
716
     *
717
     * @return true if the geometry is valid.
718
     */
719
    public boolean isValid();
720

    
721
    /**
722
     * Check if the geometry is valid and returns the validation status.
723
     *
724
     * @return the ValidationStatus
725
     */
726
    public ValidationStatus getValidationStatus();
727

    
728
    /**
729
     * Try to fix the geometry and return the new geometry. If the geometry is
730
     * valid return the same geometry. If the geometry is corrupt or can't fix
731
     * it, return null.
732
     *
733
     * @return the new fixed geometry
734
     */
735
    public Geometry makeValid();
736

    
737
    //
738
    // ===============================================
739
    //
740
    /**
741
     * @return the awt shape used to display the geometry. It applies a
742
     * tranformation before to return the coordinates of the shape
743
     * @deprecated this class inherits of {@link Shape} by historical reasons.
744
     * This method has been added just to control the usage of the {@link Shape}
745
     * class but it will removed in a future.
746
     */
747
    public Shape getShape(AffineTransform affineTransform);
748

    
749
    /**
750
     * @return the awt shape used to display the geometry.
751
     * @deprecated this class inherits of {@link Shape} by historical reasons.
752
     * This method has been added just to control the usage of the {@link Shape}
753
     * class but it will removed in a future.
754
     */
755
    public Shape getShape();
756

    
757
    /**
758
     * Returns this geometry's boundary rectangle.
759
     *
760
     * @deprecated use getEnvelope.
761
     * @return Boundary rectangle.
762
     */
763
    public Rectangle2D getBounds2D();
764

    
765
    /**
766
     * If applies an affine transformation and returns the GeneralPathXIterator
767
     * with this geometry's information.
768
     *
769
     * @param at The transformation to apply.
770
     * @return The GeneralPathXIterator with this geometry's information.
771
     * @deprecated don't use PathIterator over geometries, use instead specific
772
     * API for each operation. If not has API for that operation let the project
773
     * team.
774
     *
775
     */
776
    public PathIterator getPathIterator(AffineTransform at);
777

    
778
    /**
779
     * It returns the handlers of the geometry, these they can be of two types
780
     * is straightening and of selection.
781
     *
782
     * @param type Type of handlers.
783
     *
784
     * @deprecated don't use Handlers over geometries, use instead specific API
785
     * for each operation. If not has API for that operation let the project
786
     * team.
787
     * @return The handlers.
788
     */
789
    public Handler[] getHandlers(int type);
790

    
791
    /**
792
     * If applies an affine transformation and returns the GeneralPathXIterator
793
     * with this geometry's information.
794
     *
795
     * @param at The affine transformation.
796
     * @param flatness
797
     *
798
     * @return The GeneralPathXIterator with this geometry's information.
799
     * @deprecated don't use PathIterator over geometries, use instead specific
800
     * API for each operation. If not has API for that operation let the project
801
     * team.
802
     */
803
    @Override
804
    PathIterator getPathIterator(AffineTransform at, double flatness);
805

    
806
    /**
807
     * Useful to have the real shape behind the scenes. May be uses to edit it
808
     * knowing it it is a Circle, Ellipse, etc.
809
     *
810
     * @return The awt shape
811
     * @deprecated
812
     */
813
    public Shape getInternalShape();
814

    
815
    /**
816
     * Get GeneralPathIterator, to do registered operations to it.
817
     *
818
     * @return The GeneralPathX.
819
     * @deprecated don't use GeneralPathX over geometries, use instead specific
820
     * API for each operation. If not has API for that operation let the project
821
     * team.
822
     */
823
    public GeneralPathX getGeneralPath();
824

    
825
    /**
826
     * Converts the geometry to be points and makes with them a multiPoint
827
     *
828
     * @return MultiPoint
829
     * @throws GeometryException
830
     */
831
    public MultiPoint toPoints() throws GeometryException;
832

    
833
    /**
834
     * Converts the geometry to be lines and makes with them a multiLine
835
     *
836
     * @return
837
     * @throws GeometryException
838
     */
839
    public MultiLine toLines() throws GeometryException;
840

    
841
    /**
842
     * Converts the geometry to be polygons and makes with them a multiPolygon
843
     *
844
     * @return
845
     * @throws GeometryException
846
     */
847
    public MultiPolygon toPolygons() throws GeometryException;
848

    
849
    /**
850
     * Flip the coordinates of the geometry. If the geometry is aggregate also
851
     * revert the primitives collection.
852
     *
853
     * @throws GeometryOperationNotSupportedException
854
     * @throws GeometryOperationException
855
     */
856
    public void flip() throws GeometryOperationNotSupportedException, GeometryOperationException;
857

    
858
    /**
859
     * Ensures the orientation of the geometry according to the parameter,
860
     * flipping it if necessary. If the geometry is a polygon, ensures the
861
     * orientation of its perimeter and ensures the opposite orientation of
862
     * their holes.
863
     *
864
     * @param ccw
865
     * @return
866
     * @throws GeometryOperationNotSupportedException
867
     * @throws GeometryOperationException
868
     */
869
    public boolean ensureOrientation(boolean ccw) throws GeometryOperationNotSupportedException, GeometryOperationException;
870

    
871
    /**
872
     * Returns true if passed as a parameter geometry is completely out of
873
     * geometry.
874
     *
875
     * @param geometry
876
     * @return
877
     * @throws GeometryOperationNotSupportedException
878
     * @throws GeometryOperationException
879
     */
880
    public boolean out(Geometry geometry) throws GeometryOperationNotSupportedException, GeometryOperationException;
881

    
882
    /**
883
     * Return true if the geometry can be transformed by the affine transform
884
     *
885
     * @param at the affine transform
886
     * @return
887
     */
888
    public boolean canBeTransformed(AffineTransform at);
889

    
890
    /**
891
     * Return true if the geometry can be reprojected by the coordinate
892
     * transformation
893
     *
894
     * @param ct the coordinate transformation
895
     * @return
896
     */
897
    public boolean canBeReprojected(ICoordTrans ct);
898

    
899
    public void setProjection(IProjection projection);
900

    
901
    public void setProjectionIffNull(IProjection projection);
902

    
903
    public IProjection getProjection();
904
}