com.vividsolutions.jts.operation.linemerge
Class LineSequencer

java.lang.Object
  extended by com.vividsolutions.jts.operation.linemerge.LineSequencer

public class LineSequencer
extends java.lang.Object

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. 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 output of this method 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:

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.

Version:
1.7

Constructor Summary
LineSequencer()
           
 
Method Summary
 void add(java.util.Collection geometries)
          Adds a Collection of Geometrys 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LineSequencer

public LineSequencer()
Method Detail

isSequenced

public static boolean isSequenced(Geometry geom)
Tests whether a 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.

Parameters:
geom - the geometry to test
Returns:
true if the geometry is sequenced or is not lineal

add

public void add(java.util.Collection geometries)
Adds a Collection of Geometrys 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

public void add(Geometry geometry)
Adds a Geometry to be sequenced. May be called multiple times. Any dimension of Geometry may be added; the constituent linework will be extracted.

Parameters:
geometry - the geometry to add

isSequenceable

public boolean isSequenceable()
Tests whether the arrangement of linestrings has a valid sequence.

Returns:
true if a valid sequence exists.

getSequencedLineStrings

public Geometry getSequencedLineStrings()
Returns the LineString or MultiLineString built by the sequencing process, if one exists.

Returns:
the sequenced linestrings, or null if a valid sequence does not exist