Class LineSequencer
java.lang.Object
org.locationtech.jts.operation.linemerge.LineSequencer
Builds a sequence from a set of LineStrings so that
they are ordered end to end.
A sequence is a complete non-repeating list of the linear
components of the input. Each linestring is oriented
so that identical endpoints are adjacent in the list.
A typical use case is to convert a set of unoriented geometric links from a linear network (e.g. such as block faces on a bus route) into a continuous oriented path through the network.
The input linestrings may form one or more connected sets.
The input linestrings should be correctly noded, or the results may
not be what is expected.
The computed output is a single MultiLineString containing the ordered
linestrings in the sequence.
The sequencing employs the classic Eulerian path graph algorithm. Since Eulerian paths are not uniquely determined, further rules are used to make the computed sequence preserve as much as possible of the input ordering. Within a connected subset of lines, the ordering rules are:
- If there is degree-1 node which is the start node of an linestring, use that node as the start of the sequence
- If there is a degree-1 node which is the end node of an linestring, use that node as the end of the sequence
- If the sequence has no degree-1 nodes, use any node as the start
isSequenceable() method
will return false.- Version:
- 1.7
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(Collection geometries) Adds aCollectionofGeometrys to be sequenced.voidAdds aGeometryto be sequenced.Returns theLineStringorMultiLineStringbuilt by the sequencing process, if one exists.booleanTests whether the arrangement of linestrings has a valid sequence.static booleanisSequenced(Geometry geom) Tests whether aGeometryis sequenced correctly.static Geometry
-
Constructor Details
-
LineSequencer
public LineSequencer()
-
-
Method Details
-
sequence
-
isSequenced
Tests whether aGeometryis sequenced correctly.LineStrings are trivially sequenced.MultiLineStrings are checked for correct sequencing. Otherwise,isSequencedis defined to betruefor geometries that are not lineal.- Parameters:
geom- the geometry to test- Returns:
trueif the geometry is sequenced or is not lineal
-
add
Adds aCollectionofGeometrys to be sequenced. May be called multiple times. Any dimension of Geometry may be added; the constituent linework will be extracted.- Parameters:
geometries- a Collection of geometries to add
-
add
-
isSequenceable
public boolean isSequenceable()Tests whether the arrangement of linestrings has a valid sequence.- Returns:
trueif a valid sequence exists.
-
getSequencedLineStrings
Returns theLineStringorMultiLineStringbuilt by the sequencing process, if one exists.- Returns:
- the sequenced linestrings,
or
nullif a valid sequence does not exist
-