com.vividsolutions.jts.geom

Class Polygon

Implemented Interfaces:
Cloneable, Comparable, Serializable

public class Polygon
extends Geometry

Represents a linear polygon, which may include holes. The shell and holes of the polygon are represented by LinearRings. In a valid polygon, holes may touch the shell or other holes at a single point. However, no sequence of touching holes may split the polygon into two pieces. The orientation of the rings in the polygon does not matter.

The shell and holes must conform to the assertions specified in the OpenGIS Simple Features Specification for SQL .

Version:
1.7

Field Summary

protected LinearRing[]
holes
The interior boundaries, if any.
protected LinearRing
shell
The exterior boundary, or null if this Polygon is empty.

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

SRID, envelope

Constructor Summary

Polygon(LinearRing shell, LinearRing[] holes, GeometryFactory factory)
Constructs a Polygon with the given exterior boundary and interior boundaries.
Polygon(LinearRing shell, LinearRing[] holes, PrecisionModel precisionModel, int SRID)
Deprecated. Use GeometryFactory instead
Polygon(LinearRing shell, PrecisionModel precisionModel, int SRID)
Deprecated. Use GeometryFactory instead

Method Summary

void
apply(CoordinateFilter filter)
void
apply(GeometryComponentFilter filter)
void
apply(GeometryFilter filter)
Object
clone()
protected int
compareToSameClass(Object o)
protected int
compareToSameClass(Object o, CoordinateSequenceComparator comp)
protected Envelope
computeEnvelopeInternal()
Geometry
convexHull()
boolean
equalsExact(Geometry other, double tolerance)
double
getArea()
Returns the area of this Polygon
Geometry
getBoundary()
int
getBoundaryDimension()
Coordinate
getCoordinate()
Coordinate[]
getCoordinates()
int
getDimension()
LineString
getExteriorRing()
String
getGeometryType()
LineString
getInteriorRingN(int n)
double
getLength()
Returns the perimeter of this Polygon
int
getNumInteriorRing()
int
getNumPoints()
boolean
isEmpty()
boolean
isRectangle()
boolean
isSimple()
void
normalize()

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

apply, apply, apply, buffer, buffer, buffer, checkNotGeometryCollection, clone, compare, compareTo, compareTo, compareToSameClass, compareToSameClass, computeEnvelopeInternal, contains, convexHull, coveredBy, covers, 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

holes

protected LinearRing[] holes
The interior boundaries, if any. This instance var is never null. If there are no holes, the array is of zero length.

shell

protected LinearRing shell
The exterior boundary, or null if this Polygon is empty.

Constructor Details

Polygon

public Polygon(LinearRing shell,
               LinearRing[] holes,
               GeometryFactory factory)
Constructs a Polygon with the given exterior boundary and interior boundaries.
Parameters:
shell - the outer boundary of the new Polygon, or null or an empty LinearRing if the empty geometry is to be created.
holes - the inner boundaries of the new Polygon , or null or empty LinearRings if the empty geometry is to be created.

Polygon

public Polygon(LinearRing shell,
               LinearRing[] holes,
               PrecisionModel precisionModel,
               int SRID)

Deprecated. Use GeometryFactory instead

Constructs a Polygon with the given exterior boundary and interior boundaries.
Parameters:
shell - the outer boundary of the new Polygon, or null or an empty LinearRing if the empty geometry is to be created.
holes - the inner boundaries of the new Polygon , or null or empty LinearRings if the empty geometry is to be created.
precisionModel - the specification of the grid of allowable points for this Polygon
SRID - the ID of the Spatial Reference System used by this Polygon

Polygon

public Polygon(LinearRing shell,
               PrecisionModel precisionModel,
               int SRID)

Deprecated. Use GeometryFactory instead

Constructs a Polygon with the given exterior boundary.
Parameters:
shell - the outer boundary of the new Polygon, or null or an empty LinearRing if the empty geometry is to be created.
precisionModel - the specification of the grid of allowable points for this Polygon
SRID - the ID of the Spatial Reference System used by this Polygon

Method Details

apply

public void apply(CoordinateFilter filter)
Overrides:
apply in interface Geometry

apply

public void apply(GeometryComponentFilter filter)
Overrides:
apply in interface Geometry

apply

public void apply(GeometryFilter filter)
Overrides:
apply in interface Geometry

clone

public Object clone()
Overrides:
clone in interface Geometry

compareToSameClass

protected int compareToSameClass(Object o)
Overrides:
compareToSameClass in interface Geometry

compareToSameClass

protected int compareToSameClass(Object o,
                                 CoordinateSequenceComparator comp)
Overrides:
compareToSameClass in interface Geometry

computeEnvelopeInternal

protected Envelope computeEnvelopeInternal()
Overrides:
computeEnvelopeInternal in interface Geometry

convexHull

public Geometry convexHull()
Overrides:
convexHull in interface Geometry

equalsExact

public boolean equalsExact(Geometry other,
                           double tolerance)
Overrides:
equalsExact in interface Geometry

getArea

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

getBoundary

public Geometry getBoundary()
Overrides:
getBoundary in interface Geometry

getBoundaryDimension

public int getBoundaryDimension()
Overrides:
getBoundaryDimension in interface Geometry

getCoordinate

public Coordinate getCoordinate()
Overrides:
getCoordinate in interface Geometry

getCoordinates

public Coordinate[] getCoordinates()
Overrides:
getCoordinates in interface Geometry

getDimension

public int getDimension()
Overrides:
getDimension in interface Geometry

getExteriorRing

public LineString getExteriorRing()

getGeometryType

public String getGeometryType()
Overrides:
getGeometryType in interface Geometry

getInteriorRingN

public LineString getInteriorRingN(int n)

getLength

public double getLength()
Returns the perimeter of this Polygon
Overrides:
getLength in interface Geometry
Returns:
the perimeter of the polygon

getNumInteriorRing

public int getNumInteriorRing()

getNumPoints

public int getNumPoints()
Overrides:
getNumPoints in interface Geometry

isEmpty

public boolean isEmpty()
Overrides:
isEmpty in interface Geometry

isRectangle

public boolean isRectangle()
Overrides:
isRectangle in interface Geometry

isSimple

public boolean isSimple()
Overrides:
isSimple in interface Geometry

normalize

public void normalize()
Overrides:
normalize in interface Geometry