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

History | View | Annotate | Download (29.4 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 {
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
    /**
370
     * Returns true if this geometry intersects the rectangle passed as
371
     * parameter.
372
     *
373
     * @param r Rectangle.
374
     *
375
     * @return True, if <code>this</code> intersects <code>r</code>.
376
     */
377
    public boolean intersects(Rectangle2D r);
378

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

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

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

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

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

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

    
444
    public boolean isCCW()
445
            throws GeometryOperationNotSupportedException,
446
            GeometryOperationException;
447

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

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

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

    
485
    public Object convertTo(String format) throws GeometryOperationNotSupportedException,
486
            GeometryOperationException;
487

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

    
499
    public byte[] convertToWKB(int srs)
500
            throws GeometryOperationNotSupportedException, GeometryOperationException;
501

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

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

    
515
    public byte[] convertToEWKB(int srs)
516
            throws GeometryOperationNotSupportedException, GeometryOperationException;
517

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

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

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

    
552
    public Geometry offset(double distance)
553
            throws GeometryOperationNotSupportedException,
554
            GeometryOperationException;
555

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

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

    
591
    public Geometry[] closestPoints(Geometry other)
592
            throws GeometryOperationNotSupportedException,
593
            GeometryOperationException;
594

    
595
    boolean isWithinDistance(Geometry other, double distance)
596
            throws GeometryOperationNotSupportedException,
597
            GeometryOperationException;
598

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

    
616
    public Geometry convexHull() throws GeometryOperationNotSupportedException,
617
            GeometryOperationException;
618

    
619
    public boolean coveredBy(Geometry geometry)
620
            throws GeometryOperationNotSupportedException,
621
            GeometryOperationException;
622

    
623
    public boolean covers(Geometry geometry)
624
            throws GeometryOperationNotSupportedException,
625
            GeometryOperationException;
626

    
627
    public boolean crosses(Geometry geometry)
628
            throws GeometryOperationNotSupportedException,
629
            GeometryOperationException;
630

    
631
    public Geometry difference(Geometry other)
632
            throws GeometryOperationNotSupportedException,
633
            GeometryOperationException;
634

    
635
    public boolean disjoint(Geometry geometry)
636
            throws GeometryOperationNotSupportedException,
637
            GeometryOperationException;
638

    
639
    public Geometry intersection(Geometry other)
640
            throws GeometryOperationNotSupportedException,
641
            GeometryOperationException;
642

    
643
    public boolean intersects(Geometry geometry)
644
            throws GeometryOperationNotSupportedException,
645
            GeometryOperationException;
646

    
647
    public Geometry snapTo(Geometry other, double snapTolerance)
648
            throws GeometryOperationNotSupportedException,
649
            GeometryOperationException;
650

    
651
    public boolean touches(Geometry geometry)
652
            throws GeometryOperationNotSupportedException,
653
            GeometryOperationException;
654

    
655
    public Geometry union(Geometry other)
656
            throws GeometryOperationNotSupportedException,
657
            GeometryOperationException;
658

    
659
    public boolean within(Geometry geometry)
660
            throws GeometryOperationNotSupportedException,
661
            GeometryOperationException;
662

    
663
    public Point centroid() throws GeometryOperationNotSupportedException, GeometryOperationException;
664

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

    
677
    public double area() throws GeometryOperationNotSupportedException, GeometryOperationException;
678

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
897
    public void setProjection(IProjection projection);
898

    
899
    public void setProjectionIffNull(IProjection projection);
900

    
901
    public IProjection getProjection();
902
}