com.moximedia.ows.geom
Class Polygon

java.lang.Object
  extended bycom.moximedia.ows.geom.Polygon
All Implemented Interfaces:
java.lang.Cloneable, Geometry, GeometryType, java.io.Serializable

public class Polygon
extends java.lang.Object
implements Geometry, GeometryType, java.lang.Cloneable, java.io.Serializable

Author:
jdc
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface com.moximedia.ows.types.GeometryType
GEOMETRY_TYPE_COLLECTION, GEOMETRY_TYPE_ENVELOPE, GEOMETRY_TYPE_LINE, GEOMETRY_TYPE_MULTILINE, GEOMETRY_TYPE_MULTIPOINT, GEOMETRY_TYPE_MULTIPOLYGON, GEOMETRY_TYPE_POINT, GEOMETRY_TYPE_POLYGON, GEOMETRY_TYPE_UNKNOWN
 
Constructor Summary
Polygon()
          Creates new Polygon
Polygon(Points exterior)
           
Polygon(Points exterior, Points[] holes)
           
 
Method Summary
 void addHole(Points pts)
           
 boolean addVertexToClosestLineSegment(Point pt)
          Adds a vertex to the closest line segment.
 Geometry buffer(double distance)
          Returns a new geometry that is a buffer of this one.
 java.lang.Object clone()
           
 boolean contains(Geometry geometry)
           
 Point getClosestPointTo(Point pt)
          Gets the closest vertex in the Polygon to the specified point.
 Polygon getCopy()
           
 double getDistanceToClosestLineSegment(Point pt)
          Gets the distance from the specified point to the closest line segment in the exterior or interior of the polygon.
 Envelope getExtent()
           
 Points getExterior()
           
 int getGeometryType()
          Returns the geometry type of this geometry.
 java.lang.String getGid()
           
 Points getHole(int index)
           
 int getHoleCount()
           
 java.util.ArrayList getHoles()
           
 Points getHoleWithPoint(Point pt)
           
 Points getPoints()
          Returns all the points of the polygon (interior and holes) as a Points object.
 boolean hasHoles()
           
 Geometry intersection(Polygon polygon)
          Returns a new geometry representing the intersection of this polygon and another one.
 boolean intersects(Geometry geometry)
           
 boolean isExteriorPoint(Point pt)
           
 boolean isGeometryType(int geometryType)
          Compares a geometry type with another value.
 boolean isInteriorPoint(Point pt)
           
 boolean isValid()
          Returns an indicator of whether this shape is valid.
 Geometry project(Projection projection)
           
 Geometry project(Projection fromProjection, Projection toProjection)
           
 boolean remove(Point pt)
           
 boolean removeHoleWithPoint(Point pt)
           
 void setExterior(Points pts)
           
 void setSrs(java.lang.String srs)
           
 void setXmlAttribute(java.lang.String element, java.lang.String name, java.lang.String value)
           
 java.awt.geom.GeneralPath toGeneralPath()
           
 java.lang.String toGmlString()
           
 com.vividsolutions.jts.geom.Geometry toJtsGeometry()
          Returns this object as a JTS Geometry object.
 com.vividsolutions.jts.geom.Geometry toJtsPolygon()
          Returns this object as a JTS Polygon object.
 boolean touches(Geometry geometry)
           
 java.lang.String toWktString()
          Returns the well known string representation of this object.
 Geometry unproject(Projection projection)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Polygon

public Polygon()
Creates new Polygon


Polygon

public Polygon(Points exterior)

Polygon

public Polygon(Points exterior,
               Points[] holes)
Method Detail

addHole

public void addHole(Points pts)

getDistanceToClosestLineSegment

public double getDistanceToClosestLineSegment(Point pt)
Gets the distance from the specified point to the closest line segment in the exterior or interior of the polygon.

Parameters:
pt - The point to search from.
Returns:
The distance.

addVertexToClosestLineSegment

public boolean addVertexToClosestLineSegment(Point pt)
Adds a vertex to the closest line segment.

Parameters:
pt - The point to add to the line segment. A vertex will be added to the portion of the line segment closest to the point position.

