gistoolkit.features
Class Polygon

java.lang.Object
  extended bygistoolkit.features.Shape
      extended bygistoolkit.features.Polygon
Direct Known Subclasses:
PolygonM

public class Polygon
extends Shape

A Polygon is a group of rings, the first represents the external polygin, there may be zero or more holes as well.


Field Summary
 
Fields inherited from class gistoolkit.features.Shape
EQUAL_LIMIT, LINEARRING, LINESTRING, MULTILINESTRING, MULTIPOINT, MULTIPOLYGON, myEnvelope, NULLSHAPE, POINT, POLYGON, RASTER
 
Constructor Summary
Polygon()
          Polygon constructor comment.
Polygon(LinearRing inLinearRing)
          Create a new linear ring from the points.
Polygon(LinearRing inLinearRing, LinearRing[] inHoles)
          Create a new linear ring from the points.
 
Method Summary
 int add(double inX, double inY)
          Add the a point to this shape.
 boolean add(int inIndex, double inX, double inY)
          Adds the point to this shape at the given index.
 void addHole(int inIndex, LinearRing inLinearRing)
          Add a hole at the given index.
 void calculateEnvelope()
          Calculates the envelope based on the data in the polygon.
 java.lang.Object clone()
          Creates a copy of the Polygon
 boolean contains(Shape inShape)
          returns true if any of the contained polygons contain this shape.
 Point getCentroid()
          Find a point within the polygon .
 int getClosestIndex(double inX, double inY)
          Return the index of the point in the polygon that is the closest to this point.
 Point getClosestPoint(double inX, double inY)
          Return the point in the polygon that is the closest to this point.
 double getDistanceToPoint(double inX, double inY)
          Get the distance from this shape to the given point
 Envelope getEnvelope()
          return the bounding rectangle of this shape.
 LinearRing[] getHoles()
          Return the negative rings.
 int getNumPoints()
          Return the number of points in this shape.
 Point getPoint(int inIndex)
          Get the point at the given index.
 Point[] getPoints()
          Return the points that comprise the object
 LinearRing getPosativeRing()
          Return the posative Polygon from the shape.
 java.lang.String getShapeType()
          Return the type of shape this is
 java.lang.String getWKT()
          Returns the OGIS Well Know Text Representation of this shape
 boolean intersects(Shape inShape)
          Determines if the two shapes intersect
 boolean intersectsMultiPolygon(MultiPolygon inMultiPolygon)
          A Polygon intersects a MultiPolygon if it intersects any of the MultiPolygon's constituent Polygons.
 boolean intersectsPolygon(Polygon inPolygon)
          A polygon intersects another polygon if any of the rings of the polygon intersect, or one polygon is contained within the other.
 boolean intersectsRasterShape(RasterShape inRasterShape)
          A Polygon intersects a RasterShape if it intersects any of the envelope, or if it is contained within the envelope.
static boolean isPointInPolygon(Polygon inPolygon, Point inPoint)
          Performs a point in polygon calculation.
static boolean isPointInRing(LinearRing inRing, Point inPoint)
          Performs a point in polygon calculation.
 boolean remove(int inIndex)
          Delete the given point from the polygon.
 void removeHole(int inIndex)
          Remove a hole at the given index.
 void setPoint(int inIndex, double inXCoordinate, double inYCoordinate)
          Set the point at the given index.
 void translate(double inXDistance, double inYDistance)
          Translate the shape the given distance in the X and Y directions
 
Methods inherited from class gistoolkit.features.Shape
distance, getDistance, getDistanceToEnvelope, getDistanceToLine, getDistanceToLine, getLinesIntersect, linesIntersect, linesIntersect, pointOnLine, pointOnLine
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Polygon

public Polygon()
Polygon constructor comment.


Polygon

public Polygon(LinearRing inLinearRing)
Create a new linear ring from the points.


Polygon

