Class Polygonizer
- java.lang.Object
-
- org.locationtech.jts.operation.polygonize.Polygonizer
-
public class Polygonizer extends Object
Polygonizes a set ofGeometrys which contain linework that represents the edges of a planar graph. All types of Geometry are accepted as input; the constituent linework is extracted as the edges to be polygonized. The processed edges must be correctly noded; that is, they must only meet at their endpoints. Polygonization will accept incorrectly noded input but will not form polygons from non-noded edges, and reports them as errors.The Polygonizer reports the follow kinds of errors:
Dangles- edges which have one or both ends which are not incident on another edge endpointCut Edges- edges which are connected at both ends but which do not form part of polygonInvalid Ring Lines- edges which form rings which are invalid (e.g. the component lines contain a self-intersection)
Polygonizer(boolean)constructor allows extracting only polygons which form a valid polygonal result. The set of extracted polygons is guaranteed to be edge-disjoint. This is useful where it is known that the input lines form a valid polygonal geometry (which may include holes or nested polygons).- Version:
- 1.7
-
-
Field Summary
Fields Modifier and Type Field Description protected List<LineString>cutEdgesprotected Collection<LineString>danglesprotected org.locationtech.jts.operation.polygonize.PolygonizeGraphgraphprotected List<org.locationtech.jts.operation.polygonize.EdgeRing>holeListprotected List<LineString>invalidRingLinesprotected List<Polygon>polyListprotected List<org.locationtech.jts.operation.polygonize.EdgeRing>shellList
-
Constructor Summary
Constructors Constructor Description Polygonizer()Creates a polygonizer that extracts all polygons.Polygonizer(boolean extractOnlyPolygonal)Creates a polygonizer, specifying whether a valid polygonal geometry must be created.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(Collection geomList)Adds a collection of geometries to the edges to be polygonized.voidadd(Geometry g)Add aGeometryto the edges to be polygonized.CollectiongetCutEdges()Gets the list of cut edges found during polygonization.CollectiongetDangles()Gets the list of dangling lines found during polygonization.GeometrygetGeometry()Gets a geometry representing the polygons formed by the polygonization.CollectiongetInvalidRingLines()Gets the list of lines forming invalid rings found during polygonization.CollectiongetPolygons()Gets the list of polygons formed by the polygonization.voidsetCheckRingsValid(boolean isCheckingRingsValid)Allows disabling the valid ring checking, to optimize situations where invalid rings are not expected.
-
-
-
Field Detail
-
graph
protected org.locationtech.jts.operation.polygonize.PolygonizeGraph graph
-
dangles
protected Collection<LineString> dangles
-
cutEdges
protected List<LineString> cutEdges
-
invalidRingLines
protected List<LineString> invalidRingLines
-
holeList
protected List<org.locationtech.jts.operation.polygonize.EdgeRing> holeList
-
shellList
protected List<org.locationtech.jts.operation.polygonize.EdgeRing> shellList
-
-
Constructor Detail
-
Polygonizer
public Polygonizer()
Creates a polygonizer that extracts all polygons.
-
Polygonizer
public Polygonizer(boolean extractOnlyPolygonal)
Creates a polygonizer, specifying whether a valid polygonal geometry must be created. If the argument istruethen areas may be discarded in order to ensure that the extracted geometry is a valid polygonal geometry.- Parameters:
extractOnlyPolygonal- true if a valid polygonal geometry should be extracted
-
-
Method Detail
-
add
public void add(Collection geomList)
Adds a collection of geometries to the edges to be polygonized. May be called multiple times. Any dimension of Geometry may be added; the constituent linework will be extracted and used.- Parameters:
geomList- a list ofGeometrys with linework to be polygonized
-
add
public void add(Geometry g)
Add aGeometryto the edges to be polygonized. May be called multiple times. Any dimension of Geometry may be added; the constituent linework will be extracted and used- Parameters:
g- aGeometrywith linework to be polygonized
-
setCheckRingsValid
public void setCheckRingsValid(boolean isCheckingRingsValid)
Allows disabling the valid ring checking, to optimize situations where invalid rings are not expected.The default is
true.- Parameters:
isCheckingRingsValid- true if generated rings should be checked for validity
-
getPolygons
public Collection getPolygons()
Gets the list of polygons formed by the polygonization.- Returns:
- a collection of
Polygons
-
getGeometry
public Geometry getGeometry()
Gets a geometry representing the polygons formed by the polygonization. If a valid polygonal geometry was extracted the result is aPolygonalgeometry.- Returns:
- a geometry containing the polygons
-
getDangles
public Collection getDangles()
Gets the list of dangling lines found during polygonization.- Returns:
- a collection of the input
LineStrings which are dangles
-
getCutEdges
public Collection getCutEdges()
Gets the list of cut edges found during polygonization.- Returns:
- a collection of the input
LineStrings which are cut edges
-
getInvalidRingLines
public Collection getInvalidRingLines()
Gets the list of lines forming invalid rings found during polygonization.- Returns:
- a collection of the input
LineStrings which form invalid rings
-
-