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

History | View | Annotate | Download (30 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
        public final static int NULL = 16;
161

    
162
        public final static int COMPLEX = 17;
163

    
164
        public final static int LINE = 18;
165

    
166
        public final static int POLYGON = 19;
167

    
168
        public final static int RING = 20;
169

    
170
        public final static int MULTILINE = 21;
171

    
172
        public final static int MULTIPOLYGON = 22;
173

    
174
        public final static int CIRCUMFERENCE = 23;
175

    
176
        public final static int PERIELLIPSE = 24;
177

    
178
        public final static int FILLEDSPLINE = 25;
179

    
180
    }
181

    
182
    public interface DIMENSIONS {
183

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

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

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

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

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

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

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

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

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

    
236
    public interface OPERATIONS {
237

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

    
257
    public interface ValidationStatus {
258

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
505
    public byte[] convertToWKB(int srs)
506
            throws GeometryOperationNotSupportedException, GeometryOperationException;
507

    
508
    public byte[] convertToWKBForcingType(int srs, int type)
509
            throws GeometryOperationNotSupportedException, GeometryOperationException;
510

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

    
523
    public byte[] convertToEWKB(int srs)
524
            throws GeometryOperationNotSupportedException, GeometryOperationException;
525

    
526
    public byte[] convertToEWKBForcingType(int srs, int type)
527
            throws GeometryOperationNotSupportedException, GeometryOperationException;
528

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

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

    
560
    public Geometry offset(double distance)
561
            throws GeometryOperationNotSupportedException,
562
            GeometryOperationException;
563

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

    
581
    /**
582
     * Returns the minimum distance between this Geometry and the specified
583
     * geometry.
584
     *
585
     * This is a utility method to wrap the invocation to the operation
586
     * {@link OPERATIONS#DISTANCE}.
587
     *
588
     * @param other
589
     * @return the distance between the geometries
590
     *
591
     * @throws GeometryOperationNotSupportedException
592
     * @throws GeometryOperationException
593
     */
594
    public double distance(Geometry other)
595
            throws GeometryOperationNotSupportedException,
596
            GeometryOperationException;
597

    
598
    public Geometry[] closestPoints(Geometry other)
599
            throws GeometryOperationNotSupportedException,
600
            GeometryOperationException;
601

    
602
    boolean isWithinDistance(Geometry other, double distance)
603
            throws GeometryOperationNotSupportedException,
604
            GeometryOperationException;
605

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

    
623
    public Geometry convexHull() throws GeometryOperationNotSupportedException,
624
            GeometryOperationException;
625

    
626
    public boolean coveredBy(Geometry geometry)
627
            throws GeometryOperationNotSupportedException,
628
            GeometryOperationException;
629

    
630
    public boolean covers(Geometry geometry)
631
            throws GeometryOperationNotSupportedException,
632
            GeometryOperationException;
633

    
634
    public boolean crosses(Geometry geometry)
635
            throws GeometryOperationNotSupportedException,
636
            GeometryOperationException;
637

    
638
    public Geometry difference(Geometry other)
639
            throws GeometryOperationNotSupportedException,
640
            GeometryOperationException;
641

    
642
    public boolean disjoint(Geometry geometry)
643
            throws GeometryOperationNotSupportedException,
644
            GeometryOperationException;
645

    
646
    public Geometry intersection(Geometry other)
647
            throws GeometryOperationNotSupportedException,
648
            GeometryOperationException;
649

    
650
    public boolean intersects(Geometry geometry)
651
            throws GeometryOperationNotSupportedException,
652
            GeometryOperationException;
653

    
654
    public Geometry snapTo(Geometry other, double snapTolerance)
655
            throws GeometryOperationNotSupportedException,
656
            GeometryOperationException;
657

    
658
    public boolean touches(Geometry geometry)
659
            throws GeometryOperationNotSupportedException,
660
            GeometryOperationException;
661

    
662
    public Geometry union(Geometry other)
663
            throws GeometryOperationNotSupportedException,
664
            GeometryOperationException;
665

    
666
    public boolean within(Geometry geometry)
667
            throws GeometryOperationNotSupportedException,
668
            GeometryOperationException;
669

    
670
    public Point centroid() throws GeometryOperationNotSupportedException, GeometryOperationException;
671

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

    
684
    public double area() throws GeometryOperationNotSupportedException, GeometryOperationException;
685

    
686
    public double perimeter() throws GeometryOperationNotSupportedException, GeometryOperationException;
687

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

    
701
    /**
702
     * Shifts geometry by given amount in x and y axes
703
     *
704
     * @param dx
705
     * @param dy
706
     */
707
    public void move(double dx, double dy);
708

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

    
719
    /**
720
     * Check if the geometry is valid.
721
     *
722
     * @return true if the geometry is valid.
723
     */
724
    public boolean isValid();
725

    
726
    /**
727
     * Check if the geometry is valid and returns the validation status.
728
     *
729
     * @return the ValidationStatus
730
     */
731
    public ValidationStatus getValidationStatus();
732

    
733
    /**
734
     * Try to fix the geometry and return the new geometry. If the geometry is
735
     * valid return the same geometry. If the geometry is corrupt or can't fix
736
     * it, return null.
737
     *
738
     * @return the new fixed geometry
739
     */
740
    public Geometry makeValid();
741

    
742
    //
743
    // ===============================================
744
    //
745
    /**
746
     * @param affineTransform
747
     * @return the awt shape used to display the geometry. It applies a
748
     * tranformation before to return the coordinates of the shape
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(AffineTransform affineTransform);
754

    
755
    /**
756
     * @return the awt shape used to display the geometry.
757
     * @deprecated this class inherits of {@link Shape} by historical reasons.
758
     * This method has been added just to control the usage of the {@link Shape}
759
     * class but it will removed in a future.
760
     */
761
    public Shape getShape();
762

    
763
    /**
764
     * Returns this geometry's boundary rectangle.
765
     *
766
     * @deprecated use getEnvelope.
767
     * @return Boundary rectangle.
768
     */
769
    @Override
770
    public Rectangle2D getBounds2D();
771

    
772
    /**
773
     * If applies an affine transformation and returns the GeneralPathXIterator
774
     * with this geometry's information.
775
     *
776
     * @param at The transformation to apply.
777
     * @return The GeneralPathXIterator with this geometry's information.
778
     * @deprecated don't use PathIterator over geometries, use instead specific
779
     * API for each operation. If not has API for that operation let the project
780
     * team.
781
     *
782
     */
783
    @Override
784
    public PathIterator getPathIterator(AffineTransform at);
785

    
786
    /**
787
     * It returns the handlers of the geometry, these they can be of two types
788
     * is straightening and of selection.
789
     *
790
     * @param type Type of handlers.
791
     *
792
     * @deprecated don't use Handlers over geometries, use instead specific API
793
     * for each operation. If not has API for that operation let the project
794
     * team.
795
     * @return The handlers.
796
     */
797
    public Handler[] getHandlers(int type);
798

    
799
    /**
800
     * If applies an affine transformation and returns the GeneralPathXIterator
801
     * with this geometry's information.
802
     *
803
     * @param at The affine transformation.
804
     * @param flatness
805
     *
806
     * @return The GeneralPathXIterator with this geometry's information.
807
     * @deprecated don't use PathIterator over geometries, use instead specific
808
     * API for each operation. If not has API for that operation let the project
809
     * team.
810
     */
811
    @Override
812
    PathIterator getPathIterator(AffineTransform at, double flatness);
813

    
814
    /**
815
     * Useful to have the real shape behind the scenes. May be uses to edit it
816
     * knowing it it is a Circle, Ellipse, etc.
817
     *
818
     * @return The awt shape
819
     * @deprecated
820
     */
821
    public Shape getInternalShape();
822

    
823
    /**
824
     * Get GeneralPathIterator, to do registered operations to it.
825
     *
826
     * @return The GeneralPathX.
827
     * @deprecated don't use GeneralPathX over geometries, use instead specific
828
     * API for each operation. If not has API for that operation let the project
829
     * team.
830
     */
831
    public GeneralPathX getGeneralPath();
832

    
833
    /**
834
     * Converts the geometry to be points and makes with them a multiPoint
835
     *
836
     * @return MultiPoint
837
     * @throws GeometryException
838
     */
839
    public MultiPoint toPoints() throws GeometryException;
840

    
841
    /**
842
     * Converts the geometry to be lines and makes with them a multiLine
843
     *
844
     * @return
845
     * @throws GeometryException
846
     */
847
    public MultiLine toLines() throws GeometryException;
848

    
849
    /**
850
     * Converts the geometry to be polygons and makes with them a multiPolygon
851
     *
852
     * @return
853
     * @throws GeometryException
854
     */
855
    public MultiPolygon toPolygons() throws GeometryException;
856

    
857
    /**
858
     * Flip the coordinates of the geometry. If the geometry is aggregate also
859
     * revert the primitives collection.
860
     *
861
     * @throws GeometryOperationNotSupportedException
862
     * @throws GeometryOperationException
863
     */
864
    public void flip() throws GeometryOperationNotSupportedException, GeometryOperationException;
865

    
866
    /**
867
     * Ensures the orientation of the geometry according to the parameter,
868
     * flipping it if necessary. If the geometry is a polygon, ensures the
869
     * orientation of its perimeter and ensures the opposite orientation of
870
     * their holes.
871
     *
872
     * @param ccw
873
     * @return
874
     * @throws GeometryOperationNotSupportedException
875
     * @throws GeometryOperationException
876
     */
877
    public boolean ensureOrientation(boolean ccw) throws GeometryOperationNotSupportedException, GeometryOperationException;
878

    
879
    /**
880
     * Returns true if passed as a parameter geometry is completely out of
881
     * geometry.
882
     *
883
     * @param geometry
884
     * @return
885
     * @throws GeometryOperationNotSupportedException
886
     * @throws GeometryOperationException
887
     */
888
    public boolean out(Geometry geometry) throws GeometryOperationNotSupportedException, GeometryOperationException;
889

    
890
    public Geometry force2D() throws GeometryOperationNotSupportedException, GeometryOperationException;
891
    
892
    /**
893
     * Return true if the geometry can be transformed by the affine transform
894
     *
895
     * @param at the affine transform
896
     * @return
897
     */
898
    public boolean canBeTransformed(AffineTransform at);
899

    
900
    /**
901
     * Return true if the geometry can be reprojected by the coordinate
902
     * transformation
903
     *
904
     * @param ct the coordinate transformation
905
     * @return
906
     */
907
    public boolean canBeReprojected(ICoordTrans ct);
908

    
909
    public void setProjection(String projection);
910

    
911
    public void setProjection(IProjection projection);
912

    
913
    public void setProjectionIffNull(IProjection projection);
914

    
915
    public IProjection getProjection();
916
}