com.vividsolutions.jts.geom

Class GeometryCollection

Implemented Interfaces:
Cloneable, Comparable, Serializable
Known Direct Subclasses:
MultiLineString, MultiPoint, MultiPolygon

public class GeometryCollection
extends Geometry

Basic implementation of GeometryCollection.
Version:
1.6

Field Summary

protected Geometry[]
geometries
Internal representation of this GeometryCollection.

Fields inherited from class com.vividsolutions.jts.geom.Geometry

SRID, envelope

Constructor Summary

GeometryCollection(Geometry[] geometries, GeometryFactory factory)
GeometryCollection(Geometry[] geometries, PrecisionModel precisionModel, int SRID)
Deprecated. Use GeometryFactory instead

Method Summary

void
apply(CoordinateFilter filter)
Performs an operation with or on this Geometry's coordinates.
void
apply(GeometryComponentFilter filter)
Performs an operation with or on this Geometry and its component Geometry's.
void
apply(GeometryFilter filter)
Performs an operation with or on this Geometry and its subelement Geometrys (if any).
Object
clone()
protected int
compareToSameClass(Object o)
Returns whether this Geometry is greater than, equal to, or less than another Geometry having the same class.
protected Envelope
computeEnvelopeInternal()
Returns the minimum and maximum x and y values in this Geometry , or a null Envelope if this Geometry is empty.
boolean
equalsExact(Geometry other, double tolerance)
Returns true if the two Geometrys are exactly equal, up to a specified tolerance.
double
getArea()
Returns the area of this GeometryCollection
Geometry
getBoundary()
Returns the boundary, or the empty geometry if this Geometry is empty.
int
getBoundaryDimension()
Returns the dimension of this Geometrys inherent boundary.
Coordinate
getCoordinate()
Returns a vertex of this Geometry.
Coordinate[]
getCoordinates()
Collects all coordinates of all subgeometries into an Array.
int
getDimension()
Returns the dimension of this Geometry.
Geometry
getGeometryN(int n)
Returns an element Geometry from a GeometryCollection (or this, if the geometry is not a collection).
String
getGeometryType()
Returns the name of this object's com.vivid.jts.geom interface.
double
getLength()
Returns the length of this Geometry.
int
getNumGeometries()
Returns the number of Geometrys in a GeometryCollection (or 1, if the geometry is not a collection).
int
getNumPoints()
Returns the count of this Geometrys vertices.
boolean
isEmpty()
Returns whether or not the set of points in this Geometry is empty.
boolean
isSimple()
Returns false if the Geometry not simple.
void
normalize()
Converts this Geometry to normal form (or canonical form ).

Methods inherited from class com.vividsolutions.jts.geom.Geometry

apply, apply, apply, buffer, buffer, checkNotGeometryCollection, clone, compare, compareTo, compareToSameClass, computeEnvelopeInternal, contains, convexHull, crosses, difference, disjoint, distance, equal, equals, equalsExact, equalsExact, geometryChanged, geometryChangedAction, getArea, getBoundary, getBoundaryDimension, getCentroid, getCoordinate, getCoordinates, getDimension, getEnvelope, getEnvelopeInternal, getFactory, getGeometryN, getGeometryType, getInteriorPoint, getLength, getNumGeometries, getNumPoints, getPrecisionModel, getSRID, getUserData, hasNonEmptyElements, hasNullElements, intersection, intersects, isEmpty, isEquivalentClass, isRectangle, isSimple, isValid, isWithinDistance, normalize, overlaps, relate, relate, setSRID, setUserData, symDifference, toString, toText, touches, union, within

Field Details

geometries

protected Geometry[] geometries
Internal representation of this GeometryCollection.

Constructor Details

GeometryCollection

public GeometryCollection(Geometry[] geometries,
                          GeometryFactory factory)
Parameters:
geometries - the Geometrys for this GeometryCollection, or null or an empty array to create the empty geometry. Elements may be empty Geometrys, but not nulls.

GeometryCollection

public GeometryCollection(Geometry[] geometries,
                          PrecisionModel precisionModel,
                          int SRID)

Deprecated. Use GeometryFactory instead

Method Details

apply

public void apply(CoordinateFilter filter)
Performs an operation with or on this 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).
Overrides:
apply in interface Geometry
Parameters:
filter - the filter to apply to this Geometry's coordinates

apply

public 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.
Overrides:
apply in interface Geometry
Parameters:
filter - the filter to apply to this Geometry.

apply

public void apply(GeometryFilter filter)
Performs an operation with or on this Geometry and its subelement Geometrys (if any). Only GeometryCollections and subclasses have subelement Geometry's.
Overrides:
apply in interface Geometry
Parameters:
filter - the filter to apply to this Geometry (and its children, if it is a GeometryCollection).

