Class EdgeRing
- java.lang.Object
-
- org.locationtech.jts.operation.polygonize.EdgeRing
-
class EdgeRing extends java.lang.Object
Represents a ring ofPolygonizeDirectedEdge
s which form a ring of a polygon. The ring may be either an outer shell or a hole.- Version:
- 1.7
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
EdgeRing.EnvelopeComparator
Compares EdgeRings based on their envelope, using the standard lexicographic ordering.
-
Field Summary
Fields Modifier and Type Field Description private java.util.List
deList
private GeometryFactory
factory
private java.util.List
holes
private boolean
isHole
private boolean
isIncluded
private boolean
isIncludedSet
private boolean
isProcessed
private DirectedEdge
lowestEdge
private LinearRing
ring
private Coordinate[]
ringPts
private EdgeRing
shell
-
Constructor Summary
Constructors Constructor Description EdgeRing(GeometryFactory factory)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description private void
add(DirectedEdge de)
Adds aDirectedEdge
which is known to form part of this ring.private static void
addEdge(Coordinate[] coords, boolean isForward, CoordinateList coordList)
void
addHole(LinearRing hole)
Adds a hole to the polygon formed by this ring.void
addHole(EdgeRing holeER)
Adds a hole to the polygon formed by this ring.void
build(PolygonizeDirectedEdge startDE)
void
computeHole()
Computes whether this ring is a hole.static java.util.List
findDirEdgesInRing(PolygonizeDirectedEdge startDE)
Traverses a ring of DirectedEdges, accumulating them into a list.static EdgeRing
findEdgeRingContaining(EdgeRing testEr, java.util.List shellList)
Find the innermost enclosing shell EdgeRing containing the argument EdgeRing, if any.private Coordinate[]
getCoordinates()
Computes the list of coordinates which are contained in this ring.LineString
getLineString()
Gets the coordinates for this ring as aLineString
.EdgeRing
getOuterHole()
Polygon
getPolygon()
Computes thePolygon
formed by this ring and any contained holes.LinearRing
getRing()
Returns this ring as aLinearRing
, or null if an Exception occurs while creating it (such as a topology problem).EdgeRing
getShell()
Gets the shell for this ring.boolean
hasShell()
Tests whether this ring has a shell assigned to it.boolean
isHole()
Tests whether this ring is a hole.boolean
isIncluded()
boolean
isIncludedSet()
static boolean
isInList(Coordinate pt, Coordinate[] pts)
Deprecated.boolean
isOuterHole()
Tests whether this ring is an outer hole.boolean
isOuterShell()
Tests whether this ring is an outer shell.boolean
isProcessed()
boolean
isValid()
Tests if theLinearRing
ring formed by this edge ring is topologically valid.static Coordinate
ptNotInList(Coordinate[] testPts, Coordinate[] pts)
Deprecated.Use CoordinateArrays.ptNotInList insteadvoid
setIncluded(boolean isIncluded)
void
setProcessed(boolean isProcessed)
void
setShell(EdgeRing shell)
Sets the containing shell ring of a ring that has been determined to be a hole.java.lang.String
toString()
Gets a string representation of this object.void
updateIncluded()
Updates the included status for currently non-included shells based on whether they are adjacent to an included shell.
-
-
-
Field Detail
-
factory
private GeometryFactory factory
-
deList
private java.util.List deList
-
lowestEdge
private DirectedEdge lowestEdge
-
ring
private LinearRing ring
-
ringPts
private Coordinate[] ringPts
-
holes
private java.util.List holes
-
shell
private EdgeRing shell
-
isHole
private boolean isHole
-
isProcessed
private boolean isProcessed
-
isIncludedSet
private boolean isIncludedSet
-
isIncluded
private boolean isIncluded
-
-
Constructor Detail
-
EdgeRing
public EdgeRing(GeometryFactory factory)
-
-
Method Detail
-
findEdgeRingContaining
public static EdgeRing findEdgeRingContaining(EdgeRing testEr, java.util.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 or null if no containing EdgeRing is found
-
ptNotInList
public static Coordinate ptNotInList(Coordinate[] testPts, Coordinate[] pts)
Deprecated.Use CoordinateArrays.ptNotInList insteadFinds a point in a list of points which is not contained in another list of points- Parameters:
testPts
- theCoordinate
s to testpts
- an array ofCoordinate
s to test the input points against- Returns:
- a
Coordinate
fromtestPts
which is not inpts
, or null if there is no coordinate not in the list
-
isInList
public static boolean isInList(Coordinate pt, Coordinate[] pts)
Deprecated.Tests whether a given point is in an array of points. Uses a value-based test.- Parameters:
pt
- aCoordinate
for the test pointpts
- an array ofCoordinate
s to test- Returns:
true
if the point is in the array
-
findDirEdgesInRing
public static java.util.List findDirEdgesInRing(PolygonizeDirectedEdge startDE)
Traverses a ring of DirectedEdges, accumulating them into a list. This assumes that all dangling directed edges have been removed from the graph, so that there is always a next dirEdge.- Parameters:
startDE
- the DirectedEdge to start traversing at- Returns:
- a List of DirectedEdges that form a ring
-
build
public void build(PolygonizeDirectedEdge startDE)
-
add
private void add(DirectedEdge de)
Adds aDirectedEdge
which is known to form part of this ring.- Parameters:
de
- theDirectedEdge
to add.
-
isHole
public boolean isHole()
Tests whether this ring is a hole.- Returns:
true
if this ring is a hole
-
computeHole
public void computeHole()
Computes whether this ring is a hole. Due to the way the edges in the polygonization graph are linked, a ring is a hole if it is oriented counter-clockwise.
-
addHole
public void addHole(LinearRing hole)
Adds a hole to the polygon formed by this ring.- Parameters:
hole
- theLinearRing
forming the hole.
-
addHole
public void addHole(EdgeRing holeER)
Adds a hole to the polygon formed by this ring.- Parameters:
hole
- theLinearRing
forming the hole.
-
getPolygon
public Polygon getPolygon()
Computes thePolygon
formed by this ring and any contained holes.- Returns:
- the
Polygon
formed by this ring and its holes.
-
isValid
public boolean isValid()
Tests if theLinearRing
ring formed by this edge ring is topologically valid.- Returns:
- true if the ring is valid
-
isIncludedSet
public boolean isIncludedSet()
-
isIncluded
public boolean isIncluded()
-
setIncluded
public void setIncluded(boolean isIncluded)
-
getCoordinates
private Coordinate[] getCoordinates()
Computes the list of coordinates which are contained in this ring. The coordinates are computed once only and cached.- Returns:
- an array of the
Coordinate
s in this ring
-
getLineString
public LineString getLineString()
Gets the coordinates for this ring as aLineString
. 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
-
getRing
public LinearRing getRing()
Returns this ring as aLinearRing
, or null if an Exception occurs while creating it (such as a topology problem). Details of problems are written to standard output.
-
addEdge
private static void addEdge(Coordinate[] coords, boolean isForward, CoordinateList coordList)
-
setShell
public void setShell(EdgeRing shell)
Sets the containing shell ring of a ring that has been determined to be a hole.- Parameters:
shell
- the shell ring
-
hasShell
public boolean hasShell()
Tests whether this ring has a shell assigned to it.- Returns:
- true if the ring has a shell
-
getShell
public EdgeRing getShell()
Gets the shell for this ring. The shell is the ring itself if it is not a hole, otherwise its parent shell.- Returns:
- the shell for this ring
-
isOuterHole
public boolean isOuterHole()
Tests whether this ring is an outer hole. A hole is an outer hole if it is not contained by a shell.- Returns:
- true if the ring is an outer hole.
-
isOuterShell
public boolean isOuterShell()
Tests whether this ring is an outer shell.- Returns:
- true if the ring is an outer shell.
-
getOuterHole
public EdgeRing getOuterHole()
-
updateIncluded
public void updateIncluded()
Updates the included status for currently non-included shells based on whether they are adjacent to an included shell.
-
toString
public java.lang.String toString()
Gets a string representation of this object.- Overrides:
toString
in classjava.lang.Object
- Returns:
- a string representing the object
-
isProcessed
public boolean isProcessed()
- Returns:
- whether the ring has been processed
-
setProcessed
public void setProcessed(boolean isProcessed)
- Parameters:
isProcessed
- whether the ring has been processed
-
-