public abstract class AbstractGeometry extends java.lang.Object implements GeometryJTS
Geometry.DIMENSIONS, Geometry.OPERATIONS, Geometry.SUBTYPES, Geometry.TYPES, Geometry.ValidationStatus
Modifier and Type | Field and Description |
---|---|
protected static Logger |
LOGGER |
BEST, E, EXTENDED_GEOMSUBTYPE_OFFSET, EXTENDED_GEOMTYPE_OFFSET, JOIN_STYLE_BEVEL, JOIN_STYLE_MITRE, JOIN_STYLE_ROUND, N, NE, NW, S, SE, SELECTHANDLER, STRETCHINGHANDLER, SW, W
Constructor and Description |
---|
AbstractGeometry(int type,
int subtype) |
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 . |
Point |
centroid() |
Geometry |
clone() |
Geometry[] |
closestPoints(Geometry other) |
int |
compareTo(java.lang.Object o) |
boolean |
contains(double x,
double y) |
boolean |
contains(double x,
double y,
double w,
double h) |
boolean |
contains(Geometry geometry)
Tests whether this geometry contains the specified geometry.
|
boolean |
contains(java.awt.geom.Point2D p) |
boolean |
contains(java.awt.geom.Rectangle2D r) |
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.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() |
protected abstract Geometry |
force2DM() |
protected abstract Geometry |
force3D() |
protected abstract Geometry |
force3DM() |
Geometry |
forceSubtype(int subtype) |
java.awt.Rectangle |
getBounds() |
java.awt.geom.Rectangle2D |
getBounds2D()
Returns this geometry's boundary rectangle.
|
Envelope |
getEnvelope()
Returns the minimum bounding box for this Geometry.
|
GeometryType |
getGeometryType()
Instance of the GeometryType associated to this geometry.
|
Point |
getInteriorPoint()
This method returns a point which is inside the geometry.
|
java.awt.Shape |
getInternalShape()
Useful to have the real shape behind the scenes.
|
protected GeometryManager |
getManager() |
IProjection |
getProjection() |
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(double x,
double y,
double w,
double h) |
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
|
protected void |
notifyDeprecated(java.lang.String message) |
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 |
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 |
setGeometryType(GeometryType geometryType) |
void |
setProjection(IProjection projection) |
void |
setProjection(java.lang.String projection) |
void |
setProjectionIffNull(IProjection projection) |
Geometry |
snapTo(Geometry other,
double snapTolerance) |
java.lang.String |
toString() |
boolean |
touches(Geometry geometry) |
Geometry |
union(Geometry other) |
boolean |
within(Geometry geometry) |
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getJTS, is3D
canBeReprojected, canBeTransformed, cloneGeometry, flip, force2D, getDimension, getGeneralPath, getHandlers, getPathIterator, getPathIterator, getShape, getShape, offset, offset, reProject, toLines, toPoints, toPolygons, transform
public AbstractGeometry(int type, int subtype)
type
- subtype
- public void setGeometryType(GeometryType geometryType)
public GeometryType getGeometryType()
Geometry
getGeometryType
in interface Geometry
protected GeometryManager getManager()
public boolean contains(Geometry geometry) throws GeometryOperationNotSupportedException, GeometryOperationException
Geometry
Geometry.OPERATIONS.CONTAINS
.contains
in interface Geometry
geometry
- the Geometry with which to compare this GeometryGeometryOperationNotSupportedException
GeometryOperationException
public int compareTo(java.lang.Object o)
compareTo
in interface java.lang.Comparable
public boolean contains(double x, double y)
contains
in interface java.awt.Shape
public boolean intersects(double x, double y, double w, double h)
intersects
in interface java.awt.Shape
public boolean contains(double x, double y, double w, double h)
contains
in interface java.awt.Shape
public boolean contains(java.awt.geom.Point2D p)
contains
in interface java.awt.Shape
public boolean contains(java.awt.geom.Rectangle2D r)
contains
in interface java.awt.Shape
public double distance(Geometry other) throws GeometryOperationNotSupportedException, GeometryOperationException
Geometry
Geometry.OPERATIONS.DISTANCE
.distance
in interface Geometry
GeometryOperationNotSupportedException
GeometryOperationException
public boolean isWithinDistance(Geometry other, double distance) throws GeometryOperationNotSupportedException, GeometryOperationException
isWithinDistance
in interface Geometry
GeometryOperationNotSupportedException
GeometryOperationException
public boolean overlaps(Geometry geometry) throws GeometryOperationNotSupportedException, GeometryOperationException
Geometry
Geometry.OPERATIONS.OVERLAPS
.overlaps
in interface Geometry
geometry
- the Geometry with which to compare this GeometryGeometryOperationNotSupportedException
GeometryOperationException
public boolean coveredBy(Geometry geometry) throws GeometryOperationNotSupportedException, GeometryOperationException
coveredBy
in interface Geometry
GeometryOperationNotSupportedException
GeometryOperationException
public boolean covers(Geometry geometry) throws GeometryOperationNotSupportedException, GeometryOperationException
covers
in interface Geometry
GeometryOperationNotSupportedException
GeometryOperationException
public boolean crosses(Geometry geometry) throws GeometryOperationNotSupportedException, GeometryOperationException
crosses
in interface Geometry
GeometryOperationNotSupportedException
GeometryOperationException
public boolean intersects(Geometry geometry) throws GeometryOperationNotSupportedException, GeometryOperationException
intersects
in interface Geometry
GeometryOperationNotSupportedException
GeometryOperationException
public boolean touches(Geometry geometry) throws GeometryOperationNotSupportedException, GeometryOperationException
touches
in interface Geometry
GeometryOperationNotSupportedException
GeometryOperationException
public boolean disjoint(Geometry geometry) throws GeometryOperationNotSupportedException, GeometryOperationException
disjoint
in interface Geometry
GeometryOperationNotSupportedException
GeometryOperationException
public boolean within(Geometry geometry) throws GeometryOperationNotSupportedException, GeometryOperationException
within
in interface Geometry
GeometryOperationNotSupportedException
GeometryOperationException
public double area() throws GeometryOperationNotSupportedException, GeometryOperationException
area
in interface Geometry
GeometryOperationNotSupportedException
GeometryOperationException
public double perimeter() throws GeometryOperationNotSupportedException, GeometryOperationException
perimeter
in interface Geometry
GeometryOperationNotSupportedException
GeometryOperationException
public boolean intersects(java.awt.geom.Rectangle2D r)
Geometry
intersects
in interface java.awt.Shape
intersects
in interface Geometry
r
- Rectangle.this
intersects r
.public boolean fastIntersects(double x, double y, double w, double h)
Geometry
fastIntersects
in interface Geometry
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.public Envelope getEnvelope()
Geometry
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.
getEnvelope
in interface Geometry
public boolean isSimple()
Geometry
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.public boolean isCCW() throws GeometryOperationNotSupportedException, GeometryOperationException
isCCW
in interface Geometry
GeometryOperationNotSupportedException
GeometryOperationException
public java.lang.Object invokeOperation(int index, GeometryOperationContext ctx) throws GeometryOperationNotSupportedException, GeometryOperationException
Geometry
invokeOperation
in interface Geometry
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.public java.lang.Object invokeOperation(java.lang.String opName, GeometryOperationContext ctx) throws GeometryOperationNotSupportedException, GeometryOperationException
Geometry
invokeOperation
in interface Geometry
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.public int getType()
Geometry
Geometry.TYPES
contants.getType
in interface Geometry
Geometry.TYPES
or a runtime constant if it is an extended type.public java.lang.Object convertTo(java.lang.String format, java.lang.Object... args) throws GeometryOperationNotSupportedException, GeometryOperationException
convertTo
in interface Geometry
GeometryOperationNotSupportedException
GeometryOperationException
public byte[] convertToWKB() throws GeometryOperationNotSupportedException, GeometryOperationException
Geometry
Geometry.OPERATIONS.CONVERTTOWKB
.convertToWKB
in interface Geometry
GeometryOperationNotSupportedException
GeometryOperationException
public java.lang.String convertToHexWKB() throws GeometryOperationNotSupportedException, GeometryOperationException
convertToHexWKB
in interface Geometry
GeometryOperationNotSupportedException
GeometryOperationException
public java.lang.String convertToGeoJson() throws GeometryOperationNotSupportedException, GeometryOperationException
public java.lang.String convertToGeoJson(java.util.Map<java.lang.String,java.lang.Object> properties, boolean encodecrs) throws GeometryOperationNotSupportedException, GeometryOperationException
convertToGeoJson
in interface Geometry
GeometryOperationNotSupportedException
GeometryOperationException
public java.lang.String convertToHexEWKB() throws GeometryOperationNotSupportedException, GeometryOperationException
convertToHexEWKB
in interface Geometry
GeometryOperationNotSupportedException
GeometryOperationException
public byte[] convertToWKBQuietly()
convertToWKBQuietly
in interface Geometry
public java.lang.String convertToHexWKBQuietly()
convertToHexWKBQuietly
in interface Geometry
public java.lang.String convertToHexEWKBQuietly()
convertToHexEWKBQuietly
in interface Geometry
public byte[] convertToWKB(int srs) throws GeometryOperationNotSupportedException, GeometryOperationException
convertToWKB
in interface Geometry
GeometryOperationNotSupportedException
GeometryOperationException
public byte[] convertToWKBForcingType(int srs, int type) throws GeometryOperationNotSupportedException, GeometryOperationException
convertToWKBForcingType
in interface Geometry
GeometryOperationNotSupportedException
GeometryOperationException
public byte[] convertToEWKB() throws GeometryOperationNotSupportedException, GeometryOperationException
Geometry
OPERATIONS#CONVERTTOEWKB
.convertToEWKB
in interface Geometry
GeometryOperationNotSupportedException
GeometryOperationException
public byte[] convertToEWKB(int srs) throws GeometryOperationNotSupportedException, GeometryOperationException
convertToEWKB
in interface Geometry
GeometryOperationNotSupportedException
GeometryOperationException
public byte[] convertToEWKBForcingType(int srs, int type) throws GeometryOperationNotSupportedException, GeometryOperationException
convertToEWKBForcingType
in interface Geometry
GeometryOperationNotSupportedException
GeometryOperationException
public java.lang.String convertToWKT() throws GeometryOperationNotSupportedException, GeometryOperationException
Geometry
Geometry.OPERATIONS.CONVERTTOWKT
.convertToWKT
in interface Geometry
GeometryOperationNotSupportedException
GeometryOperationException
public java.lang.String convertToWKTQuietly()
convertToWKTQuietly
in interface Geometry
public Geometry buffer(double distance) throws GeometryOperationNotSupportedException, GeometryOperationException
Geometry
Geometry.OPERATIONS.BUFFER
.buffer
in interface Geometry
distance
- the width of the bufferGeometryOperationNotSupportedException
GeometryOperationException
public Geometry buffer(double distance, int joinStyle, boolean capButt) throws GeometryOperationNotSupportedException, GeometryOperationException
Geometry
Geometry.OPERATIONS.BUFFER
.buffer
in interface Geometry
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
public Geometry snapTo(Geometry other, double snapTolerance) throws GeometryOperationNotSupportedException, GeometryOperationException
snapTo
in interface Geometry
GeometryOperationNotSupportedException
GeometryOperationException
public Point getInteriorPoint() throws GeometryOperationNotSupportedException, GeometryOperationException
Geometry
getInteriorPoint
in interface Geometry
GeometryOperationNotSupportedException
GeometryOperationException
public boolean isValid()
Geometry
public Geometry.ValidationStatus getValidationStatus()
Geometry
getValidationStatus
in interface Geometry
public Geometry makeValid()
Geometry
public java.awt.geom.Rectangle2D getBounds2D()
Geometry
getBounds2D
in interface java.awt.Shape
getBounds2D
in interface Geometry
public java.awt.Rectangle getBounds()
getBounds
in interface java.awt.Shape
public java.awt.Shape getInternalShape()
Geometry
getInternalShape
in interface Geometry
public void rotate(double radAngle, double basex, double basey)
Geometry
public void move(double dx, double dy)
Geometry
public void scale(Point basePoint, double sx, double sy)
Geometry
public Geometry[] closestPoints(Geometry other) throws GeometryOperationNotSupportedException, GeometryOperationException
closestPoints
in interface Geometry
GeometryOperationNotSupportedException
GeometryOperationException
public Geometry convexHull() throws GeometryOperationNotSupportedException, GeometryOperationException
convexHull
in interface Geometry
GeometryOperationNotSupportedException
GeometryOperationException
public Geometry difference(Geometry other) throws GeometryOperationNotSupportedException, GeometryOperationException
difference
in interface Geometry
GeometryOperationNotSupportedException
GeometryOperationException
public Geometry intersection(Geometry other) throws GeometryOperationNotSupportedException, GeometryOperationException
intersection
in interface Geometry
GeometryOperationNotSupportedException
GeometryOperationException
public Geometry union(Geometry other) throws GeometryOperationNotSupportedException, GeometryOperationException
union
in interface Geometry
GeometryOperationNotSupportedException
GeometryOperationException
public Point centroid() throws GeometryOperationNotSupportedException, GeometryOperationException
centroid
in interface Geometry
GeometryOperationNotSupportedException
GeometryOperationException
protected void notifyDeprecated(java.lang.String message)
public boolean ensureOrientation(boolean ccw) throws GeometryOperationNotSupportedException, GeometryOperationException
Geometry
ensureOrientation
in interface Geometry
GeometryOperationNotSupportedException
GeometryOperationException
public boolean out(Geometry geometry) throws GeometryOperationNotSupportedException, GeometryOperationException
Geometry
out
in interface Geometry
GeometryOperationNotSupportedException
GeometryOperationException
public boolean equals(java.lang.Object obj)
public java.lang.String toString()
toString
in class java.lang.Object
public IProjection getProjection()
getProjection
in interface Geometry
public void setProjectionIffNull(IProjection projection)
setProjectionIffNull
in interface Geometry
public void setProjection(IProjection projection)
setProjection
in interface Geometry
public void setProjection(java.lang.String projection)
setProjection
in interface Geometry
public Geometry clone() throws java.lang.CloneNotSupportedException
public Geometry forceSubtype(int subtype) throws GeometryOperationNotSupportedException, GeometryOperationException
forceSubtype
in interface Geometry
GeometryOperationNotSupportedException
GeometryOperationException
protected abstract Geometry force2DM() throws GeometryOperationNotSupportedException, GeometryOperationException
protected abstract Geometry force3D() throws GeometryOperationNotSupportedException, GeometryOperationException
protected abstract Geometry force3DM() throws GeometryOperationNotSupportedException, GeometryOperationException