Class PolygonBuilder
java.lang.Object
org.locationtech.jts.operation.overlay.PolygonBuilder
Forms
Polygon
s out of a graph of DirectedEdge
s.
The edges to use are marked as being in the result Area.
- Version:
- 1.7
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(Collection dirEdges, Collection nodes) Add a set of edges and nodes, which form a graph.void
add
(PlanarGraph graph) Add a complete graph.private List
buildMaximalEdgeRings
(Collection dirEdges) for all DirectedEdges in result, form them into MaximalEdgeRingsprivate List
buildMinimalEdgeRings
(List maxEdgeRings, List shellList, List freeHoleList) private List
computePolygons
(List shellList) boolean
Checks the current set of shells (with their associated holes) to see if any of them contain the point.private EdgeRing
findEdgeRingContaining
(EdgeRing testEr, List shellList) Find the innermost enclosing shell EdgeRing containing the argument EdgeRing, if any.private EdgeRing
This method takes a list of MinimalEdgeRings derived from a MaximalEdgeRing, and tests whether they form a Polygon.private void
placeFreeHoles
(List shellList, List freeHoleList) This method determines finds a containing shell for all holes which have not yet been assigned to a shell.private void
placePolygonHoles
(EdgeRing shell, List minEdgeRings) This method assigns the holes for a Polygon (formed from a list of MinimalEdgeRings) to its shell.private void
sortShellsAndHoles
(List edgeRings, List shellList, List freeHoleList) For all rings in the input list, determine whether the ring is a shell or a hole and add it to the appropriate list.
-
Field Details
-
geometryFactory
-
shellList
-
-
Constructor Details
-
PolygonBuilder
-
-
Method Details
-
add
Add a complete graph. The graph is assumed to contain one or more polygons, possibly with holes. -
add
Add a set of edges and nodes, which form a graph. The graph is assumed to contain one or more polygons, possibly with holes. -
getPolygons
-
buildMaximalEdgeRings
for all DirectedEdges in result, form them into MaximalEdgeRings -
buildMinimalEdgeRings
-
findShell
This method takes a list of MinimalEdgeRings derived from a MaximalEdgeRing, and tests whether they form a Polygon. This is the case if there is a single shell in the list. In this case the shell is returned. The other possibility is that they are a series of connected holes, in which case no shell is returned.- Returns:
- the shell EdgeRing, if there is one or null, if all the rings are holes
-
placePolygonHoles
This method assigns the holes for a Polygon (formed from a list of MinimalEdgeRings) to its shell. Determining the holes for a MinimalEdgeRing polygon serves two purposes:- it is faster than using a point-in-polygon check later on.
- it ensures correctness, since if the PIP test was used the point chosen might lie on the shell, which might return an incorrect result from the PIP test
-
sortShellsAndHoles
For all rings in the input list, determine whether the ring is a shell or a hole and add it to the appropriate list. Due to the way the DirectedEdges were linked, a ring is a shell if it is oriented CW, a hole otherwise. -
placeFreeHoles
This method determines finds a containing shell for all holes which have not yet been assigned to a shell. These "free" holes should all be properly contained in their parent shells, so it is safe to use thefindEdgeRingContaining
method. (This is the case because any holes which are NOT properly contained (i.e. are connected to their parent shell) would have formed part of a MaximalEdgeRing and been handled in a previous step).- Throws:
TopologyException
- if a hole cannot be assigned to a shell
-
findEdgeRingContaining
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
-
computePolygons
-
containsPoint
Checks the current set of shells (with their associated holes) to see if any of them contain the point.
-