public Polygon(LinearRing inLinearRing,
               LinearRing[] inHoles)
Create a new linear ring from the points.

Method Detail

getShapeType

public java.lang.String getShapeType()
Return the type of shape this is

Specified by:
getShapeType in class Shape

getNumPoints

public int getNumPoints()
Return the number of points in this shape.

Specified by:
getNumPoints in class Shape

getPoint

public Point getPoint(int inIndex)
Get the point at the given index.

Specified by:
getPoint in class Shape

setPoint

public void setPoint(int inIndex,
                     double inXCoordinate,
                     double inYCoordinate)
Set the point at the given index.

Specified by:
setPoint in class Shape

add

public int add(double inX,
               double inY)
Add the a point to this shape. Returns the location where the point was added. Returns -1 if it could not be added.

Specified by:
add in class Shape

add

public boolean add(int inIndex,
                   double inX,
                   double inY)
Adds the point to this shape at the given index.

Specified by:
add in class Shape

remove

public boolean remove(int inIndex)
Delete the given point from the polygon.

Specified by:
remove in class Shape

calculateEnvelope

public void calculateEnvelope()
Calculates the envelope based on the data in the polygon.

Overrides:
calculateEnvelope in class Shape

getEnvelope

public Envelope getEnvelope()
Description copied from class: Shape
return the bounding rectangle of this shape.

Specified by:
getEnvelope in class Shape

clone

public java.lang.Object clone()
Creates a copy of the Polygon

Specified by:
clone in class Shape

contains

public boolean contains(Shape inShape)
returns true if any of the contained polygons contain this shape.

Overrides:
contains in class Shape

getHoles

public LinearRing[] getHoles()
Return the negative rings.


addHole

public void addHole(int inIndex,
                    LinearRing inLinearRing)
Add a hole at the given index.


removeHole

public void removeHole(int inIndex)
Remove a hole at the given index.


getPosativeRing

public LinearRing getPosativeRing()
Return the posative Polygon from the shape.


isPointInPolygon

public static boolean isPointInPolygon(Polygon inPolygon,
                                       Point inPoint)
Performs a point in polygon calculation.


isPointInRing

public static boolean isPointInRing(LinearRing inRing,
                                    Point inPoint)
Performs a point in polygon calculation.


getPoints

public Point[] getPoints()
Return the points that comprise the object

Specified by:
getPoints in class Shape

getWKT

public java.lang.String getWKT()
Returns the OGIS Well Know Text Representation of this shape

Specified by:
getWKT in class Shape

translate

public void translate(double inXDistance,
                      double inYDistance)
Translate the shape the given distance in the X and Y directions

Specified by:
translate in class Shape

getClosestPoint

public Point getClosestPoint(double inX,
                             double inY)
Return the point in the polygon that is the closest to this point.


getClosestIndex

public int getClosestIndex(double inX,
                           double inY)
Return the index of the point in the polygon that is the closest to this point.

Specified by:
getClosestIndex in class Shape

getDistanceToPoint

public double getDistanceToPoint(double inX,
                                 double inY)
Get the distance from this shape to the given point

Specified by:
getDistanceToPoint in class Shape

intersects

public boolean intersects(Shape inShape)
Determines if the two shapes intersect

Specified by:
intersects in class Shape

intersectsPolygon

public boolean intersectsPolygon(Polygon inPolygon)
A polygon intersects another polygon if any of the rings of the polygon intersect, or one polygon is contained within the other.


intersectsMultiPolygon

public boolean intersectsMultiPolygon(MultiPolygon inMultiPolygon)
A Polygon intersects a MultiPolygon if it intersects any of the MultiPolygon's constituent Polygons.


intersectsRasterShape

public boolean intersectsRasterShape(RasterShape inRasterShape)
A Polygon intersects a RasterShape if it intersects any of the envelope, or if it is contained within the envelope.


getCentroid

public Point getCentroid()
Find a point within the polygon .