Class LineMerger
- java.lang.Object
-
- org.locationtech.jts.operation.linemerge.LineMerger
-
public class LineMerger extends java.lang.ObjectMerges a collection of linear components to form maximal-length linestrings.Merging stops at nodes of degree 1 or degree 3 or more. In other words, all nodes of degree 2 are merged together. The exception is in the case of an isolated loop, which only has degree-2 nodes. In this case one of the nodes is chosen as a starting point.
The direction of each merged LineString will be that of the majority of the LineStrings from which it was derived.
Any dimension of Geometry is handled - the constituent linework is extracted to form the edges. The edges must be correctly noded; that is, they must only meet at their endpoints. The LineMerger will accept non-noded input but will not merge non-noded edges.
Input lines which are empty or contain only a single unique coordinate are not included in the merging.
- Version:
- 1.7
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.CollectionedgeStringsprivate GeometryFactoryfactoryprivate LineMergeGraphgraphprivate java.util.CollectionmergedLineStrings
-
Constructor Summary
Constructors Constructor Description LineMerger()Creates a new line merger.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(java.util.Collection geometries)Adds a collection of Geometries to be processed.voidadd(Geometry geometry)Adds a Geometry to be processed.private voidadd(LineString lineString)private voidbuildEdgeStringsForIsolatedLoops()private voidbuildEdgeStringsForNonDegree2Nodes()private voidbuildEdgeStringsForObviousStartNodes()private voidbuildEdgeStringsForUnprocessedNodes()private voidbuildEdgeStringsStartingAt(Node node)private EdgeStringbuildEdgeStringStartingWith(LineMergeDirectedEdge start)java.util.CollectiongetMergedLineStrings()Gets theLineStrings created by the merging process.private voidmerge()
-
-
-
Field Detail
-
graph
private LineMergeGraph graph
-
mergedLineStrings
private java.util.Collection mergedLineStrings
-
factory
private GeometryFactory factory
-
edgeStrings
private java.util.Collection edgeStrings
-
-
Method Detail
-
add
public void add(Geometry geometry)
Adds a Geometry to be processed. May be called multiple times. Any dimension of Geometry may be added; the constituent linework will be extracted.- Parameters:
geometry- geometry to be line-merged
-
add
public void add(java.util.Collection geometries)
Adds a collection of Geometries to be processed. May be called multiple times. Any dimension of Geometry may be added; the constituent linework will be extracted.- Parameters:
geometries- the geometries to be line-merged
-
add
private void add(LineString lineString)
-
merge
private void merge()
-
buildEdgeStringsForObviousStartNodes
private void buildEdgeStringsForObviousStartNodes()
-
buildEdgeStringsForIsolatedLoops
private void buildEdgeStringsForIsolatedLoops()
-
buildEdgeStringsForUnprocessedNodes
private void buildEdgeStringsForUnprocessedNodes()
-
buildEdgeStringsForNonDegree2Nodes
private void buildEdgeStringsForNonDegree2Nodes()
-
buildEdgeStringsStartingAt
private void buildEdgeStringsStartingAt(Node node)
-
buildEdgeStringStartingWith
private EdgeString buildEdgeStringStartingWith(LineMergeDirectedEdge start)
-
getMergedLineStrings
public java.util.Collection getMergedLineStrings()
Gets theLineStrings created by the merging process.- Returns:
- the collection of merged LineStrings
-
-