clone

public Object clone()
Overrides:
clone in interface Geometry

compareToSameClass

protected int compareToSameClass(Object o)
Returns whether this Geometry is greater than, equal to, or less than another Geometry having the same class.
Overrides:
compareToSameClass in interface Geometry
Parameters:
o - a Geometry having the same class as this Geometry
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

computeEnvelopeInternal

protected Envelope computeEnvelopeInternal()
Returns the minimum and maximum x and y values in this 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.
Overrides:
computeEnvelopeInternal in interface Geometry
Returns:
this Geometrys bounding box; if the Geometry is empty, Envelope#isNull will return true

equalsExact

public boolean equalsExact(Geometry other,
                           double tolerance)
Returns true if the two Geometrys are exactly equal, up to a specified tolerance. Two Geometries are exactly within a tolerance equal iff:
  • 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.
If this and the other Geometrys are composites and any children are not Geometrys, returns false.
Overrides:
equalsExact in interface Geometry
Parameters:
other - the Geometry with which to compare this Geometry
Returns:
true if this and the other Geometry are of the same class and have equal internal data.

getArea

public double getArea()
Returns the area of this GeometryCollection
Overrides:
getArea in interface Geometry
Returns:
the area of the polygon

getBoundary

public Geometry getBoundary()
Returns the boundary, or the empty geometry if this 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."
Overrides:
getBoundary in interface Geometry
Returns:
the closure of the combinatorial boundary of this Geometry

getBoundaryDimension

public int getBoundaryDimension()
Returns the dimension of this Geometrys inherent boundary.
Overrides:
getBoundaryDimension in interface Geometry
Returns:
the dimension of the boundary of the class implementing this interface, whether or not this object is the empty geometry. Returns Dimension.FALSE if the boundary is the empty geometry.

getCoordinate

public Coordinate getCoordinate()
Returns a vertex of this Geometry.
Overrides:
getCoordinate in interface Geometry
Returns:
a Coordinate which is a vertex of this Geometry. Returns null if this Geometry is empty

getCoordinates

public Coordinate[] getCoordinates()
Collects all coordinates of all subgeometries into an Array. Note that while changes to the coordinate objects themselves may modify the Geometries in place, the returned Array as such is only a temporary container which is not synchronized back.
Overrides:
getCoordinates in interface Geometry
Returns:
the collected coordinates

getDimension

public int getDimension()
Returns the dimension of this Geometry.
Overrides:
getDimension in interface Geometry
Returns:
the dimension of the class implementing this interface, whether or not this object is the empty geometry

getGeometryN

public Geometry getGeometryN(int n)
Returns an element Geometry from a GeometryCollection (or this, if the geometry is not a collection).
Overrides:
getGeometryN in interface Geometry
Parameters:
n - the index of the geometry element
Returns:
the n'th geometry contained in this geometry

getGeometryType

public String getGeometryType()
Returns the name of this object's com.vivid.jts.geom interface.
Overrides:
getGeometryType in interface Geometry
Returns:
the name of this Geometrys most specific com.vividsolutions.jts.geom interface

getLength

public double getLength()
Returns the length of this Geometry. Linear geometries return their length. Areal geometries return their perimeter. They override this function to compute the area. Others return 0.0
Overrides:
getLength in interface Geometry
Returns:
the length of the Geometry

getNumGeometries

public int getNumGeometries()
Returns the number of Geometrys in a GeometryCollection (or 1, if the geometry is not a collection).
Overrides:
getNumGeometries in interface Geometry
Returns:
the number of geometries contained in this geometry

getNumPoints

public int getNumPoints()
Returns the count of this Geometrys vertices. The Geometry s contained by composite Geometrys must be Geometry's; that is, they must implement getNumPoints
Overrides:
getNumPoints in interface Geometry
Returns:
the number of vertices in this Geometry

isEmpty

public boolean isEmpty()
Returns whether or not the set of points in this Geometry is empty.
Overrides:
isEmpty in interface Geometry
Returns:
true if this Geometry equals the empty geometry

isSimple

public boolean isSimple()
Returns false if the 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:

  • A Geometry is simple iff the only self-intersections are at boundary points.
For all empty Geometrys, isSimple = true.
Overrides:
isSimple in interface Geometry
Returns:
true if this Geometry has any points of self-tangency, self-intersection or other anomalous points

normalize

public void normalize()
Converts this Geometry to normal form (or canonical form ). Normal form is a unique representation for Geometry s. It can be used to test whether two Geometrys 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.
Overrides:
normalize in interface Geometry