GEOS 3.14.0dev
Public Member Functions | Static Public Member Functions | List of all members
geos::operation::linemerge::LineSequencer Class Reference

Builds a sequence from a set of LineStrings so that they are ordered end to end. More...

#include <LineSequencer.h>

Public Member Functions

bool isSequenceable ()
 Tests whether the arrangement of linestrings has a valid sequence.
 
void add (const geom::Geometry &geometry)
 Adds a Geometry to be sequenced.
 
template<class TargetContainer >
void add (TargetContainer &geoms)
 
void filter (const geom::Geometry *g)
 Act as a GeometryComponentFilter so to extract the linearworks.
 
geom::GeometrygetSequencedLineStrings (bool release=1)
 Returns the LineString or MultiLineString built by the sequencing process, if one exists.
 

Static Public Member Functions

static geom::Geometrysequence (const geom::Geometry &geom)
 
static bool isSequenced (const geom::Geometry *geom)
 Tests whether a Geometry is sequenced correctly.
 

Detailed Description

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:

Note
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.

Member Function Documentation

◆ add()

void geos::operation::linemerge::LineSequencer::add ( const geom::Geometry geometry)
inline

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
geometrythe geometry to add

References geos::geom::Geometry::applyComponentFilter().

◆ getSequencedLineStrings()

geom::Geometry * geos::operation::linemerge::LineSequencer::getSequencedLineStrings ( bool  release = 1)
inline

Returns the LineString or MultiLineString built by the sequencing process, if one exists.

Parameters
releaserelease ownership of computed Geometry
Returns
the sequenced linestrings, or null if a valid sequence does not exist.

◆ isSequenceable()

bool geos::operation::linemerge::LineSequencer::isSequenceable ( )
inline

Tests whether the arrangement of linestrings has a valid sequence.

Returns
true if a valid sequence exists.

◆ isSequenced()

static bool geos::operation::linemerge::LineSequencer::isSequenced ( const geom::Geometry geom)
static

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
geomthe geometry to test
Returns
true if the geometry is sequenced or is not lineal

The documentation for this class was generated from the following file: