|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.vividsolutions.jts.geom.Geometry
Basic implementation of Geometry
.
clone
returns a deep copy of the object.
GeometryCollection
s would be useful,
GeometryCollection
s are not supported as arguments to binary
predicates (other than convexHull
) or the relate
method.
Point
, LineString
, or
Polygon
will be returned if the result contains a single
element; otherwise, a MultiPoint
, MultiLineString
,
or MultiPolygon
will be returned. If the result is
heterogeneous a GeometryCollection
will be returned.
Because it is not clear at this time what semantics for set-theoretic
methods involving GeometryCollection
s would be useful,
GeometryCollections
are not supported as arguments to the set-theoretic methods.
Geometry
.
The SFS does not specify an unambiguous representation of a given point set
returned from a spatial analysis method. One goal of JTS is to make this
specification precise and unambiguous. JTS will use a canonical form for
Geometry
s returned from spatial analysis methods. The canonical
form is a Geometry
which is simple and noded:
isSimple
.
LineString
s. It
means that all intersection points on LineString
s will be
present as endpoints of LineString
s in the result.
Geometry
s. These new points arise from intersections between line segments in the
edges of the input Geometry
s. In the general case it is not
possible to represent constructed points exactly. This is due to the fact
that the coordinates of an intersection point may contain twice as many bits
of precision as the coordinates of the input line segments. In order to
represent these constructed points explicitly, JTS must truncate them to fit
the PrecisionModel
. Unfortunately, truncating coordinates moves them slightly. Line segments which would not be coincident in the exact result may become coincident in the truncated representation. This in turn leads to "topology collapses" -- situations where a computed element has a lower dimension than it would in the exact result.
When JTS detects topology collapses during the computation of spatial analysis methods, it will throw an exception. If possible the exception will report the location of the collapse.
#equals(Object) and #hashCode are not overridden, so that when two topologically equal Geometries are added to HashMaps and HashSets, they remain distinct. This behaviour is desired in many cases.
Field Summary | |
protected Envelope |
envelope
The bounding box of this Geometry . |
protected int |
SRID
The ID of the Spatial Reference System used by this Geometry |
Constructor Summary | |
Geometry(GeometryFactory factory)
|
Method Summary | |
abstract void |
apply(CoordinateFilter filter)
Performs an operation with or on this Geometry 's
coordinates. |
abstract void |
apply(GeometryComponentFilter filter)
Performs an operation with or on this Geometry and its component Geometry's. |
abstract void |
apply(GeometryFilter filter)
Performs an operation with or on this Geometry and its
subelement Geometry s (if any). |
Geometry |
buffer(double distance)
Returns a buffer region around this Geometry having the given
width. |
Geometry |
buffer(double distance,
int quadrantSegments)
Returns a buffer region around this Geometry having the given
width and with a specified number of segments used to approximate curves. |
protected void |
checkNotGeometryCollection(Geometry g)
Throws an exception if g 's class is GeometryCollection
. |
java.lang.Object |
clone()
|
protected int |
compare(java.util.Collection a,
java.util.Collection b)
Returns the first non-zero result of compareTo encountered as
the two Collection s are iterated over. |
int |
compareTo(java.lang.Object o)
Returns whether this Geometry is greater than, equal to,
or less than another Geometry . |
protected abstract int |
compareToSameClass(java.lang.Object o)
Returns whether this Geometry is greater than, equal to,
or less than another Geometry having the same class. |
protected abstract Envelope |
computeEnvelopeInternal()
Returns the minimum and maximum x and y values in this Geometry
, or a null Envelope if this Geometry is empty. |
boolean |
contains(Geometry g)
Returns true if other.within(this) returns
true . |
Geometry |
convexHull()
Returns the smallest convex Polygon that contains all the
points in the Geometry . |
boolean |
crosses(Geometry g)
Returns true if the DE-9IM intersection matrix for the two
Geometry s is
T*T****** (for a point and a curve, a point and an area or a line
and an area)
0******** (for two curves)
. |
Geometry |
difference(Geometry other)
Returns a Geometry representing the points making up this
Geometry that do not make up other . |
boolean |
disjoint(Geometry g)
Returns true if the DE-9IM intersection matrix for the two
Geometry s is FF*FF****. |
double |
distance(Geometry g)
Returns the minimum distance between this Geometry
and the Geometry g |
protected boolean |
equal(Coordinate a,
Coordinate b,
double tolerance)
|
boolean |
equals(Geometry g)
Returns true if the DE-9IM intersection matrix for the two
Geometry s is T*F**FFF*. |
boolean |
equalsExact(Geometry other)
Returns true if the two Geometry s are exactly equal. |
abstract boolean |
equalsExact(Geometry other,
double tolerance)
Returns true if the two Geometry s are exactly equal,
up to a specified tolerance. |
protected Geometry |
fromInternalGeometry(Geometry g)
|
void |
geometryChanged()
Notifies this Geometry that its Coordinates have been changed by an external party (using a CoordinateFilter, for example). |
protected void |
geometryChangedAction()
Notifies this Geometry that its Coordinates have been changed by an external party. |
double |
getArea()
Returns the area of this Geometry . |
abstract Geometry |
getBoundary()
Returns the boundary, or the empty geometry if this Geometry
is empty. |
abstract int |
getBoundaryDimension()
Returns the dimension of this Geometry s inherent boundary. |
Point |
getCentroid()
Computes the centroid of this Geometry . |
abstract Coordinate |
getCoordinate()
Returns a vertex of this Geometry . |
abstract Coordinate[] |
getCoordinates()
Returns this Geometry s vertices. |
abstract int |
getDimension()
Returns the dimension of this Geometry . |
Geometry |
getEnvelope()
Returns this Geometry s bounding box. |
Envelope |
getEnvelopeInternal()
Returns the minimum and maximum x and y values in this Geometry
, or a null Envelope if this Geometry is empty. |
GeometryFactory |
getFactory()
Gets the factory which contains the context in which this geometry was created. |
abstract java.lang.String |
getGeometryType()
Returns the name of this object's com.vivid.jts.geom
interface. |
Point |
getInteriorPoint()
Computes an interior point of this Geometry . |
double |
getLength()
Returns the length of this Geometry . |
abstract int |
getNumPoints()
Returns the count of this Geometry s vertices. |
PrecisionModel |
getPrecisionModel()
Returns the PrecisionModel used by the Geometry . |
int |
getSRID()
Deprecated. use getUserData instead |
java.lang.Object |
getUserData()
Gets the user data object for this geometry, if any. |
protected static boolean |
hasNonEmptyElements(Geometry[] geometries)
Returns true if the array contains any non-empty Geometry s. |
protected static boolean |
hasNullElements(java.lang.Object[] array)
Returns true if the array contains any null elements. |
Geometry |
intersection(Geometry other)
Returns a Geometry representing the points shared by this
Geometry and other . |
boolean |
intersects(Geometry g)
Returns true if disjoint returns false. |
abstract boolean |
isEmpty()
Returns whether or not the set of points in this Geometry is
empty. |
protected boolean |
isEquivalentClass(Geometry other)
Returns whether the two Geometry s are equal, from the point
of view of the equalsExact method. |
abstract boolean |
isSimple()
Returns false if the Geometry not simple. |
boolean |
isValid()
Tests the validity of this Geometry . |
boolean |
isWithinDistance(Geometry geom,
double distance)
Tests whether the distance from this Geometry
to another is less than or equal to a specified value. |
abstract void |
normalize()
Converts this Geometry to normal form (or
canonical form ). |
boolean |
overlaps(Geometry g)
Returns true if the DE-9IM intersection matrix for the two
Geometry s is
T*T***T** (for two points or two surfaces)
1*T***T** (for two curves)
. |
IntersectionMatrix |
relate(Geometry g)
Returns the DE-9IM intersection matrix for the two Geometry s. |
boolean |
relate(Geometry g,
java.lang.String intersectionPattern)
Returns true if the elements in the DE-9IM intersection
matrix for the two Geometry s match the elements in intersectionPattern
, which may be:
0
1
2
T ( = 0, 1 or 2)
F ( = -1)
* ( = -1, 0, 1 or 2)
For more information on the DE-9IM, see the OpenGIS Simple Features
Specification. |
void |
setSRID(int SRID)
Deprecated. use setUserData instead |
void |
setUserData(java.lang.Object userData)
A simple scheme for applications to add their own custom data to a Geometry. |
Geometry |
symDifference(Geometry other)
Returns a set combining the points in this Geometry not in
other , and the points in other not in this
Geometry . |
protected Geometry |
toInternalGeometry(Geometry g)
The JTS algorithms assume that Geometry#getCoordinate and #getCoordinates are fast, which may not be the case if the CoordinateSequence is not a BasicCoordinateSequence (e.g. |
java.lang.String |
toString()
|
java.lang.String |
toText()
Returns the Well-known Text representation of this Geometry . |
boolean |
touches(Geometry g)
Returns true if the DE-9IM intersection matrix for the two
Geometry s is FT*******, F**T***** or F***T****. |
Geometry |
union(Geometry other)
Returns a Geometry representing all the points in this Geometry
and other . |
boolean |
within(Geometry g)
Returns true if the DE-9IM intersection matrix for the two
Geometry s is T*F**F***. |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected Envelope envelope
Geometry
.
protected int SRID
Geometry
Constructor Detail |
public Geometry(GeometryFactory factory)
Method Detail |
public abstract java.lang.String getGeometryType()
com.vivid.jts.geom
interface.
Geometry
s most specific com.vividsolutions.jts.geom
interfaceprotected static boolean hasNonEmptyElements(Geometry[] geometries)
Geometry
s.
geometries
- an array of Geometry
s; no elements may be
null
true
if any of the Geometry
s
isEmpty
methods return false
protected static boolean hasNullElements(java.lang.Object[] array)
null
elements.
array
- an array to validate
true
if any of array
s elements are
null
public int getSRID()
getUserData
instead
Geometry
.
JTS supports Spatial Reference System information in the simple way
defined in the SFS. A Spatial Reference System ID (SRID) is present in
each Geometry
object. Geometry
provides basic
accessor operations for this field, but no others. The SRID is represented
as an integer.
Geometry
is defined.public void setSRID(int SRID)
setUserData
instead
Geometry
.
public GeometryFactory getFactory()
public java.lang.Object getUserData()
null
if none setpublic void setUserData(java.lang.Object userData)
Note that user data objects are not present in geometries created by construction methods.
userData
- an object, the semantics for which are defined by the
application using this Geometrypublic PrecisionModel getPrecisionModel()
PrecisionModel
used by the Geometry
.
Geometry
and all other Geometry
spublic abstract Coordinate getCoordinate()
Geometry
.
Coordinate
which is a vertex of this Geometry
.
Returns null
if this Geometry is emptypublic abstract Coordinate[] getCoordinates()
Geometry
s vertices. If you modify the coordinates
in this array, be sure to call #geometryChanged afterwards.
The Geometry
s contained by composite Geometry
s
must be Geometry's; that is, they must implement getCoordinates
.
Geometry
public abstract int getNumPoints()
Geometry
s vertices. The Geometry
s contained by composite Geometry
s must be
Geometry's; that is, they must implement getNumPoints
Geometry
public abstract boolean isSimple()
Geometry
not simple.
Subclasses provide their own definition of "simple". If
this Geometry
is empty, returns true
. In general, the SFS specifications of simplicity seem to follow the following rule:
Geometry
s, isSimple
= true
.
true
if this Geometry
has any points of
self-tangency, self-intersection or other anomalous pointspublic boolean isValid()
Geometry
.
Subclasses provide their own definition of "valid".
true
if this Geometry
is validIsValidOp
public abstract boolean isEmpty()
Geometry
is
empty.
true
if this Geometry
equals the empty
geometrypublic double distance(Geometry g)
Geometry
and the Geometry
g
g
- the Geometry
from which to compute the distancepublic boolean isWithinDistance(Geometry geom, double distance)
Geometry
to another is less than or equal to a specified value.
geom
- the Geometry to check the distance todistance
- the distance value to compare
true
if the geometries are less than distance
apart.public double getArea()
Geometry
.
Areal Geometries have a non-zero area.
They override this function to compute the area.
Others return 0.0
public double getLength()
Geometry
.
Linear geometries return their length.
Areal geometries return their perimeter.
They override this function to compute the area.
Others return 0.0
public Point getCentroid()
Geometry
.
The centroid
is equal to the centroid of the set of component Geometries of highest
dimension (since the lower-dimension geometries contribute zero
"weight" to the centroid)
Point
which is the centroid of this Geometrypublic Point getInteriorPoint()
Geometry
.
An interior point is guaranteed to lie in the interior of the Geometry,
if it possible to calculate such a point exactly. Otherwise,
the point may lie on the boundary of the geometry.
Point
which is in the interior of this Geometrypublic abstract int getDimension()
Geometry
.
public abstract Geometry getBoundary()
Geometry
is empty. For a discussion of this function, see the OpenGIS Simple
Features Specification. As stated in SFS Section 2.1.13.1, "the boundary
of a Geometry is a set of Geometries of the next lower dimension."
Geometry
public abstract int getBoundaryDimension()
Geometry
s inherent boundary.
Dimension.FALSE
if the boundary is the empty geometry.public Geometry getEnvelope()
Geometry
s bounding box. If this Geometry
is the empty geometry, returns an empty Point
. If the Geometry
is a point, returns a non-empty Point
. Otherwise, returns a
Polygon
whose points are (minx, miny), (maxx, miny), (maxx,
maxy), (minx, maxy), (minx, miny).
Point
(for empty Geometry
s), a
Point
(for Point
s) or a Polygon
(in all other cases)public Envelope getEnvelopeInternal()
Geometry
, or a null Envelope
if this Geometry
is empty.
Geometry
s bounding box; if the Geometry
is empty, Envelope#isNull
will return true
public void geometryChanged()
Envelope
).
protected void geometryChangedAction()
apply(GeometryComponentFilter)
public boolean disjoint(Geometry g)
true
if the DE-9IM intersection matrix for the two
Geometry
s is FF*FF****.
true
if the two Geometry
s are
disjointpublic boolean touches(Geometry g)
true
if the DE-9IM intersection matrix for the two
Geometry
s is FT*******, F**T***** or F***T****.
true
if the two Geometry
s touch;
Returns false if both Geometry
s are pointspublic boolean intersects(Geometry g)
true
if disjoint
returns false.
true
if the two Geometry
s intersectpublic boolean crosses(Geometry g)
true
if the DE-9IM intersection matrix for the two
Geometry
s is
true
if the two Geometry
s cross.
For this function to return true
, the Geometry
s must be a point and a curve; a point and a surface; two curves; or a
curve and a surface.public boolean within(Geometry g)
true
if the DE-9IM intersection matrix for the two
Geometry
s is T*F**F***.
true
if this Geometry
is within
other
public boolean contains(Geometry g)
true
if other.within(this)
returns
true
.
true
if this Geometry
contains
other
public boolean overlaps(Geometry g)
true
if the DE-9IM intersection matrix for the two
Geometry
s is
true
if the two Geometry
s overlap.
For this function to return true
, the Geometry
s must be two points, two curves or two surfaces.public boolean relate(Geometry g, java.lang.String intersectionPattern)
true
if the elements in the DE-9IM intersection
matrix for the two Geometry
s match the elements in intersectionPattern
, which may be:
intersectionPattern
- the pattern against which to check the
intersection matrix for the two Geometry
s
true
if the DE-9IM intersection
matrix for the two Geometry
s match intersectionPattern
public IntersectionMatrix relate(Geometry g)
Geometry
s.
Geometry
spublic boolean equals(Geometry g)
true
if the DE-9IM intersection matrix for the two
Geometry
s is T*F**FFF*.
true
if the two Geometry
s are equalpublic java.lang.String toString()
public java.lang.String toText()
Geometry
.
For a definition of the Well-known Text format, see the OpenGIS Simple
Features Specification.
Geometry
public Geometry buffer(double distance)
Geometry
having the given
width.
The buffer of a Geometry is
the Minkowski sum or difference
of the Geometry with
a disc of radius distance
.
distance
- the width of the buffer, interpreted according to the
PrecisionModel
of the Geometry
Geometry
are less than or equal to distance
protected Geometry toInternalGeometry(Geometry g)
protected Geometry fromInternalGeometry(Geometry g)
public Geometry buffer(double distance, int quadrantSegments)
Geometry
having the given
width and with a specified number of segments used to approximate curves.
The buffer of a Geometry is the Minkowski sum of the Geometry with
a disc of radius distance
. Curves in the buffer polygon are
approximated with line segments. This method allows specifying the
accuracy of that approximation.
distance
- the width of the buffer, interpreted according to the
PrecisionModel
of the Geometry
quadrantSegments
- the number of segments to use to approximate a quadrant of a circle
Geometry
are less than or equal to distance
public Geometry convexHull()
Polygon
that contains all the
points in the Geometry
. This obviously applies only to Geometry
s which contain 3 or more points; the results for degenerate cases are
specified as follows:
Number of Point s in argument Geometry |
Geometry class of result |
---|---|
0 | empty GeometryCollection |
1 | Point |
2 | LineString |
3 or more | Polygon |
Geometry
'
s pointspublic Geometry intersection(Geometry other)
Geometry
representing the points shared by this
Geometry
and other
.
other
- the Geometry
with which to compute the
intersection
Geometry
spublic Geometry union(Geometry other)
Geometry
representing all the points in this Geometry
and other
.
other
- the Geometry
with which to compute the union
Geometry
and
the points of other
public Geometry difference(Geometry other)
Geometry
representing the points making up this
Geometry
that do not make up other
. This method
returns the closure of the resultant Geometry
.
other
- the Geometry
with which to compute the
difference
Geometry
with
other
public Geometry symDifference(Geometry other)
Geometry
not in
other
, and the points in other
not in this
Geometry
. This method returns the closure of the resultant
Geometry
.
other
- the Geometry
with which to compute the symmetric
difference
Geometry
with other
public abstract boolean equalsExact(Geometry other, double tolerance)
Geometry
s are exactly equal,
up to a specified tolerance.
Two Geometries are exactly within a tolerance equal iff:
Geometry
s are
composites and any children are not Geometry
s, returns
false.
other
- the Geometry
with which to compare this Geometry
true
if this and the other Geometry
are of the same class and have equal internal data.public boolean equalsExact(Geometry other)
Geometry
s are exactly equal.
Two Geometries are exactly equal iff:
Geometry
s are
composites and any children are not Geometry
s, returns
false.
This provides a stricter test of equality than
equals
.
other
- the Geometry
with which to compare this Geometry
true
if this and the other Geometry
are of the same class and have equal internal data.public abstract void apply(CoordinateFilter filter)
Geometry
's
coordinates. If you are using this method to modify the geometry, be sure
to call #geometryChanged() afterwards. Note that you cannot use this
method to
modify this Geometry if its underlying CoordinateSequence's #get method
returns a copy of the Coordinate, rather than the actual Coordinate stored
(if it even stores Coordinates at all).
filter
- the filter to apply to this Geometry
's
coordinatespublic abstract void apply(GeometryFilter filter)
Geometry
and its
subelement Geometry
s (if any).
Only GeometryCollections and subclasses
have subelement Geometry's.
filter
- the filter to apply to this Geometry
(and
its children, if it is a GeometryCollection
).public abstract void apply(GeometryComponentFilter filter)
filter
- the filter to apply to this Geometry
.public java.lang.Object clone()
public abstract void normalize()
Geometry
to normal form (or
canonical form ). Normal form is a unique representation for Geometry
s. It can be used to test whether two Geometry
s are equal
in a way that is independent of the ordering of the coordinates within
them. Normal form equality is a stronger condition than topological
equality, but weaker than pointwise equality. The definitions for normal
form use the standard lexicographical ordering for coordinates. "Sorted in
order of coordinates" means the obvious extension of this ordering to
sequences of coordinates.
public int compareTo(java.lang.Object o)
Geometry
is greater than, equal to,
or less than another Geometry
. If their classes are different, they are compared using the following ordering:
Geometry
s have the same class, their first
elements are compared. If those are the same, the second elements are
compared, etc.
compareTo
in interface java.lang.Comparable
o
- a Geometry
with which to compare this Geometry
o
, as
defined in "Normal Form For Geometry" in the JTS Technical
Specificationsprotected boolean isEquivalentClass(Geometry other)
Geometry
s are equal, from the point
of view of the equalsExact
method. Called by equalsExact
. In general, two Geometry
classes are considered to be
"equivalent" only if they are the same class. An exception is LineString
, which is considered to be equivalent to its subclasses.
other
- the Geometry
with which to compare this Geometry
for equality
true
if the classes of the two Geometry
s are considered to be equal by the equalsExact
method.protected void checkNotGeometryCollection(Geometry g)
g
's class is GeometryCollection
. (Its subclasses do not trigger an exception).
g
- the Geometry
to check
java.lang.IllegalArgumentException
- if g
is a GeometryCollection
but not one of its subclassesprotected abstract Envelope computeEnvelopeInternal()
Geometry
, or a null Envelope
if this Geometry
is empty.
Unlike getEnvelopeInternal
, this method calculates the Envelope
each time it is called; getEnvelopeInternal
caches the result
of this method.
Geometry
s bounding box; if the Geometry
is empty, Envelope#isNull
will return true
protected abstract int compareToSameClass(java.lang.Object o)
Geometry
is greater than, equal to,
or less than another Geometry
having the same class.
o
- a Geometry
having the same class as this Geometry
o
, as
defined in "Normal Form For Geometry" in the JTS Technical
Specificationsprotected int compare(java.util.Collection a, java.util.Collection b)
compareTo
encountered as
the two Collection
s are iterated over. If, by the time one of
the iterations is complete, no non-zero result has been encountered,
returns 0 if the other iteration is also complete. If b
completes before a
, a positive number is returned; if a
before b, a negative number.
a
- a Collection
of Comparable
sb
- a Collection
of Comparable
s
compareTo
result, if any;
otherwise, zeroprotected boolean equal(Coordinate a, Coordinate b, double tolerance)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |