public class LineMerger
extends java.lang.Object
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.
Modifier and Type | Field and Description |
---|---|
private java.util.Collection |
edgeStrings |
private GeometryFactory |
factory |
private LineMergeGraph |
graph |
private java.util.Collection |
mergedLineStrings |
Constructor and Description |
---|
LineMerger()
Creates a new line merger.
|
Modifier and Type | Method and Description |
---|---|
void |
add(java.util.Collection geometries)
Adds a collection of Geometries to be processed.
|
void |
add(Geometry geometry)
Adds a Geometry to be processed.
|
private void |
add(LineString lineString) |
private void |
buildEdgeStringsForIsolatedLoops() |
private void |
buildEdgeStringsForNonDegree2Nodes() |
private void |
buildEdgeStringsForObviousStartNodes() |
private void |
buildEdgeStringsForUnprocessedNodes() |
private void |
buildEdgeStringsStartingAt(Node node) |
private EdgeString |
buildEdgeStringStartingWith(LineMergeDirectedEdge start) |
java.util.Collection |
getMergedLineStrings()
Gets the
LineString s created by the merging process. |
private void |
merge() |
private LineMergeGraph graph
private java.util.Collection mergedLineStrings
private GeometryFactory factory
private java.util.Collection edgeStrings
public void add(Geometry geometry)
geometry
- geometry to be line-mergedpublic void add(java.util.Collection geometries)
geometries
- the geometries to be line-mergedprivate void add(LineString lineString)
private void merge()
private void buildEdgeStringsForObviousStartNodes()
private void buildEdgeStringsForIsolatedLoops()
private void buildEdgeStringsForUnprocessedNodes()
private void buildEdgeStringsForNonDegree2Nodes()
private void buildEdgeStringsStartingAt(Node node)
private EdgeString buildEdgeStringStartingWith(LineMergeDirectedEdge start)
public java.util.Collection getMergedLineStrings()
LineString
s created by the merging process.