public class Polygon extends DefaultGeometry implements Surface, PolygonTypeGeometry
Polygon class defines a polygon in a 2D space. | Modifier and Type | Field and Description |
|---|---|
protected LinearRing[] |
rings
the rings defining the polygon.
|
GEOMETRY_ANNOTATION, GEOMETRY_COMPLEX, GEOMETRY_ELLIPSE, GEOMETRY_LINE, GEOMETRY_LINEAR_RING, GEOMETRY_LINESTRING, GEOMETRY_MULTI_ANNOTATION, GEOMETRY_MULTI_LINESTRING, GEOMETRY_MULTI_POINT, GEOMETRY_MULTI_POLYGON, GEOMETRY_POINT, GEOMETRY_POLYGON, GEOMETRY_RECTANGLE| Constructor and Description |
|---|
Polygon() |
Polygon(double[][] tab)
Constructs a Polygon given a matrix of double (rings made of points, points are entered as x y in the array), doesn't check if it's valid !
|
Polygon(LinearRing ring)
Constructs a Polygon given a single ring, doesn't check if it's valid !
|
Polygon(LinearRing[] rings)
Constructs a Polygon given rings, doesn't check if it's valid !
|
| Modifier and Type | Method and Description |
|---|---|
double |
area()
Computes the area of this Polygon
|
java.lang.String |
asText()
Returns this geometry encoded using the Well-Known Text (WKT) standard.
|
Geometry |
boundary()
The boundary (!= boundingBox) of this polygon
|
Point |
centroid()
Computes the centroid (center of mass) of the polygon, considering
possibles holes in it.
|
Polygon |
clone()
Clones the current polygon object.
|
void |
createBounds()
creates the bounding box
called in the constructor, not needed from outside |
boolean |
equals(java.lang.Object o) |
LinearRing |
exteriorRing()
The Exterior Ring
|
Rectangle |
getBounds()
Returns the bounding box
|
Point |
getCenteredPoint()
This method returns a point that is typically centered on the geometry.
|
short |
getGeometryId()
Returns the geometry class id.
|
int |
getGeometryType()
Returns the geometry type for this geometry.
|
LinearRing[] |
getRings()
The rings defining this polygon
|
boolean |
hasHoles() |
LinearRing |
interiorRingN(int N) |
double |
length()
Returns the geometry length.
|
int |
numInteriorRing()
The number of holes
|
Point |
pointOnSurface()
a Point on this Polygon, in fact the first of the exteriorRing (not in the interior)
|
PolygonGeometryIterator |
polygonIterator() |
Point[] |
serialize()
This polygon as an array of Point
|
void |
setRings(LinearRing[] rings) |
int |
sizeOf()
Returns an approximation in bytes of the memory used by this geometry.
|
boolean |
spatiallyEquals(Geometry geometry,
PrecisionModel precisionModel)
Tests if this Polygon is equal to the argument, on a topological point of vue
it means that they represents the same geometry, even if it is described differently (direction of the rings, order of the rings) it does not remove additional points on lineString (3 points aligned), one must use smoother.removeExtraPoints() before in order to achieve that. |
java.lang.String |
toString()
Returns informations about the current geometry.
|
Geometry |
transform(Transformation tr)
Creates a clone of the current polygon and returns
the new instance transformed with the specified geometry transformation.
The returned geometry can be of any geometry types after the transformation. |
void |
translate(double dx,
double dy)
Translate this Polygon
|
boolean |
validate()
validate this polygon
ie test if it autointersects and if holes crosse the exteriorRing |
spatiallyEqualsfinalize, getClass, hashCode, notify, notifyAll, wait, wait, waitspatiallyEqualsprotected LinearRing[] rings
public Polygon()
public Polygon(LinearRing ring)
ring - public Polygon(LinearRing[] rings)
rings - public Polygon(double[][] tab)
tab - public Rectangle getBounds()
public boolean validate()
public void createBounds()
createBounds in interface Geometrypublic Point centroid()
centroid in interface PolygonTypeGeometrycentroid in interface Surfacepublic double area()
public double length()
Geometrypublic Polygon clone()
clone in interface Geometryclone in class DefaultGeometrypublic Point[] serialize()
public LinearRing exteriorRing()
public int numInteriorRing()
public LinearRing interiorRingN(int N)
public Geometry boundary()
public Point pointOnSurface()
pointOnSurface in interface PolygonTypeGeometrypointOnSurface in interface Surfacepublic LinearRing[] getRings()
public void setRings(LinearRing[] rings)
rings - public boolean hasHoles()
public boolean spatiallyEquals(Geometry geometry, PrecisionModel precisionModel)
spatiallyEquals in interface Geometrygeometry - precisionModel - the precision model to use while comparing geometries.public boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic java.lang.String toString()
Geometrypublic PolygonGeometryIterator polygonIterator()
polygonIterator in interface PolygonTypeGeometrypublic void translate(double dx,
double dy)
public short getGeometryId()
GeometrygetGeometryId in interface Geometrypublic int getGeometryType()
GeometrygetGeometryType in interface Geometryfor more details.public Geometry transform(Transformation tr)
public Point getCenteredPoint()
GeometrygetCenteredPoint in interface GeometryGeometry.getCenteredPoint()public int sizeOf()
public java.lang.String asText()
DefaultGeometryasText in interface GeometryasText in class DefaultGeometry