public interface Geometry
extends java.awt.Shape, java.io.Serializable, java.lang.Comparable, java.lang.Cloneable
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 |
JOIN_STYLE_BEVEL
Specifies a bevel join style for buffer.
|
static int |
JOIN_STYLE_MITRE
Specifies a mitre join style for buffer.
|
static int |
JOIN_STYLE_ROUND
Specifies a round join style for buffer.
|
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 |
boundary()
Return the boundary
|
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 . |
Geometry |
buffer(double distance,
int joinStyle,
boolean capButt)
Computes a buffer area around this geometry having the given width, the joinStyle and the capButt
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(java.awt.geom.AffineTransform at)
Return true if the geometry can be transformed by the affine transform
|
Point |
centroid() |
Geometry |
clone() |
Geometry |
cloneGeometry()
Creates a clone of this geometry.
|
Geometry[] |
closestPoints(Geometry other) |
boolean |
contains(Geometry geometry)
Tests whether this geometry contains the specified geometry.
|
java.lang.Object |
convertTo(java.lang.String format,
java.lang.Object... args) |
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) |
java.lang.String |
convertToGeoJson(java.util.Map<java.lang.String,java.lang.Object> properties,
boolean encodecrs) |
java.lang.String |
convertToHexEWKB() |
java.lang.String |
convertToHexEWKBQuietly() |
java.lang.String |
convertToHexWKB() |
java.lang.String |
convertToHexWKBQuietly() |
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) |
byte[] |
convertToWKBQuietly() |
java.lang.String |
convertToWKT()
Return a string with the equivalent in WKT format of the Geometry.
|
java.lang.String |
convertToWKTQuietly() |
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 |
equals(java.lang.Object obj) |
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.
|
Geometry |
fix() |
void |
flip()
Flip the coordinates of the geometry.
|
Geometry |
force2D()
Deprecated.
use forceSubtype(Geometry.SUBTYPES.GEOM2D)
|
Geometry |
forceSubtype(int subtype) |
java.awt.geom.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.
|
java.awt.Shape |
getInternalShape()
Deprecated.
|
java.awt.geom.PathIterator |
getPathIterator(java.awt.geom.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.
|
java.awt.geom.PathIterator |
getPathIterator(java.awt.geom.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.
|
IProjection |
getProjection() |
java.awt.Shape |
getShape()
Deprecated.
this class inherits of
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. |
java.awt.Shape |
getShape(java.awt.geom.AffineTransform affineTransform)
Deprecated.
this class inherits of
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. |
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(java.awt.geom.Rectangle2D r)
Returns true if this geometry intersects the rectangle passed as
parameter.
|
java.lang.Object |
invokeOperation(int index,
GeometryOperationContext ctx)
Invokes a geometry operation given its index and context.
|
java.lang.Object |
invokeOperation(java.lang.String opName,
GeometryOperationContext ctx)
Invokes a geometry operation given its name and context.
|
boolean |
isCCW() |
boolean |
isEmpty() |
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) |
Geometry |
offset(int joinStyle,
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.
|
void |
setProjection(IProjection projection) |
void |
setProjection(java.lang.String projection) |
void |
setProjectionIffNull(IProjection 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(java.awt.geom.AffineTransform at)
It applies an affine transformation to the geometry.
|
Geometry |
union(Geometry other) |
boolean |
within(Geometry geometry) |
static final int JOIN_STYLE_ROUND
static final int JOIN_STYLE_MITRE
static final int JOIN_STYLE_BEVEL
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()
Geometry clone() throws java.lang.CloneNotSupportedException
java.lang.CloneNotSupportedException
boolean intersects(java.awt.geom.Rectangle2D r)
intersects
in interface java.awt.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(java.awt.geom.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
java.lang.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.java.lang.Object invokeOperation(java.lang.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()
java.lang.Object convertTo(java.lang.String format, java.lang.Object... args) throws GeometryOperationNotSupportedException, GeometryOperationException
java.lang.String convertToGeoJson(java.util.Map<java.lang.String,java.lang.Object> properties, boolean encodecrs) throws GeometryOperationNotSupportedException, GeometryOperationException
byte[] convertToWKB() throws GeometryOperationNotSupportedException, GeometryOperationException
Geometry.OPERATIONS.CONVERTTOWKB
.GeometryOperationNotSupportedException
GeometryOperationException
java.lang.String convertToHexEWKB() throws GeometryOperationNotSupportedException, GeometryOperationException
java.lang.String convertToHexWKB() throws GeometryOperationNotSupportedException, GeometryOperationException
byte[] convertToWKBQuietly()
java.lang.String convertToHexWKBQuietly()
java.lang.String convertToHexEWKBQuietly()
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
java.lang.String convertToWKT() throws GeometryOperationNotSupportedException, GeometryOperationException
Geometry.OPERATIONS.CONVERTTOWKT
.GeometryOperationNotSupportedException
GeometryOperationException
java.lang.String convertToWKTQuietly()
Geometry buffer(double distance) throws GeometryOperationNotSupportedException, GeometryOperationException
Geometry.OPERATIONS.BUFFER
.distance
- the width of the bufferGeometryOperationNotSupportedException
GeometryOperationException
Geometry buffer(double distance, int joinStyle, boolean capButt) throws GeometryOperationNotSupportedException, GeometryOperationException
Geometry.OPERATIONS.BUFFER
.distance
- the width of the bufferjoinStyle
- the join style can be JOIN_STYLE_ROUND, JOIN_STYLE_MITRE, JOIN_STYLE_BEVEL,capButt
- true if not add a capGeometryOperationNotSupportedException
GeometryOperationException
Geometry offset(double distance) throws GeometryOperationNotSupportedException, GeometryOperationException
distance
- GeometryOperationNotSupportedException
GeometryOperationException
Geometry offset(int joinStyle, double distance) throws GeometryOperationNotSupportedException, GeometryOperationException
joinStyle
- distance
- 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
.other
- GeometryOperationNotSupportedException
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()
java.awt.Shape getShape(java.awt.geom.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.affineTransform
- java.awt.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.java.awt.geom.Rectangle2D getBounds2D()
getBounds2D
in interface java.awt.Shape
java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform at)
getPathIterator
in interface java.awt.Shape
at
- The transformation to apply.Handler[] getHandlers(int type)
type
- Type of handlers.java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform at, double flatness)
getPathIterator
in interface java.awt.Shape
at
- The affine transformation.flatness
- java.awt.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
Geometry force2D() throws GeometryOperationNotSupportedException, GeometryOperationException
GeometryOperationNotSupportedException
GeometryOperationException
Geometry forceSubtype(int subtype) throws GeometryOperationNotSupportedException, GeometryOperationException
boolean canBeTransformed(java.awt.geom.AffineTransform at)
at
- the affine transformboolean canBeReprojected(ICoordTrans ct)
ct
- the coordinate transformationvoid setProjection(java.lang.String projection)
void setProjection(IProjection projection)
void setProjectionIffNull(IProjection projection)
IProjection getProjection()
Geometry boundary()
boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
Geometry fix()
boolean isEmpty()