Package org.locationtech.jts.dissolve
Class LineDissolver
java.lang.Object
org.locationtech.jts.dissolve.LineDissolver
Dissolves the linear components
from a collection of
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.
Geometry
s
into a set of maximal-length
invalid reference
Linestring
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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate GeometryFactory
private DissolveEdgeGraph
private List
private Stack
private Geometry
private DissolveHalfEdge
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(Collection geometries) Adds a collection of Geometries to be processed.void
Adds aGeometry
to be dissolved.private void
add
(LineString lineString) private void
addLine
(CoordinateList line) private void
Builds a line starting from the given edge.private void
For each edge in stack (which must originate at a node) extracts the line it initiates.private void
private void
static Geometry
Dissolves the linear components in a geometry.Gets the dissolved result as a MultiLineString.private void
private void
stackEdges
(HalfEdge node) Adds edges around this node to the stack.private void
Updates the tracked ringStartEdge if the given edge has a lower origin (using the standardCoordinate
ordering).
-
Field Details
-
result
-
factory
-
graph
-
lines
-
nodeEdgeStack
-
ringStartEdge
-
-
Constructor Details
-
LineDissolver
public LineDissolver()
-
-
Method Details
-
dissolve
Dissolves the linear components in a geometry.- Parameters:
g
- the geometry to dissolve- Returns:
- the dissolved lines
-
add
Adds aGeometry
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.- Parameters:
geometry
- geometry to be line-merged
-
add
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
-
getResult
Gets the dissolved result as a MultiLineString.- Returns:
- the dissolved lines
-
computeResult
private void computeResult() -
process
-
buildLines
private void buildLines()For each edge in stack (which must originate at a node) extracts the line it initiates. -
updateRingStartEdge
Updates the tracked ringStartEdge if the given edge has a lower origin (using the standardCoordinate
ordering). Identifying the lowest starting node meets two goals:- It ensures that isolated input rings are created using the original node and orientation
- For isolated rings formed from multiple input linestrings, it provides a canonical node and orientation for the output (rather than essentially random, and thus hard to test).
- Parameters:
e
-
-
buildLine
Builds a line starting from the given edge. The start edge origin is a node (valence = 1 or >= 3), unless it is part of a pure ring. A pure ring has no other incident lines. In this case the start edge may occur anywhere on the ring. The line is built up to the next node encountered, or until the start edge is re-encountered (which happens if the edges form a ring).- Parameters:
eStart
-
-
buildRing
-
addLine
-
stackEdges
Adds edges around this node to the stack.- Parameters:
node
-
-