public class LineDissolver
extends java.lang.Object
Geometry
s
into a set of maximal-length Linestring
s
in which every unique segment appears once only.
The output linestrings run between node vertices
of the input, which are vertices which have
either degree 1, or degree 3 or greater.
Use cases for dissolving linear components include generalization (in particular, simplifying polygonal coverages), and visualization (in particular, avoiding symbology conflicts when depicting shared polygon boundaries).
This class does not node the input lines. If there are line segments crossing in the input, they will still cross in the output.
Modifier and Type | Field and Description |
---|---|
private GeometryFactory |
factory |
private DissolveEdgeGraph |
graph |
private java.util.List |
lines |
private java.util.Stack |
nodeEdgeStack |
private Geometry |
result |
private DissolveHalfEdge |
ringStartEdge |
Constructor and Description |
---|
LineDissolver() |
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 dissolved. |
private void |
add(LineString lineString) |
private void |
addLine(CoordinateList line) |
private void |
buildLine(HalfEdge eStart)
Builds a line starting from the given edge.
|
private void |
buildLines()
For each edge in stack
(which must originate at a node)
extracts the line it initiates.
|
private void |
buildRing(HalfEdge eStartRing) |
private void |
computeResult() |
static Geometry |
dissolve(Geometry g)
Dissolves the linear components in a geometry.
|
Geometry |
getResult()
Gets the dissolved result as a MultiLineString.
|
private void |
process(HalfEdge e) |
private void |
stackEdges(HalfEdge node)
Adds edges around this node to the stack.
|
private void |
updateRingStartEdge(DissolveHalfEdge e)
Updates the tracked ringStartEdge
if the given edge has a lower origin
(using the standard
Coordinate ordering). |
private Geometry result
private GeometryFactory factory
private DissolveEdgeGraph graph
private java.util.List lines
private java.util.Stack nodeEdgeStack
private DissolveHalfEdge ringStartEdge
public static Geometry dissolve(Geometry g)
g
- the geometry to dissolvepublic void add(Geometry geometry)
Geometry
to be dissolved.
Any number of geometries may be added by calling this method multiple times.
Any type of Geometry may be added. The constituent linework will be
extracted to be dissolved.geometry
- geometry to be line-mergedpublic void add(java.util.Collection geometries)
geometries
- the geometries to be line-mergedprivate void add(LineString lineString)
public Geometry getResult()
private void computeResult()
private void process(HalfEdge e)
private void buildLines()
private void updateRingStartEdge(DissolveHalfEdge e)
Coordinate
ordering).
Identifying the lowest starting node meets two goals:
e
- private void buildLine(HalfEdge eStart)
eStart
- private void buildRing(HalfEdge eStartRing)
private void addLine(CoordinateList line)
private void stackEdges(HalfEdge node)
node
-