Package org.geolatte.geom
Class Polygon<P extends Position>
- java.lang.Object
-
- org.geolatte.geom.Geometry<P>
-
- org.geolatte.geom.Polygon<P>
-
- All Implemented Interfaces:
Serializable,Iterable<LinearRing<P>>,Complex<P,LinearRing<P>>,Polygonal<P>
public class Polygon<P extends Position> extends Geometry<P> implements Polygonal<P>, Complex<P,LinearRing<P>>
A planar surface defined by 1 exterior boundary and 0 or more interior boundaries. Each interior boundary defines a hole in thePolygon.The exterior boundary
LinearRingdefines the "top" of the surface which is the side of the surface from which the exterior boundary appears to traverse the boundary in a counter clockwise direction. The interiorLinearRings will have the opposite orientation and appear as clockwise when viewed from the "top".The rules that define valid
Polygons are as followsPolygons are topologically closed;- The boundary of a
Polygonconsists of a set ofLinearRings that make up its exterior and interior boundaries; - No two rings in the boundary cross and the rings in the boundary of a
Polygonmay intersect at aPointbut only as a tangent - A
Polygonmay not have cut lines, spikes or punctures; - The interior of every
Polygonis a connected point set; - The exterior of a
Polygonwith 1 or more holes is not connected. Each hole defines a connected component of the exterior
- Author:
- Karel Maesen, Geovise BVBA creation-date: 4/14/11
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Polygon(CoordinateReferenceSystem<P> crs)Polygon(LinearRing<P>... rings)Creates aPolygonwith the specified array of exterior and interior boundaries.Polygon(PositionSequence<P> positionSequence, CoordinateReferenceSystem<P> crs)Creates aPolygonwith no holes, and having the specifiedPositionSequenceas exterior boundary
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(GeometryVisitor<P> visitor)Accepts aGeometryVisitor.<Q extends Position>
Polygon<Q>as(Class<Q> castToType)LinearRing<P>[]components()Returns the componentsClass<? extends Geometry>getComponentType()Returns theClassof which all constituentGeometrys are instances.intgetDimension()Returns the topological dimension of this instance.LinearRing<P>getExteriorRing()Returns the exterior boundary of thisPolygon.GeometryTypegetGeometryType()Returns the type of thisGeometry.LinearRing<P>getInteriorRingN(int index)Returns the specified interior ring.intgetNumGeometries()Returns the number of constituentGeometrysintgetNumInteriorRing()returns the number of interior boundaries.Iterator<LinearRing<P>>iterator()Returns anIteratorover the boundaries of thisPolygon.-
Methods inherited from class org.geolatte.geom.Geometry
checkCast, equals, forceToCrs, getCoordinateDimension, getCoordinateReferenceSystem, getCrs, getEnvelope, getNumPositions, getPositionClass, getPositionN, getPositions, getSRID, hashCode, isEmpty, nestPositionSequences, toString, writeReplace
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
Polygon
public Polygon(CoordinateReferenceSystem<P> crs)
-
Polygon
public Polygon(PositionSequence<P> positionSequence, CoordinateReferenceSystem<P> crs)
Creates aPolygonwith no holes, and having the specifiedPositionSequenceas exterior boundary- Parameters:
positionSequence- thePositionSequencerepresenting the exterior boundary- Throws:
IllegalArgumentException- when the specifiedPositionSequencedoes not form aLinearRing(i.e., is empty or not closed).
-
Polygon
public Polygon(LinearRing<P>... rings)
Creates aPolygonwith the specified array of exterior and interior boundaries.- Parameters:
rings- the array of thePolygon's boundaries: the first element is the exterior boundary, all subsequent rings represent interior boundaries.- Throws:
IllegalArgumentException- when the specifiedPositionSequencedoes not form aLinearRing(i.e., is empty or not closed).
-
-
Method Detail
-
getExteriorRing
public LinearRing<P> getExteriorRing()
Returns the exterior boundary of thisPolygon.- Returns:
- a
LinearRingrepresenting the exterior boundary of thisPolygon.
-
getNumInteriorRing
public int getNumInteriorRing()
returns the number of interior boundaries.- Returns:
- the number of interior boundaries
-
getInteriorRingN
public LinearRing<P> getInteriorRingN(int index)
Returns the specified interior ring.- Parameters:
index- the (zero-based) position of the interior boundary in the list of interior boundaries.- Returns:
- the
LinearRingat the position specified by the parameter index.
-
getDimension
public int getDimension()
Description copied from class:GeometryReturns the topological dimension of this instance. In non-homogenous collections, this will return the largest topological dimension of the containedGeometries.- Specified by:
getDimensionin classGeometry<P extends Position>- Returns:
- the topological dimension of this instance
-
getGeometryType
public GeometryType getGeometryType()
Description copied from class:GeometryReturns the type of thisGeometry.- Specified by:
getGeometryTypein classGeometry<P extends Position>- Returns:
- the
GeometryTypeof this instance.
-
iterator
public Iterator<LinearRing<P>> iterator()
Returns anIteratorover the boundaries of thisPolygon.The boundaries are returned in order, with the first element being the exterior boundary.
-
accept
public void accept(GeometryVisitor<P> visitor)
Description copied from class:GeometryAccepts aGeometryVisitor.If this
Geometryinstance is aGeometryCollectionthen it will pass the visitor to its containedGeometries.
-
getNumGeometries
public int getNumGeometries()
Description copied from interface:ComplexReturns the number of constituentGeometrys- Specified by:
getNumGeometriesin interfaceComplex<P extends Position,LinearRing<P extends Position>>- Returns:
- the number of constituent
Geometrys
-
getComponentType
public Class<? extends Geometry> getComponentType()
Description copied from interface:ComplexReturns theClassof which all constituentGeometrys are instances.- Specified by:
getComponentTypein interfaceComplex<P extends Position,LinearRing<P extends Position>>- Returns:
- the
Classof which all constituentGeometrys are instances.
-
components
public LinearRing<P>[] components()
Returns the components- Specified by:
componentsin interfaceComplex<P extends Position,LinearRing<P extends Position>>- Returns:
- an array containing all component objects
-
-