public interface Geometry extends Shape, Serializable, Comparable
This interface is equivalent to the GM_Object specified in ISO 19107. It is the root class of the geometric object taxonomy and supports interfaces common to all geographically referenced geometric objects.
Geometry instances are sets of direct positions in a particular coordinate reference system. A Geometry can be regarded as an infinite set of points that satisfies the set operation interfaces for a set of direct positions.
A geometric object shall be a combination of a coordinate geometry and a coordinate reference system. In all of the operations, all geometric calculations shall be done in the coordinate reference system of the first geometric object accessed, which is normally the object whose operation is being invoked. Returned objects shall be in the coordinate reference system in which the calculations are done unless explicitly stated otherwise.
This class extends of the Shape
class by historical reasons but this
inheritance will disappear in future versions.
Modifier and Type | Interface and Description |
---|---|
static interface |
Geometry.DIMENSIONS |
static interface |
Geometry.OPERATIONS |
static interface |
Geometry.SUBTYPES
The subtype of a geometry is related with the dimension of the geometry,
that is a combination between the spatial dimension (2D, 2ZD, 3D) and the
M coordinate or "measure".
|
static interface |
Geometry.TYPES
Predefined geometry types in the model.
|
static interface |
Geometry.ValidationStatus |
Modifier and Type | Field and Description |
---|---|
static int |
BEST |
static int |
E
East.
|
static int |
EXTENDED_GEOMSUBTYPE_OFFSET
Initial value for new geometry subtypes (it must not overlap with the
basic ones defined in SUBTYPES).
|
static int |
EXTENDED_GEOMTYPE_OFFSET
Initial value for new geometry types (it must not overlap with the basic
ones defined in TYPES).
|
static int |
N
North.
|
static int |
NE
North - East.
|
static int |
NW
North - West.
|
static int |
S
South.
|
static int |
SE
South - East.
|
static int |
SELECTHANDLER |
static int |
STRETCHINGHANDLER |
static int |
SW
South - West.
|
static int |
W
West.
|
Modifier and Type | Method and Description |
---|---|
double |
area() |
Geometry |
buffer(double distance)
Computes a buffer area around this geometry having the given width
This is a utility method to wrap the invocation to the operation
Geometry.OPERATIONS.BUFFER . |
boolean |
canBeReprojected(ICoordTrans ct)
Return true if the geometry can be reprojected by the coordinate transformation
|
boolean |
canBeTransformed(AffineTransform at)
Return true if the geometry can be transformed by the affine transform
|
Point |
centroid() |
Geometry |
cloneGeometry()
Creates a clone of this geometry.
|
Geometry[] |
closestPoints(Geometry other) |
boolean |
contains(Geometry geometry)
Tests whether this geometry contains the specified geometry.
|
byte[] |
convertToEWKB()
Return a byte array with the equivalent in EWKB format of the Geometry.
|
byte[] |
convertToEWKB(int srs) |
byte[] |
convertToEWKBForcingType(int srs,
int type) |
byte[] |
convertToWKB()
Return a byte array with the equivalent in WKB format of the Geometry.
|
byte[] |
convertToWKB(int srs) |
byte[] |
convertToWKBForcingType(int srs,
int type) |
String |
convertToWKT()
Return a string with the equivalent in WKT format of the Geometry.
|
Geometry |
convexHull() |
boolean |
coveredBy(Geometry geometry) |
boolean |
covers(Geometry geometry) |
boolean |
crosses(Geometry geometry) |
Geometry |
difference(Geometry other) |
boolean |
disjoint(Geometry geometry) |
double |
distance(Geometry other)
Returns the minimum distance between this Geometry and the specified
geometry.
|
boolean |
ensureOrientation(boolean ccw)
Ensures the orientation of the geometry according to the parameter, flipping it if necessary.
|
boolean |
fastIntersects(double x,
double y,
double w,
double h)
Used by the drawing strategies to quickly test whether this geometry
intersects with the visible rectangle.
|
void |
flip()
Flip the coordinates of the geometry.
|
Rectangle2D |
getBounds2D()
Deprecated.
use getEnvelope.
|
int |
getDimension()
Returns the largest number n such that each direct position in a
geometric set can be associated with a subset that has the direct
position in its interior and is similar (isomorphic) to Rn, Euclidean
n-space.
|
Envelope |
getEnvelope()
Returns the minimum bounding box for this Geometry.
|
GeneralPathX |
getGeneralPath()
Deprecated.
don't use GeneralPathX over geometries, use instead specific API for each operation. If not has API for that operation let the project team.
|
GeometryType |
getGeometryType()
Instance of the GeometryType associated to this geometry.
|
Handler[] |
getHandlers(int type)
Deprecated.
don't use Handlers over geometries, use instead specific API for each operation. If not has API for that operation let the project team.
|
Point |
getInteriorPoint()
This method returns a point which is inside the geometry.
|
Shape |
getInternalShape()
Deprecated.
|
PathIterator |
getPathIterator(AffineTransform at)
Deprecated.
don't use PathIterator over geometries, use instead specific API for each operation. If not has API for that operation let the project team.
|
PathIterator |
getPathIterator(AffineTransform at,
double flatness)
Deprecated.
don't use PathIterator over geometries, use instead specific API for each operation. If not has API for that operation let the project team.
|
Shape |
getShape()
|
Shape |
getShape(AffineTransform affineTransform)
|
int |
getType()
If this geometry is a predefined interface then this method returns one
of
Geometry.TYPES contants. |
Geometry.ValidationStatus |
getValidationStatus()
Check if the geometry is valid and returns the validation status.
|
Geometry |
intersection(Geometry other) |
boolean |
intersects(Geometry geometry) |
boolean |
intersects(Rectangle2D r)
Returns true if this geometry intersects the rectangle passed as
parameter.
|
Object |
invokeOperation(int index,
GeometryOperationContext ctx)
Invokes a geometry operation given its index and context.
|
Object |
invokeOperation(String opName,
GeometryOperationContext ctx)
Invokes a geometry operation given its name and context.
|
boolean |
isCCW() |
boolean |
isSimple()
Returns
true if this Geometry has no interior point of
self-intersection or self-tangency. |
boolean |
isValid()
Check if the geometry is valid.
|
boolean |
isWithinDistance(Geometry other,
double distance) |
Geometry |
makeValid()
Try to fix the geometry and return the new geometry.
|
void |
move(double dx,
double dy)
Shifts geometry by given amount in x and y axes
|
Geometry |
offset(double distance) |
boolean |
out(Geometry geometry)
Returns true if passed as a parameter geometry is completely out of geometry.
|
boolean |
overlaps(Geometry geometry)
Tests whether this geometry overlaps the specified geometry.
|
double |
perimeter() |
void |
reProject(ICoordTrans ct)
Reprojects this geometry by the coordinate transformer passed as
parameter.
|
void |
rotate(double radAngle,
double basex,
double basey)
Rotates the geometry by radAngle radians using the given
coordinates as center of rotation.
|
void |
scale(Point basePoint,
double sx,
double sy)
Scales geometry in x and y axes by given scale factors
using the given point as center of projection.
|
Geometry |
snapTo(Geometry other,
double snapTolerance) |
MultiLine |
toLines()
Converts the geometry to be lines and makes with them a multiLine
|
MultiPoint |
toPoints()
Converts the geometry to be points and makes with them a multiPoint
|
MultiPolygon |
toPolygons()
Converts the geometry to be polygons and makes with them a multiPolygon
|
boolean |
touches(Geometry geometry) |
void |
transform(AffineTransform at)
It applies an affine transformation to the geometry.
|
Geometry |
union(Geometry other) |
boolean |
within(Geometry geometry) |
contains, contains, contains, contains, getBounds, intersects
compareTo
static final int EXTENDED_GEOMTYPE_OFFSET
static final int EXTENDED_GEOMSUBTYPE_OFFSET
static final int BEST
static final int N
static final int NE
static final int E
static final int SE
static final int S
static final int SW
static final int W
static final int NW
static final int SELECTHANDLER
static final int STRETCHINGHANDLER
int getType()
Geometry.TYPES
contants.Geometry.TYPES
or a runtime constant if it is an extended
type.Geometry cloneGeometry()
boolean intersects(Rectangle2D r)
intersects
in interface Shape
r
- Rectangle.this
intersects r
.boolean fastIntersects(double x, double y, double w, double h)
x
- The minimum X coordinate.y
- The minimum Y coordinate.w
- The width of the envelope.h
- The height of the envelope.this
intersects the rectangle defined by the
parameters.Envelope getEnvelope()
Returns the minimum bounding box for this Geometry. This shall be the coordinate region spanning the minimum and maximum value for each ordinate taken on by DirectPositions in this Geometry. The simplest representation for an envelope consists of two DirectPositions, the first one containing all the minimums for each ordinate, and second one containing all the maximums.
void reProject(ICoordTrans ct)
ct
- Coordinate Transformer.void transform(AffineTransform at)
at
- The transformation to apply.int getDimension()
boolean isSimple()
true
if this Geometry has no interior point of
self-intersection or self-tangency. In mathematical formalisms, this
means that every point in the interior of the object must have a metric
neighborhood whose intersection with the object is isomorphic to an
n-sphere, where n is the dimension of this Geometry.boolean isCCW() throws GeometryOperationNotSupportedException, GeometryOperationException
Object invokeOperation(int index, GeometryOperationContext ctx) throws GeometryOperationNotSupportedException, GeometryOperationException
index
- Unique index of the operation. Operation code.ctx
- The context of the geometry operation.GeometryOperationNotSupportedException
- It is thrown when the operation has been not registered for
this geometry.GeometryOperationException
- It is thrown when there is an error executing the operation.Object invokeOperation(String opName, GeometryOperationContext ctx) throws GeometryOperationNotSupportedException, GeometryOperationException
opName
- Operation name.ctx
- The context of the geometry operation.GeometryOperationNotSupportedException
- It is thrown when the operation has been not registered for
this geometry.GeometryOperationException
- It is thrown when there is an error executing the operation.GeometryType getGeometryType()
byte[] convertToWKB() throws GeometryOperationNotSupportedException, GeometryOperationException
Geometry.OPERATIONS.CONVERTTOWKB
.GeometryOperationNotSupportedException
GeometryOperationException
byte[] convertToWKB(int srs) throws GeometryOperationNotSupportedException, GeometryOperationException
byte[] convertToWKBForcingType(int srs, int type) throws GeometryOperationNotSupportedException, GeometryOperationException
byte[] convertToEWKB() throws GeometryOperationNotSupportedException, GeometryOperationException
OPERATIONS#CONVERTTOEWKB
.GeometryOperationNotSupportedException
GeometryOperationException
byte[] convertToEWKB(int srs) throws GeometryOperationNotSupportedException, GeometryOperationException
byte[] convertToEWKBForcingType(int srs, int type) throws GeometryOperationNotSupportedException, GeometryOperationException
String convertToWKT() throws GeometryOperationNotSupportedException, GeometryOperationException
Geometry.OPERATIONS.CONVERTTOWKT
.GeometryOperationNotSupportedException
GeometryOperationException
Geometry buffer(double distance) throws GeometryOperationNotSupportedException, GeometryOperationException
Geometry.OPERATIONS.BUFFER
.distance
- the width of the bufferGeometryOperationNotSupportedException
GeometryOperationException
Geometry offset(double distance) throws GeometryOperationNotSupportedException, GeometryOperationException
boolean contains(Geometry geometry) throws GeometryOperationNotSupportedException, GeometryOperationException
Geometry.OPERATIONS.CONTAINS
.geometry
- the Geometry with which to compare this GeometryGeometryOperationNotSupportedException
GeometryOperationException
double distance(Geometry other) throws GeometryOperationNotSupportedException, GeometryOperationException
Geometry.OPERATIONS.DISTANCE
.geometry
- the Geometry from which to compute the distanceGeometryOperationNotSupportedException
GeometryOperationException
Geometry[] closestPoints(Geometry other) throws GeometryOperationNotSupportedException, GeometryOperationException
boolean isWithinDistance(Geometry other, double distance) throws GeometryOperationNotSupportedException, GeometryOperationException
boolean overlaps(Geometry geometry) throws GeometryOperationNotSupportedException, GeometryOperationException
Geometry.OPERATIONS.OVERLAPS
.geometry
- the Geometry with which to compare this GeometryGeometryOperationNotSupportedException
GeometryOperationException
Geometry convexHull() throws GeometryOperationNotSupportedException, GeometryOperationException
boolean coveredBy(Geometry geometry) throws GeometryOperationNotSupportedException, GeometryOperationException
boolean covers(Geometry geometry) throws GeometryOperationNotSupportedException, GeometryOperationException
boolean crosses(Geometry geometry) throws GeometryOperationNotSupportedException, GeometryOperationException
Geometry difference(Geometry other) throws GeometryOperationNotSupportedException, GeometryOperationException
boolean disjoint(Geometry geometry) throws GeometryOperationNotSupportedException, GeometryOperationException
Geometry intersection(Geometry other) throws GeometryOperationNotSupportedException, GeometryOperationException
boolean intersects(Geometry geometry) throws GeometryOperationNotSupportedException, GeometryOperationException
Geometry snapTo(Geometry other, double snapTolerance) throws GeometryOperationNotSupportedException, GeometryOperationException
boolean touches(Geometry geometry) throws GeometryOperationNotSupportedException, GeometryOperationException
Geometry union(Geometry other) throws GeometryOperationNotSupportedException, GeometryOperationException
boolean within(Geometry geometry) throws GeometryOperationNotSupportedException, GeometryOperationException
Point centroid() throws GeometryOperationNotSupportedException, GeometryOperationException
Point getInteriorPoint() throws GeometryOperationNotSupportedException, GeometryOperationException
GeometryOperationNotSupportedException
GeometryOperationException
double area() throws GeometryOperationNotSupportedException, GeometryOperationException
double perimeter() throws GeometryOperationNotSupportedException, GeometryOperationException
void rotate(double radAngle, double basex, double basey)
radAngle
- the amount of rotation, in radiansbasex
- x coordinate of center of rotationbasey
- y coordinate of center of rotationvoid move(double dx, double dy)
dx
- dy
- void scale(Point basePoint, double sx, double sy)
basePoint
- sx
- scale factor in x axissy
- scale factor in y axisboolean isValid()
Geometry.ValidationStatus getValidationStatus()
Geometry makeValid()
Shape getShape(AffineTransform affineTransform)
Shape
by historical
reasons. This method has been added just to control the usage of
the Shape
class but it will removed in a future.Shape getShape()
Shape
by historical
reasons. This method has been added just to control the usage of
the Shape
class but it will removed in a future.Rectangle2D getBounds2D()
getBounds2D
in interface Shape
PathIterator getPathIterator(AffineTransform at)
getPathIterator
in interface Shape
at
- The transformation to apply.Handler[] getHandlers(int type)
type
- Type of handlers.PathIterator getPathIterator(AffineTransform at, double flatness)
getPathIterator
in interface Shape
at
- The affine transformation.flatness
- Shape getInternalShape()
GeneralPathX getGeneralPath()
MultiPoint toPoints() throws GeometryException
GeometryException
MultiLine toLines() throws GeometryException
GeometryException
MultiPolygon toPolygons() throws GeometryException
GeometryException
void flip() throws GeometryOperationNotSupportedException, GeometryOperationException
boolean ensureOrientation(boolean ccw) throws GeometryOperationNotSupportedException, GeometryOperationException
ccw
- GeometryOperationNotSupportedException
GeometryOperationException
boolean out(Geometry geometry) throws GeometryOperationNotSupportedException, GeometryOperationException
geometry
- GeometryOperationNotSupportedException
GeometryOperationException
boolean canBeTransformed(AffineTransform at)
at
- the affine transformboolean canBeReprojected(ICoordTrans ct)
ct
- the coordinate transformation