| Prev Class | Next Class | Frames | No Frames |
| Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Objectcom.vividsolutions.jts.geom.Geometrypublic abstract class Geometryextends java.lang.Objectimplements Cloneable, Comparable, SerializableGeometry.
clone returns a deep copy of the object.
GeometryCollections would be useful,
GeometryCollections 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 GeometryCollections 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
Geometrys returned from spatial analysis methods. The canonical
form is a Geometry which is simple and noded:
isSimple.
LineStrings. It
means that all intersection points on LineStrings will be
present as endpoints of LineStrings in the result.
Geometry
s. These new points arise from intersections between line segments in the
edges of the input Geometrys. 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 int |
|
protected Envelope |
|
Constructor Summary | |
| |
Method Summary | |
abstract void |
|
abstract void |
|
abstract void |
|
Geometry |
|
Geometry | |
protected void |
|
Object |
|
protected int |
|
int |
|
protected abstract int |
|
protected abstract Envelope |
|
boolean | |
Geometry |
|
boolean | |
Geometry |
|
boolean | |
double | |
protected boolean |
|
boolean | |
boolean |
|
abstract boolean |
|
void |
|
protected void |
|
double |
|
abstract Geometry |
|
abstract int |
|
Point |
|
abstract Coordinate |
|
abstract Coordinate[] |
|
abstract int |
|
Geometry |
|
Envelope |
|
GeometryFactory |
|
Geometry |
|
abstract String |
|
Point |
|
double |
|
int |
|
abstract int |
|
PrecisionModel |
|
int |
|
Object |
|
protected static boolean |
|
protected static boolean |
|
Geometry |
|
boolean |
|
abstract boolean |
|
protected boolean |
|
boolean | |
abstract boolean |
|
boolean |
|
boolean |
|
abstract void |
|
boolean | |
IntersectionMatrix | |
boolean |
|
void |
|
void |
|
Geometry |
|
String |
|
String |
|
boolean | |
Geometry | |
boolean | |
public abstract void apply(CoordinateFilter filter)
Performs an operation with or on thisGeometry'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).
- Parameters:
filter- the filter to apply to thisGeometry's coordinates
public abstract void apply(GeometryComponentFilter filter)
Performs an operation with or on this Geometry and its component Geometry's. Only GeometryCollections and Polygons have component Geometry's; for Polygons they are the LinearRings of the shell and holes.
- Parameters:
filter- the filter to apply to thisGeometry.
public abstract void apply(GeometryFilter filter)
Performs an operation with or on thisGeometryand its subelementGeometrys (if any). Only GeometryCollections and subclasses have subelement Geometry's.
- Parameters:
filter- the filter to apply to thisGeometry(and its children, if it is aGeometryCollection).
public Geometry buffer(double distance)
Returns a buffer region around thisGeometryhaving the given width. The buffer of a Geometry is the Minkowski sum or difference of the Geometry with a disc of radiusdistance.
- Parameters:
distance- the width of the buffer, interpreted according to thePrecisionModelof theGeometry
- Returns:
- all points whose distance from this
Geometryare less than or equal todistance
public Geometry buffer(double distance, int quadrantSegments)
Returns a buffer region around thisGeometryhaving 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 radiusdistance. Curves in the buffer polygon are approximated with line segments. This method allows specifying the accuracy of that approximation.
- Parameters:
distance- the width of the buffer, interpreted according to thePrecisionModelof theGeometryquadrantSegments- the number of segments to use to approximate a quadrant of a circle
- Returns:
- all points whose distance from this
Geometryare less than or equal todistance
protected void checkNotGeometryCollection(Geometry g)
Throws an exception ifg's class isGeometryCollection. (Its subclasses do not trigger an exception).
- Parameters:
g- theGeometryto check
public Object clone()
protected int compare(Collection a,
Collection b)Returns the first non-zero result ofcompareToencountered as the twoCollections 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. Ifbcompletes beforea, a positive number is returned; if a before b, a negative number.
- Parameters:
a- aCollectionofComparablesb- aCollectionofComparables
- Returns:
- the first non-zero
compareToresult, if any; otherwise, zero
public int compareTo(Object o)
Returns whether thisGeometryis greater than, equal to, or less than anotherGeometry. If their classes are different, they are compared using the following ordering:If the two
- Point (lowest)
- MultiPoint
- LineString
- LinearRing
- MultiLineString
- Polygon
- MultiPolygon
- GeometryCollection (highest)
Geometrys have the same class, their first elements are compared. If those are the same, the second elements are compared, etc.
- Parameters:
o- aGeometrywith which to compare thisGeometry
- Returns:
- a positive number, 0, or a negative number, depending on whether this object is greater than, equal to, or less than
o, as defined in "Normal Form For Geometry" in the JTS Technical Specifications
protected abstract int compareToSameClass(Object o)
Returns whether thisGeometryis greater than, equal to, or less than anotherGeometryhaving the same class.
- Parameters:
o- aGeometryhaving the same class as thisGeometry
- Returns:
- a positive number, 0, or a negative number, depending on whether this object is greater than, equal to, or less than
o, as defined in "Normal Form For Geometry" in the JTS Technical Specifications
protected abstract Envelope computeEnvelopeInternal()
Returns the minimum and maximum x and y values in thisGeometry, or a nullEnvelopeif thisGeometryis empty. UnlikegetEnvelopeInternal, this method calculates theEnvelopeeach time it is called;getEnvelopeInternalcaches the result of this method.
- Returns:
- this
Geometrys bounding box; if theGeometryis empty,Envelope#isNullwill returntrue
public boolean contains(Geometry g)
Returnstrueifother.within(this)returnstrue.
- Parameters:
- Returns:
trueif thisGeometrycontainsother
public Geometry convexHull()
Returns the smallest convexPolygonthat contains all the points in theGeometry. This obviously applies only toGeometrys which contain 3 or more points; the results for degenerate cases are specified as follows:
Number of Points in argumentGeometryGeometryclass of result0 empty GeometryCollection1 Point2 LineString3 or more Polygon
- Returns:
- the minimum-area convex polygon containing this
Geometry' s points
public boolean crosses(Geometry g)
Returnstrueif the DE-9IM intersection matrix for the twoGeometrys is.
- T*T****** (for a point and a curve, a point and an area or a line and an area)
- 0******** (for two curves)
- Parameters:
- Returns:
trueif the twoGeometrys cross. For this function to returntrue, theGeometrys must be a point and a curve; a point and a surface; two curves; or a curve and a surface.
public Geometry difference(Geometry other)
Returns aGeometryrepresenting the points making up thisGeometrythat do not make upother. This method returns the closure of the resultantGeometry.
- Parameters:
other- theGeometrywith which to compute the difference
- Returns:
- the point set difference of this
Geometrywithother
public boolean disjoint(Geometry g)
Returnstrueif the DE-9IM intersection matrix for the twoGeometrys is FF*FF****.
- Parameters:
- Returns:
trueif the twoGeometrys are disjoint
public double distance(Geometry g)
Returns the minimum distance between thisGeometryand theGeometryg
- Parameters:
g- theGeometryfrom which to compute the distance
public boolean equals(Geometry g)
Returnstrueif the DE-9IM intersection matrix for the twoGeometrys is T*F**FFF*.
- Parameters:
- Returns:
trueif the twoGeometrys are equal
public boolean equalsExact(Geometry other)
Returns true if the twoGeometrys are exactly equal. Two Geometries are exactly equal iff:If this and the other
- they have the same class
- they have the same values of Coordinates in their internal Coordinate lists, in exactly the same order.
Geometrys are composites and any children are notGeometrys, returns false. This provides a stricter test of equality thanequals.
- Parameters:
other- theGeometrywith which to compare thisGeometry
- Returns:
trueif this and the otherGeometryare of the same class and have equal internal data.
public abstract boolean equalsExact(Geometry other, double tolerance)
Returns true if the twoGeometrys are exactly equal, up to a specified tolerance. Two Geometries are exactly within a tolerance equal iff:If this and the other
- they have the same class
- they have the same values of Coordinates, within the given tolerance distance, in their internal Coordinate lists, in exactly the same order.
Geometrys are composites and any children are notGeometrys, returns false.
- Parameters:
other- theGeometrywith which to compare thisGeometry
- Returns:
trueif this and the otherGeometryare of the same class and have equal internal data.
public void geometryChanged()
Notifies this Geometry that its Coordinates have been changed by an external party (using a CoordinateFilter, for example). The Geometry will flush and/or update any information it has cached (such as itsEnvelope).
protected void geometryChangedAction()
Notifies this Geometry that its Coordinates have been changed by an external party. When #geometryChanged is called, this method will be called for this Geometry and its component Geometries.
- See Also:
apply(GeometryComponentFilter)
public double getArea()
Returns the area of thisGeometry. Areal Geometries have a non-zero area. They override this function to compute the area. Others return 0.0
- Returns:
- the area of the Geometry
public abstract Geometry getBoundary()
Returns the boundary, or the empty geometry if thisGeometryis 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."
- Returns:
- the closure of the combinatorial boundary of this
Geometry
public abstract int getBoundaryDimension()
Returns the dimension of thisGeometrys inherent boundary.
- Returns:
- the dimension of the boundary of the class implementing this interface, whether or not this object is the empty geometry. Returns
Dimension.FALSEif the boundary is the empty geometry.
public Point getCentroid()
Computes the centroid of thisGeometry. 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)
- Returns:
- a
Pointwhich is the centroid of this Geometry
public abstract Coordinate getCoordinate()
Returns a vertex of thisGeometry.
- Returns:
- a
Coordinatewhich is a vertex of thisGeometry. Returnsnullif this Geometry is empty
public abstract Coordinate[] getCoordinates()
Returns thisGeometrys vertices. If you modify the coordinates in this array, be sure to call #geometryChanged afterwards. TheGeometrys contained by compositeGeometrys must be Geometry's; that is, they must implementgetCoordinates.
- Returns:
- the vertices of this
Geometry
public abstract int getDimension()
Returns the dimension of thisGeometry.
- Returns:
- the dimension of the class implementing this interface, whether or not this object is the empty geometry
public Geometry getEnvelope()
Returns thisGeometrys bounding box. If thisGeometryis the empty geometry, returns an emptyPoint. If theGeometryis a point, returns a non-emptyPoint. Otherwise, returns aPolygonwhose points are (minx, miny), (maxx, miny), (maxx, maxy), (minx, maxy), (minx, miny).
- Returns:
- an empty
Point(for emptyGeometrys), aPoint(forPoints) or aPolygon(in all other cases)
public Envelope getEnvelopeInternal()
Returns the minimum and maximum x and y values in thisGeometry, or a nullEnvelopeif thisGeometryis empty.
- Returns:
- this
Geometrys bounding box; if theGeometryis empty,Envelope#isNullwill returntrue
public GeometryFactory getFactory()
Gets the factory which contains the context in which this geometry was created.
- Returns:
- the factory for this geometry
public Geometry getGeometryN(int n)
Returns an elementGeometryfrom aGeometryCollection(orthis, if the geometry is not a collection).
- Parameters:
n- the index of the geometry element
- Returns:
- the n'th geometry contained in this geometry
public abstract String getGeometryType()
Returns the name of this object'scom.vivid.jts.geominterface.
- Returns:
- the name of this
Geometrys most specificcom.vividsolutions.jts.geominterface
public Point getInteriorPoint()
Computes an interior point of thisGeometry. 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.
- Returns:
- a
Pointwhich is in the interior of this Geometry
public double getLength()
Returns the length of thisGeometry. Linear geometries return their length. Areal geometries return their perimeter. They override this function to compute the area. Others return 0.0
- Returns:
- the length of the Geometry
public int getNumGeometries()
Returns the number ofGeometrys in aGeometryCollection(or 1, if the geometry is not a collection).
- Returns:
- the number of geometries contained in this geometry
public abstract int getNumPoints()
Returns the count of thisGeometrys vertices. TheGeometrys contained by compositeGeometrys must be Geometry's; that is, they must implementgetNumPoints
- Returns:
- the number of vertices in this
Geometry
public PrecisionModel getPrecisionModel()
Returns thePrecisionModelused by theGeometry.
- Returns:
- the specification of the grid of allowable points, for this
Geometryand all otherGeometrys
public int getSRID()
Deprecated. use
getUserDatainsteadReturns the ID of the Spatial Reference System used by theGeometry. JTS supports Spatial Reference System information in the simple way defined in the SFS. A Spatial Reference System ID (SRID) is present in eachGeometryobject.Geometryprovides basic accessor operations for this field, but no others. The SRID is represented as an integer.
- Returns:
- the ID of the coordinate space in which the
Geometryis defined.
public Object getUserData()
Gets the user data object for this geometry, if any.
- Returns:
- the user data object, or
nullif none set
protected static boolean hasNonEmptyElements(Geometry[] geometries)
Returns true if the array contains any non-emptyGeometrys.
- Parameters:
geometries- an array ofGeometrys; no elements may benull
- Returns:
trueif any of theGeometrysisEmptymethods returnfalse
protected static boolean hasNullElements(Object[] array)
Returns true if the array contains anynullelements.
- Parameters:
array- an array to validate
- Returns:
trueif any ofarrays elements arenull
public Geometry intersection(Geometry other)
Returns aGeometryrepresenting the points shared by thisGeometryandother.
- Parameters:
other- theGeometrywith which to compute the intersection
- Returns:
- the points common to the two
Geometrys
public boolean intersects(Geometry g)
Returnstrueifdisjointreturns false.
- Parameters:
- Returns:
trueif the twoGeometrys intersect
public abstract boolean isEmpty()
Returns whether or not the set of points in thisGeometryis empty.
- Returns:
trueif thisGeometryequals the empty geometry
protected boolean isEquivalentClass(Geometry other)
Returns whether the twoGeometrys are equal, from the point of view of theequalsExactmethod. Called byequalsExact. In general, twoGeometryclasses are considered to be "equivalent" only if they are the same class. An exception isLineString, which is considered to be equivalent to its subclasses.
- Parameters:
other- theGeometrywith which to compare thisGeometryfor equality
- Returns:
trueif the classes of the twoGeometrys are considered to be equal by theequalsExactmethod.
public boolean isRectangle()
public abstract boolean isSimple()
Returns false if theGeometrynot simple. Subclasses provide their own definition of "simple". If thisGeometryis empty, returnstrue. In general, the SFS specifications of simplicity seem to follow the following rule:For all empty
- A Geometry is simple iff the only self-intersections are at boundary points.
Geometrys,isSimple=true.
- Returns:
trueif thisGeometryhas any points of self-tangency, self-intersection or other anomalous points
public boolean isValid()
Tests the validity of thisGeometry. Subclasses provide their own definition of "valid".
- Returns:
trueif thisGeometryis valid
- See Also:
IsValidOp
public boolean isWithinDistance(Geometry geom, double distance)
Tests whether the distance from thisGeometryto another is less than or equal to a specified value.
- Parameters:
geom- the Geometry to check the distance todistance- the distance value to compare
- Returns:
trueif the geometries are less thandistanceapart.
public abstract void normalize()
Converts thisGeometryto normal form (or canonical form ). Normal form is a unique representation forGeometrys. It can be used to test whether twoGeometrys 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 boolean overlaps(Geometry g)
Returnstrueif the DE-9IM intersection matrix for the twoGeometrys is.
- T*T***T** (for two points or two surfaces)
- 1*T***T** (for two curves)
- Parameters:
- Returns:
trueif the twoGeometrys overlap. For this function to returntrue, theGeometrys must be two points, two curves or two surfaces.
public IntersectionMatrix relate(Geometry g)
Returns the DE-9IM intersection matrix for the twoGeometrys.
- Parameters:
- Returns:
- a matrix describing the intersections of the interiors, boundaries and exteriors of the two
Geometrys
public boolean relate(Geometry g, String intersectionPattern)
Returnstrueif the elements in the DE-9IM intersection matrix for the twoGeometrys match the elements inintersectionPattern, which may be:For more information on the DE-9IM, see the OpenGIS Simple Features Specification.
- 0
- 1
- 2
- T ( = 0, 1 or 2)
- F ( = -1)
- * ( = -1, 0, 1 or 2)
- Parameters:
intersectionPattern- the pattern against which to check the intersection matrix for the twoGeometrys
- Returns:
trueif the DE-9IM intersection matrix for the twoGeometrys matchintersectionPattern
public void setSRID(int SRID)
Deprecated. use
setUserDatainsteadSets the ID of the Spatial Reference System used by theGeometry.
public void setUserData(Object userData)
A simple scheme for applications to add their own custom data to a Geometry. An example use might be to add an object representing a Coordinate Reference System. Note that user data objects are not present in geometries created by construction methods.
- Parameters:
userData- an object, the semantics for which are defined by the application using this Geometry
public Geometry symDifference(Geometry other)
Returns a set combining the points in thisGeometrynot inother, and the points inothernot in thisGeometry. This method returns the closure of the resultantGeometry.
- Parameters:
other- theGeometrywith which to compute the symmetric difference
- Returns:
- the point set symmetric difference of this
Geometrywithother
public String toString()
public String toText()
Returns the Well-known Text representation of thisGeometry. For a definition of the Well-known Text format, see the OpenGIS Simple Features Specification.
- Returns:
- the Well-known Text representation of this
Geometry
public boolean touches(Geometry g)
Returnstrueif the DE-9IM intersection matrix for the twoGeometrys is FT*******, F**T***** or F***T****.
- Parameters:
- Returns:
trueif the twoGeometrys touch; Returns false if bothGeometrys are points
public Geometry union(Geometry other)
Returns aGeometryrepresenting all the points in thisGeometryandother.
- Parameters:
other- theGeometrywith which to compute the union
- Returns:
- a set combining the points of this
Geometryand the points ofother
public boolean within(Geometry g)
Returnstrueif the DE-9IM intersection matrix for the twoGeometrys is T*F**F***.
- Parameters:
- Returns:
trueif thisGeometryis withinother