com.vividsolutions.jts.operation.polygonize

Class EdgeRing


public class EdgeRing
extends java.lang.Object

Represents a ring of PolygonizeDirectedEdges which form a ring of a polygon. The ring may be either an outer shell or a hole.
Version:
1.6

Constructor Summary

EdgeRing(GeometryFactory factory)

Method Summary

void
add(DirectedEdge de)
Adds a DirectedEdge which is known to form part of this ring.
void
addHole(LinearRing hole)
Adds a hole to the polygon formed by this ring.
static EdgeRing
findEdgeRingContaining(EdgeRing testEr, List shellList)
Find the innermost enclosing shell EdgeRing containing the argument EdgeRing, if any.
LineString
getLineString()
Gets the coordinates for this ring as a LineString.
Polygon
getPolygon()
Computes the
LinearRing
getRing()
Returns this ring as a LinearRing, or null if an Exception occurs while creating it (such as a topology problem).
boolean
isHole()
Tests whether this ring is a hole.
static boolean
isInList(Coordinate pt, Coordinate[] pts)
Tests whether a given point is in an array of points.
boolean
isValid()
Tests if the LinearRing ring formed by this edge ring is topologically valid.
static Coordinate
ptNotInList(Coordinate[] testPts, Coordinate[] pts)
Finds a point in a list of points which is not contained in another list of points

Constructor Details

EdgeRing

public EdgeRing(GeometryFactory factory)

Method Details

add

public void add(DirectedEdge de)
Adds a DirectedEdge which is known to form part of this ring.
Parameters:
de - the DirectedEdge to add.

addHole

public void addHole(LinearRing hole)
Adds a hole to the polygon formed by this ring.
Parameters:
hole - the LinearRing forming the hole.

findEdgeRingContaining

public static EdgeRing findEdgeRingContaining(EdgeRing testEr,
                                              List shellList)
Find the innermost enclosing shell EdgeRing containing the argument EdgeRing, if any. The innermost enclosing ring is the smallest enclosing ring. The algorithm used depends on the fact that:
ring A contains ring B iff envelope(ring A) contains envelope(ring B)
This routine is only safe to use if the chosen point of the hole is known to be properly contained in a shell (which is guaranteed to be the case if the hole does not touch its shell)
Returns:
containing EdgeRing, if there is one

getLineString

public LineString getLineString()
Gets the coordinates for this ring as a LineString. Used to return the coordinates in this ring as a valid geometry, when it has been detected that the ring is topologically invalid.
Returns:
a LineString containing the coordinates in this ring

getPolygon

public Polygon getPolygon()
Computes the formed by this ring and any contained holes. @return the {@link Polygon formed by this ring and its holes.

getRing

public LinearRing getRing()
Returns this ring as a LinearRing, or null if an Exception occurs while creating it (such as a topology problem). Details of problems are written to standard output.

isHole

public boolean isHole()
Tests whether this ring is a hole. Due to the way the edges in the polyongization graph are linked, a ring is a hole if it is oriented counter-clockwise.
Returns:
true if this ring is a hole

isInList

public static boolean isInList(Coordinate pt,
                               Coordinate[] pts)
Tests whether a given point is in an array of points. Uses a value-based test.
Parameters:
pt - a Coordinate for the test point
pts - an array of Coordinates to test
Returns:
true if the point is in the array

isValid

public boolean isValid()
Tests if the LinearRing ring formed by this edge ring is topologically valid.
Returns:

ptNotInList

public static Coordinate ptNotInList(Coordinate[] testPts,
                                     Coordinate[] pts)
Finds a point in a list of points which is not contained in another list of points
Parameters:
testPts - the Coordinates to test
pts - an array of Coordinates to test the input points against
Returns:
a Coordinate from testPts which is not in pts, ' or null