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

History | View | Annotate | Download (30.3 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
        public final static int UNKNOWN = -1;
83
        /**
84
         * Any geometry.
85
         */
86
        public final static int GEOMETRY = 0;
87

    
88
        /**
89
         * A geometric element that has zero dimensions and a location
90
         * determinable by an ordered set of coordinates.
91
         */
92
        public final static int POINT = 1;
93

    
94
        /**
95
         * A straight or curved geometric element that is generated by a moving
96
         * point and that has extension only along the path of the point.
97
         */
98
        public final static int CURVE = 2;
99

    
100
        /**
101
         * A closed plane figure bounded by straight lines.
102
         */
103
        public final static int SURFACE = 3;
104

    
105
        /**
106
         * Solids in 3D.
107
         */
108
        public final static int SOLID = 4;
109

    
110
        /**
111
         * A set that can contain points, lines and polygons. This is usual in
112
         * <i>CAD</i> layers <i>(dxf, dgn, dwg)</i>.
113
         */
114
        public final static int AGGREGATE = 6;
115
        /**
116
         * A set of points.
117
         */
118
        public final static int MULTIPOINT = 7;
119

    
120
        /**
121
         * A set of lines.
122
         */
123
        public final static int MULTICURVE = 8;
124

    
125
        /**
126
         * A set of polygons.
127
         */
128
        public final static int MULTISURFACE = 9;
129

    
130
        /**
131
         * A set of solids.
132
         */
133
        public final static int MULTISOLID = 10;
134

    
135
        /**
136
         * A closed plane curve every point of which is equidistant from a fixed
137
         * point within the curve.
138
         */
139
        public final static int CIRCLE = 11;
140

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

    
146
        /**
147
         * A closed plane curve generated by a point moving in such a way that
148
         * the sums of its distances from two fixed points is a constant : a
149
         * plane section of a right circular cone that is a closed curve.
150
         */
151
        public final static int ELLIPSE = 13;
152

    
153
        public final static int SPLINE = 14;
154

    
155
        public final static int ELLIPTICARC = 15;
156

    
157
        /**
158
         * NO DATA geometry.
159
         */
160
        @Deprecated
161
        public final static int NULL = 16;
162

    
163
        public final static int COMPLEX = 17;
164

    
165
        public final static int LINE = 18;
166

    
167
        public final static int POLYGON = 19;
168

    
169
        public final static int RING = 20;
170

    
171
        public final static int MULTILINE = 21;
172

    
173
        public final static int MULTIPOLYGON = 22;
174

    
175
        public final static int CIRCUMFERENCE = 23;
176

    
177
        public final static int PERIELLIPSE = 24;
178

    
179
        public final static int FILLEDSPLINE = 25;
180

    
181
    }