clone

public java.lang.Object clone()
Specified by:
clone in interface Geometry

getCopy

public Polygon getCopy()

getExtent

public Envelope getExtent()
Specified by:
getExtent in interface Geometry

getExterior

public Points getExterior()

getGeometryType

public int getGeometryType()
Returns the geometry type of this geometry.

Specified by:
getGeometryType in interface Geometry
Returns:
The geometry type of this geometry.

isGeometryType

public boolean isGeometryType(int geometryType)
Compares a geometry type with another value.

Specified by:
isGeometryType in interface Geometry
Parameters:
geometryType - An enumerated value.
Returns:
True if the type of this geometry is the same, otherwise false.

getGid

public java.lang.String getGid()

getHoleCount

public int getHoleCount()

getHole

public Points getHole(int index)

getHoles

public java.util.ArrayList getHoles()

hasHoles

public boolean hasHoles()

setExterior

public void setExterior(Points pts)

setXmlAttribute

public void setXmlAttribute(java.lang.String element,
                            java.lang.String name,
                            java.lang.String value)
Specified by:
setXmlAttribute in interface Geometry

toGeneralPath

public java.awt.geom.GeneralPath toGeneralPath()

toGmlString

public java.lang.String toGmlString()
Specified by:
toGmlString in interface Geometry

project

public Geometry project(Projection fromProjection,
                        Projection toProjection)
Specified by:
project in interface Geometry

project

public Geometry project(Projection projection)
Specified by:
project in interface Geometry

isValid

public boolean isValid()
Returns an indicator of whether this shape is valid.

Specified by:
isValid in interface Geometry
Returns:
True if this shape is valid, otherwise false.

toJtsGeometry

public com.vividsolutions.jts.geom.Geometry toJtsGeometry()
Returns this object as a JTS Geometry object.

Specified by:
toJtsGeometry in interface Geometry
Returns:
This object as a JTS Geometry object.

toJtsPolygon

public com.vividsolutions.jts.geom.Geometry toJtsPolygon()
Returns this object as a JTS Polygon object.

Returns:
This object as a JTS Polygon object.

unproject

public Geometry unproject(Projection projection)
Specified by:
unproject in interface Geometry

buffer

public Geometry buffer(double distance)
Returns a new geometry that is a buffer of this one.

Parameters:
distance - The buffer distance.
Returns:
A new geometry that is this polygon buffered by the specified distance.

intersection

public Geometry intersection(Polygon polygon)
Returns a new geometry representing the intersection of this polygon and another one.

Parameters:
polygon - Another polygon to intersect with this one.
Returns:
The intersection geometry.

intersects

public boolean intersects(Geometry geometry)
Specified by:
intersects in interface Geometry

touches

public boolean touches(Geometry geometry)

getClosestPointTo

public Point getClosestPointTo(Point pt)
Gets the closest vertex in the Polygon to the specified point. This routine uses the exterior and hole vertexes for comparison.

Specified by:
getClosestPointTo in interface Geometry
Parameters:
pt - The point to compare the vertexes to.
Returns:
The closest vertex to the specified point, or null if there are no points in the polygon.

setSrs

public void setSrs(java.lang.String srs)
Specified by:
setSrs in interface Geometry

remove

public boolean remove(Point pt)

getPoints

public Points getPoints()
Returns all the points of the polygon (interior and holes) as a Points object. Note: this is a copy not a reference.

Returns:
The points.

contains

public boolean contains(Geometry geometry)

isExteriorPoint

public boolean isExteriorPoint(Point pt)

isInteriorPoint

public boolean isInteriorPoint(Point pt)

getHoleWithPoint

public Points getHoleWithPoint(Point pt)

removeHoleWithPoint

public boolean removeHoleWithPoint(Point pt)

toWktString

public java.lang.String toWktString()
Returns the well known string representation of this object.

Specified by:
toWktString in interface Geometry
Returns:
The well known text.


Internet Mapping Framework for OpenGIS Java Object Model API (v1.3.007)
Copyright © 2005 Moxi Media Inc. and Province of British Columbia. All Rights Reserved.