GEOS
3.9.1dev
|
Builds a sequence from a set of LineStrings so that they are ordered end to end. More...
#include <LineSequencer.h>
Public Member Functions | |
LineSequencer () | |
bool | isSequenceable () |
Tests whether the arrangement of linestrings has a valid sequence. More... | |
void | add (const geom::Geometry &geometry) |
Adds a Geometry to be sequenced. More... | |
template<class TargetContainer > | |
void | add (TargetContainer &geoms) |
void | filter (const geom::Geometry *g) |
Act as a GeometryComponentFilter so to extract the linearworks. More... | |
geom::Geometry * | getSequencedLineStrings (bool release=1) |
Returns the LineString or MultiLineString built by the sequencing process, if one exists. More... | |
Static Public Member Functions | |
static geom::Geometry * | sequence (const geom::Geometry &geom) |
static bool | isSequenced (const geom::Geometry *geom) |
Tests whether a Geometry is sequenced correctly. More... | |
Private Types | |
typedef std::list< planargraph::DirectedEdge * > | DirEdgeList |
typedef std::vector< DirEdgeList * > | Sequences |
Private Member Functions | |
void | addLine (const geom::LineString *lineString) |
void | computeSequence () |
Sequences * | findSequences () |
DirEdgeList * | findSequence (planargraph::Subgraph &graph) |
void | delAll (Sequences &) |
geom::Geometry * | buildSequencedGeometry (const Sequences &sequences) |
void | addReverseSubpath (const planargraph::DirectedEdge *de, DirEdgeList &deList, DirEdgeList::iterator lit, bool expectedClosed) |
DirEdgeList * | orient (DirEdgeList *seq) |
DirEdgeList * | reverse (DirEdgeList &seq) |
bool | hasSequence (planargraph::Subgraph &graph) |
Static Private Member Functions | |
static geom::LineString * | reverse (const geom::LineString *line) |
return a newly allocated LineString More... | |
static const planargraph::Node * | findLowestDegreeNode (const planargraph::Subgraph &graph) |
static const planargraph::DirectedEdge * | findUnvisitedBestOrientedDE (const planargraph::Node *node) |
Private Attributes | |
LineMergeGraph | graph |
const geom::GeometryFactory * | factory |
unsigned int | lineCount |
bool | isRun |
std::unique_ptr< geom::Geometry > | sequencedGeometry |
bool | isSequenceableVar |
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:
isSequenceable
method will return false
. Definition at line 93 of file LineSequencer.h.
|
private |
Definition at line 96 of file LineSequencer.h.
|
private |
Definition at line 97 of file LineSequencer.h.
|
inline |
Definition at line 198 of file LineSequencer.h.
|
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.
geometry | the geometry to add |
Definition at line 243 of file LineSequencer.h.
References geos::geom::Geometry::applyComponentFilter().
Referenced by sequence().
|
inline |
Definition at line 250 of file LineSequencer.h.
|
private |
|
private |
|
private |
Builds a geometry (LineString or MultiLineString ) representing the sequence.
sequences | a vector of vectors of const planarDirectedEdges with LineMergeEdges as their parent edges. Ownership of container and contents retained by caller. |
|
private |
|
private |
|
inline |
Act as a GeometryComponentFilter so to extract the linearworks.
Definition at line 264 of file LineSequencer.h.
|
staticprivate |
|
private |
|
private |
|
staticprivate |
Finds an DirectedEdge for an unvisited edge (if any), choosing the dirEdge which preserves orientation, if possible.
node | the node to examine |
null
if none were unvisited
|
inline |
Returns the LineString or MultiLineString built by the sequencing process, if one exists.
release | release ownership of computed Geometry |
null
if a valid sequence does not exist. Definition at line 281 of file LineSequencer.h.
Referenced by sequence().
|
private |
Tests whether a complete unique path exists in a graph using Euler's Theorem.
graph | the subgraph containing the edges |
true
if a sequence exists
|
inline |
Tests whether the arrangement of linestrings has a valid sequence.
true
if a valid sequence exists. Definition at line 227 of file LineSequencer.h.
|
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.
geom | the geometry to test |
true
if the geometry is sequenced or is not lineal
|
private |
Computes a version of the sequence which is optimally oriented relative to the underlying geometry.
Heuristics used are:
seq | a List of planarDirectedEdges |
|
staticprivate |
return a newly allocated LineString
|
private |
Reverse the sequence. This requires reversing the order of the dirEdges, and flipping each dirEdge as well
seq | a List of DirectedEdges, in sequential order |
|
inlinestatic |
Definition at line 191 of file LineSequencer.h.
References add(), and getSequencedLineStrings().
|
private |
Definition at line 100 of file LineSequencer.h.
|
private |
Definition at line 99 of file LineSequencer.h.
|
private |
Definition at line 102 of file LineSequencer.h.
|
private |
Definition at line 104 of file LineSequencer.h.
|
private |
Definition at line 101 of file LineSequencer.h.
|
private |
Definition at line 103 of file LineSequencer.h.