public class LineSequencer extends Object
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:
isSequenceable() method will return
false.
| Constructor and Description |
|---|
LineSequencer()
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(Collection
Adds a
Collection of
Geometrys to be sequenced.
|
void |
add(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
Tests whether a
Geometry is sequenced correctly.
|
static Geometry |
sequence(Geometry
|
public static boolean isSequenced(Geometrygeom)
Geometry is sequenced correctly.
LineStrings are trivially sequenced.
MultiLineStrings are checked for correct sequencing. Otherwise,
isSequenced is defined to be
true for geometries that are not lineal.
geom - the geometry to test
true if the geometry is sequenced or is not lineal
public void add(Collectiongeometries)
Collection of
Geometrys 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 add
public void add(Geometrygeometry)
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 add
public boolean isSequenceable()
true if a valid sequence exists.
public GeometrygetSequencedLineStrings()
LineString or
MultiLineString built by the sequencing process, if one exists.
null if a valid sequence does not exist