Class Polygon

Hierarchy: Object , Geometry, Polygon
All Implemented Interfaces: Cloneable , Comparable , Serializable , Polygonal
public class Polygon
extends Geometry
implements Polygonal
Represents a polygon with linear edges, which may include holes. The outer boundary (shell) and inner boundaries (holes) of the polygon are represented by LinearRings. The boundary rings of the polygon may have any orientation. Polygons are closed, simple geometries by definition.

The polygon model conforms to the assertions specified in the OpenGIS Simple Features Specification for SQL.

A Polygon is topologically valid if and only if:

  • the coordinates which define it are valid coordinates
  • the linear rings for the shell and holes are valid (i.e. are closed and do not self-intersect)
  • holes touch the shell or another hole at at most one point (which implies that the rings of the shell and holes must not cross)
  • the interior of the polygon is connected, or equivalently no sequence of touching holes makes the interior of the polygon disconnected (i.e. effectively split the polygon into two pieces).

Other

  • version: 1.7
public Polygon(LinearRing shell, PrecisionModel precisionModel, int SRID)
Constructs a Polygon with the given exterior boundary.
Parameters:
shell - shell the outer boundary of the new Polygon, or null or an empty LinearRing if the empty geometry is to be created.
precisionModel - precisionModel the specification of the grid of allowable points for this Polygon
SRID - SRID the ID of the Spatial Reference System used by this Polygon
Deprecation:
Use GeometryFactory instead
public Polygon(LinearRing shell, LinearRing[] holes, PrecisionModel precisionModel, int SRID)
Constructs a Polygon with the given exterior boundary and interior boundaries.
Parameters:
shell - shell the outer boundary of the new Polygon, or null or an empty LinearRing if the empty geometry is to be created.
holes - holes the inner boundaries of the new Polygon , or null or empty LinearRings if the empty geometry is to be created.
precisionModel - precisionModel the specification of the grid of allowable points for this Polygon
SRID - SRID the ID of the Spatial Reference System used by this Polygon
Deprecation:
Use GeometryFactory instead
public Polygon(LinearRing shell, LinearRing[] holes, GeometryFactory factory)
Constructs a Polygon with the given exterior boundary and interior boundaries.
Parameters:
shell - shell the outer boundary of the new Polygon, or null or an empty LinearRing if the empty geometry is to be created.
holes - holes the inner boundaries of the new Polygon , or null or empty LinearRings if the empty geometry is to be created.
public Coordinate getCoordinate()
public Coordinate[] getCoordinates()
public int getNumPoints()
public int getDimension()
public int getBoundaryDimension()
public boolean isEmpty()
public boolean isRectangle()
public LinearRing getExteriorRing()
public int getNumInteriorRing()
public LinearRing getInteriorRingN(int n)
public String getGeometryType()
public double getArea()
Returns the area of this Polygon
Returns:
the area of the polygon
public double getLength()
Returns the perimeter of this Polygon
Returns:
the perimeter of the polygon
public Geometry getBoundary()
Computes the boundary of this geometry
See also:
Geometry#getBoundary
Returns:
a lineal geometry (which may be empty)
protected Envelope computeEnvelopeInternal()
public boolean equalsExact(Geometry other, double tolerance)
public void apply(CoordinateFilter filter)
public void apply(CoordinateSequenceFilter filter)
public void apply(GeometryFilter filter)
public void apply(GeometryComponentFilter filter)
public Object clone()
Creates and returns a full copy of this Polygon object. (including all coordinates contained by it).
Returns:
a clone of this instance
protected Polygon copyInternal()
public Geometry convexHull()
public void normalize()
protected int compareToSameClass(Object o)
protected int compareToSameClass(Object o, CoordinateSequenceComparator comp)
protected int getTypeCode()
public Polygon reverse()
protected Polygon reverseInternal()