182

    
183
    public interface DIMENSIONS {
184

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

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

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

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

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

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

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

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

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

    
237
    public interface OPERATIONS {
238

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

    
258
    public interface ValidationStatus {
259

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

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

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

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

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

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

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

    
318
    /**
319
     * East.
320
     */
321
    public static int E = 3;
322

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

    
328
    /**
329
     * South.
330
     */
331
    public static int S = 5;
332

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

    
338
    /**
339
     * West.
340
     */
341
    public static int W = 7;
342

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

    
348
    public static int SELECTHANDLER = 0;
349
    public static int STRETCHINGHANDLER = 1;
350

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

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

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

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

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

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

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

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

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

    
449
    public boolean isCCW()
450
            throws GeometryOperationNotSupportedException,
451
            GeometryOperationException;
452

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

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

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

    
490
    public Object convertTo(String format) throws GeometryOperationNotSupportedException,
491
            GeometryOperationException;
492

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

    
506
    public String convertToHexWKB() throws GeometryOperationNotSupportedException,
507
            GeometryOperationException;
508

    
509
    public byte[] convertToWKBQuietly();
510

    
511
    public String convertToHexWKBQuietly();
512

    
513
    public byte[] convertToWKB(int srs)
514
            throws GeometryOperationNotSupportedException, GeometryOperationException;
515

    
516
    public byte[] convertToWKBForcingType(int srs, int type)
517
            throws GeometryOperationNotSupportedException, GeometryOperationException;
518

    
519
    /**
520
     * Return a byte array with the equivalent in EWKB format of the Geometry.
521
     *
522
     * Utility method to wrap the invocation to the operation
523
     * {@link OPERATIONS#CONVERTTOEWKB}.
524
     *
525
     * @return the EWKB version of the geometry
526
     * @throws org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException
527
     * @throws org.gvsig.fmap.geom.operation.GeometryOperationException
528
     */
529
    public byte[] convertToEWKB() throws GeometryOperationNotSupportedException, GeometryOperationException;
530

    
531
    public byte[] convertToEWKB(int srs)
532
            throws GeometryOperationNotSupportedException, GeometryOperationException;
533

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

    
537
    /**
538
     * Return a string with the equivalent in WKT format of the Geometry.
539
     *
540
     * This is a utility method to wrap the invocation to the operation
541
     * {@link OPERATIONS#CONVERTTOWKT}.
542
     *
543
     * @return the WKT version of the geometry.
544
     *
545
     * @throws GeometryOperationNotSupportedException
546
     * @throws GeometryOperationException
547
     */
548
    public String convertToWKT() throws GeometryOperationNotSupportedException,
549
            GeometryOperationException;
550

    
551
    public String convertToWKTQuietly();
552
    
553
    /**
554
     * Computes a buffer area around this geometry having the given width
555
     *
556
     * This is a utility method to wrap the invocation to the operation
557
     * {@link OPERATIONS#BUFFER}.
558
     *
559
     * @param distance the width of the buffer
560
     *
561
     * @return a new Geometry with the computed buffer.
562
     *
563
     * @throws GeometryOperationNotSupportedException
564
     * @throws GeometryOperationException
565
     */
566
    public Geometry buffer(double distance)
567
            throws GeometryOperationNotSupportedException,
568
            GeometryOperationException;
569

    
570
    public Geometry offset(double distance)
571
            throws GeometryOperationNotSupportedException,
572
            GeometryOperationException;
573

    
574
    /**
575
     * Tests whether this geometry contains the specified geometry.
576
     *
577
     * This is a utility method to wrap the invocation to the operation
578
     * {@link OPERATIONS#CONTAINS}.
579
     *
580
     * @param geometry the Geometry with which to compare this Geometry
581
     *
582
     * @return if this Geometry contains the specified geometry
583
     *
584
     * @throws GeometryOperationNotSupportedException
585
     * @throws GeometryOperationException
586
     */
587
    public boolean contains(Geometry geometry)
588
            throws GeometryOperationNotSupportedException,
589
            GeometryOperationException;
590

    
591
    /**
592
     * Returns the minimum distance between this Geometry and the specified
593
     * geometry.
594
     *
595
     * This is a utility method to wrap the invocation to the operation
596
     * {@link OPERATIONS#DISTANCE}.
597
     *
598
     * @param other
599
     * @return the distance between the geometries
600
     *
601
     * @throws GeometryOperationNotSupportedException
602
     * @throws GeometryOperationException
603
     */
604
    public double distance(Geometry other)
605
            throws GeometryOperationNotSupportedException,
606
            GeometryOperationException;
607

    
608
    public Geometry[] closestPoints(Geometry other)
609
            throws GeometryOperationNotSupportedException,
610
            GeometryOperationException;
611

    
612
    boolean isWithinDistance(Geometry other, double distance)
613
            throws GeometryOperationNotSupportedException,
614
            GeometryOperationException;
615

    
616
    /**
617
     * Tests whether this geometry overlaps the specified geometry.
618
     *
619
     * This is a utility method to wrap the invocation to the operation
620
     * {@link OPERATIONS#OVERLAPS}.
621
     *
622
     * @param geometry the Geometry with which to compare this Geometry
623
     *
624
     * @return true if the two geometries overlap.
625
     *
626
     * @throws GeometryOperationNotSupportedException
627
     * @throws GeometryOperationException
628
     */
629
    public boolean overlaps(Geometry geometry)
630
            throws GeometryOperationNotSupportedException,
631
            GeometryOperationException;
632

    
633
    public Geometry convexHull() throws GeometryOperationNotSupportedException,
634
            GeometryOperationException;
635

    
636
    public boolean coveredBy(Geometry geometry)
637
            throws GeometryOperationNotSupportedException,
638
            GeometryOperationException;
639

    
640
    public boolean covers(Geometry geometry)
641
            throws GeometryOperationNotSupportedException,
642
            GeometryOperationException;
643

    
644
    public boolean crosses(Geometry geometry)
645
            throws GeometryOperationNotSupportedException,
646
            GeometryOperationException;
647

    
648
    public Geometry difference(Geometry other)
649
            throws GeometryOperationNotSupportedException,
650
            GeometryOperationException;
651

    
652
    public boolean disjoint(Geometry geometry)
653
            throws GeometryOperationNotSupportedException,
654
            GeometryOperationException;
655

    
656
    public Geometry intersection(Geometry other)
657
            throws GeometryOperationNotSupportedException,
658
            GeometryOperationException;
659

    
660
    public boolean intersects(Geometry geometry)
661
            throws GeometryOperationNotSupportedException,
662
            GeometryOperationException;
663

    
664
    public Geometry snapTo(Geometry other, double snapTolerance)
665
            throws GeometryOperationNotSupportedException,
666
            GeometryOperationException;
667

    
668
    public boolean touches(Geometry geometry)
669
            throws GeometryOperationNotSupportedException,
670
            GeometryOperationException;
671

    
672
    public Geometry union(Geometry other)
673
            throws GeometryOperationNotSupportedException,
674
            GeometryOperationException;
675

    
676
    public boolean within(Geometry geometry)
677
            throws GeometryOperationNotSupportedException,
678
            GeometryOperationException;
679

    
680
    public Point centroid() throws GeometryOperationNotSupportedException, GeometryOperationException;
681

    
682
    /**
683
     * This method returns a point which is inside the geometry. This is useful
684
     * for mathematical purposes but it is very unlikely to be a suitable place
685
     * for a label, for example.
686
     *
687
     *
688
     * @return an interior point
689
     * @throws GeometryOperationNotSupportedException
690
     * @throws GeometryOperationException
691
     */
692
    public Point getInteriorPoint() throws GeometryOperationNotSupportedException, GeometryOperationException;
693

    
694
    public double area() throws GeometryOperationNotSupportedException, GeometryOperationException;
695

    
696
    public double perimeter() throws GeometryOperationNotSupportedException, GeometryOperationException;
697

    
698
    /**
699
     * Rotates the geometry by radAngle radians using the given coordinates as
700
     * center of rotation. Rotating with a positive angle rotates points on the
701
     * positive x axis toward the positive y axis. In most cases, we assume x
702
     * increases rightwards and y increases upwards, so in most cases, a
703
     * positive angle will mean counter-clockwise rotation.
704
     *
705
     * @param radAngle the amount of rotation, in radians
706
     * @param basex x coordinate of center of rotation
707
     * @param basey y coordinate of center of rotation
708
     */
709
    public void rotate(double radAngle, double basex, double basey);
710

    
711
    /**
712
     * Shifts geometry by given amount in x and y axes
713
     *
714
     * @param dx
715
     * @param dy
716
     */
717
    public void move(double dx, double dy);
718

    
719
    /**
720
     * Scales geometry in x and y axes by given scale factors using the given
721
     * point as center of projection.
722
     *
723
     * @param basePoint
724
     * @param sx scale factor in x axis
725
     * @param sy scale factor in y axis
726
     */
727
    public void scale(Point basePoint, double sx, double sy);
728

    
729
    /**
730
     * Check if the geometry is valid.
731
     *
732
     * @return true if the geometry is valid.
733
     */
734
    public boolean isValid();
735

    
736
    /**
737
     * Check if the geometry is valid and returns the validation status.
738
     *
739
     * @return the ValidationStatus
740
     */
741
    public ValidationStatus getValidationStatus();
742

    
743
    /**
744
     * Try to fix the geometry and return the new geometry. If the geometry is
745
     * valid return the same geometry. If the geometry is corrupt or can't fix
746
     * it, return null.
747
     *
748
     * @return the new fixed geometry
749
     */
750
    public Geometry makeValid();
751

    
752
    //
753
    // ===============================================
754
    //
755
    /**
756
     * @param affineTransform
757
     * @return the awt shape used to display the geometry. It applies a
758
     * tranformation before to return the coordinates of the shape
759
     * @deprecated this class inherits of {@link Shape} by historical reasons.
760
     * This method has been added just to control the usage of the {@link Shape}
761
     * class but it will removed in a future.
762
     */
763
    public Shape getShape(AffineTransform affineTransform);
764

    
765
    /**
766
     * @return the awt shape used to display the geometry.
767
     * @deprecated this class inherits of {@link Shape} by historical reasons.
768
     * This method has been added just to control the usage of the {@link Shape}
769
     * class but it will removed in a future.
770
     */
771
    public Shape getShape();
772

    
773
    /**
774
     * Returns this geometry's boundary rectangle.
775
     *
776
     * @deprecated use getEnvelope.
777
     * @return Boundary rectangle.
778
     */
779
    @Override
780
    public Rectangle2D getBounds2D();
781

    
782
    /**
783
     * If applies an affine transformation and returns the GeneralPathXIterator
784
     * with this geometry's information.
785
     *
786
     * @param at The transformation to apply.
787
     * @return The GeneralPathXIterator with this geometry's information.
788
     * @deprecated don't use PathIterator over geometries, use instead specific
789
     * API for each operation. If not has API for that operation let the project
790
     * team.
791
     *
792
     */
793
    @Override
794
    public PathIterator getPathIterator(AffineTransform at);
795

    
796
    /**
797
     * It returns the handlers of the geometry, these they can be of two types
798
     * is straightening and of selection.
799
     *
800
     * @param type Type of handlers.
801
     *
802
     * @deprecated don't use Handlers over geometries, use instead specific API
803
     * for each operation. If not has API for that operation let the project
804
     * team.
805
     * @return The handlers.
806
     */
807
    public Handler[] getHandlers(int type);
808

    
809
    /**
810
     * If applies an affine transformation and returns the GeneralPathXIterator
811
     * with this geometry's information.
812
     *
813
     * @param at The affine transformation.
814
     * @param flatness
815
     *
816
     * @return The GeneralPathXIterator with this geometry's information.
817
     * @deprecated don't use PathIterator over geometries, use instead specific
818
     * API for each operation. If not has API for that operation let the project
819
     * team.
820
     */
821
    @Override
822
    PathIterator getPathIterator(AffineTransform at, double flatness);
823

    
824
    /**
825
     * Useful to have the real shape behind the scenes. May be uses to edit it
826
     * knowing it it is a Circle, Ellipse, etc.
827
     *
828
     * @return The awt shape
829
     * @deprecated
830
     */
831
    public Shape getInternalShape();
832

    
833
    /**
834
     * Get GeneralPathIterator, to do registered operations to it.
835
     *
836
     * @return The GeneralPathX.
837
     * @deprecated don't use GeneralPathX over geometries, use instead specific
838
     * API for each operation. If not has API for that operation let the project
839
     * team.
840
     */
841
    public GeneralPathX getGeneralPath();
842

    
843
    /**
844
     * Converts the geometry to be points and makes with them a multiPoint
845
     *
846
     * @return MultiPoint
847
     * @throws GeometryException
848
     */
849
    public MultiPoint toPoints() throws GeometryException;
850

    
851
    /**
852
     * Converts the geometry to be lines and makes with them a multiLine
853
     *
854
     * @return
855
     * @throws GeometryException
856
     */
857
    public MultiLine toLines() throws GeometryException;
858

    
859
    /**
860
     * Converts the geometry to be polygons and makes with them a multiPolygon
861
     *
862
     * @return
863
     * @throws GeometryException
864
     */
865
    public MultiPolygon toPolygons() throws GeometryException;
866

    
867
    /**
868
     * Flip the coordinates of the geometry. If the geometry is aggregate also
869
     * revert the primitives collection.
870
     *
871
     * @throws GeometryOperationNotSupportedException
872
     * @throws GeometryOperationException
873
     */
874
    public void flip() throws GeometryOperationNotSupportedException, GeometryOperationException;
875

    
876
    /**
877
     * Ensures the orientation of the geometry according to the parameter,
878
     * flipping it if necessary. If the geometry is a polygon, ensures the
879
     * orientation of its perimeter and ensures the opposite orientation of
880
     * their holes.
881
     *
882
     * @param ccw
883
     * @return
884
     * @throws GeometryOperationNotSupportedException
885
     * @throws GeometryOperationException
886
     */
887
    public boolean ensureOrientation(boolean ccw) throws GeometryOperationNotSupportedException, GeometryOperationException;
888

    
889
    /**
890
     * Returns true if passed as a parameter geometry is completely out of
891
     * geometry.
892
     *
893
     * @param geometry
894
     * @return
895
     * @throws GeometryOperationNotSupportedException
896
     * @throws GeometryOperationException
897
     */
898
    public boolean out(Geometry geometry) throws GeometryOperationNotSupportedException, GeometryOperationException;
899

    
900
    public Geometry force2D() throws GeometryOperationNotSupportedException, GeometryOperationException;
901
    
902
    /**
903
     * Return true if the geometry can be transformed by the affine transform
904
     *
905
     * @param at the affine transform
906
     * @return
907
     */
908
    public boolean canBeTransformed(AffineTransform at);
909

    
910
    /**
911
     * Return true if the geometry can be reprojected by the coordinate
912
     * transformation
913
     *
914
     * @param ct the coordinate transformation
915
     * @return
916
     */
917
    public boolean canBeReprojected(ICoordTrans ct);
918

    
919
    public void setProjection(String projection);
920

    
921
    public void setProjection(IProjection projection);
922

    
923
    public void setProjectionIffNull(IProjection projection);
924

    
925
    public IProjection getProjection();
926
}