public class LineSequencer
extends java.lang.Object
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:
Not all arrangements of lines can be sequenced.
For a connected set of edges in a graph,
Euler's Theorem states that there is a sequence containing each edge once
if and only if there are no more than 2 nodes of odd degree.
If it is not possible to find a sequence, the isSequenceable
method
will return false
.
Constructor and Description |
---|
LineSequencer() |
Modifier and Type | Method and Description |
---|---|
void |
add(java.util.Collection geometries)
Adds a
Collection of Geometry s to be sequenced. |
void |
add(Geometry geometry)
Adds a
Geometry to be sequenced. |
Geometry |
getSequencedLineStrings()
Returns the
LineString or MultiLineString
built by the sequencing process, if one exists. |
boolean |
isSequenceable()
Tests whether the arrangement of linestrings has a valid
sequence.
|
static boolean |
isSequenced(Geometry geom)
Tests whether a
Geometry is sequenced correctly. |
public static boolean isSequenced(Geometry geom)
Geometry
is sequenced correctly.
LineString
s are trivially sequenced.
MultiLineString
s are checked for correct sequencing.
Otherwise, isSequenced
is defined
to be true
for geometries that are not lineal.geom
- the geometry to testtrue
if the geometry is sequenced or is not linealpublic void add(java.util.Collection geometries)
Collection
of Geometry
s to be sequenced.
May be called multiple times.
Any dimension of Geometry may be added; the constituent linework will be
extracted.geometries
- a Collection of geometries to addpublic void add(Geometry geometry)
Geometry
to be sequenced.
May be called multiple times.
Any dimension of Geometry may be added; the constituent linework will be
extracted.geometry
- the geometry to addpublic boolean isSequenceable()
true
if a valid sequence exists.public Geometry getSequencedLineStrings()
LineString
or MultiLineString
built by the sequencing process, if one exists.null
if a valid sequence does not exist