GEOS  3.9.1dev
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
geos::linearref::LinearIterator Class Reference

An iterator over the components and coordinates of a linear geometry (LineString or MultiLineString). More...

#include <LinearIterator.h>

Collaboration diagram for geos::linearref::LinearIterator:
[legend]

Public Member Functions

 LinearIterator (const geom::Geometry *linear)
 Creates an iterator initialized to the start of a linear Geometry. More...
 
 LinearIterator (const geom::Geometry *linear, const LinearLocation &start)
 Creates an iterator starting at a LinearLocation on a linear geom::Geometry. More...
 
 LinearIterator (const geom::Geometry *linear, size_t componentIndex, size_t vertexIndex)
 Creates an iterator starting at a component and vertex in a linear geom::Geometry. More...
 
bool hasNext () const
 Tests whether there are any vertices left to iterator over. More...
 
void next ()
 Moves the iterator ahead to the next vertex and (possibly) linear component. More...
 
bool isEndOfLine () const
 Checks whether the iterator cursor is pointing to the endpoint of a component geom::LineString. More...
 
size_t getComponentIndex () const
 The component index of the vertex the iterator is currently at. More...
 
size_t getVertexIndex () const
 The vertex index of the vertex the iterator is currently at. More...
 
const geom::LineStringgetLine () const
 Gets the geom::LineString component the iterator is current at. More...
 
geom::Coordinate getSegmentStart () const
 Gets the first geom::Coordinate of the current segment. (the coordinate of the current vertex). More...
 
geom::Coordinate getSegmentEnd () const
 Gets the second geom::Coordinate of the current segment. (the coordinate of the next vertex). If the iterator is at the end of a line, null is returned. More...
 

Private Member Functions

void loadCurrentLine ()
 
 LinearIterator (const LinearIterator &other)=delete
 
LinearIteratoroperator= (const LinearIterator &rhs)=delete
 

Static Private Member Functions

static size_t segmentEndVertexIndex (const LinearLocation &loc)
 

Private Attributes

const geom::LineStringcurrentLine
 
size_t vertexIndex
 
size_t componentIndex
 
const geom::Geometrylinear
 
const size_t numLines
 

Detailed Description

An iterator over the components and coordinates of a linear geometry (LineString or MultiLineString).

The standard usage pattern for a LinearIterator is:

for (LinearIterator it = new LinearIterator(...); it.hasNext(); it.next()) {
...
int ci = it.getComponentIndex(); // for example
int vi = it.getVertexIndex(); // for example
...
}
Version
1.7

Definition at line 50 of file LinearIterator.h.

Constructor & Destructor Documentation

geos::linearref::LinearIterator::LinearIterator ( const geom::Geometry linear)

Creates an iterator initialized to the start of a linear Geometry.

Parameters
linearthe linear geometry to iterate over
geos::linearref::LinearIterator::LinearIterator ( const geom::Geometry linear,
const LinearLocation start 
)

Creates an iterator starting at a LinearLocation on a linear geom::Geometry.

Parameters
linearthe linear geometry to iterate over
startthe location to start at
geos::linearref::LinearIterator::LinearIterator ( const geom::Geometry linear,
size_t  componentIndex,
size_t  vertexIndex 
)

Creates an iterator starting at a component and vertex in a linear geom::Geometry.

Parameters
linearthe linear geometry to iterate over
componentIndexthe component to start at
vertexIndexthe vertex to start at
geos::linearref::LinearIterator::LinearIterator ( const LinearIterator other)
privatedelete

Member Function Documentation

size_t geos::linearref::LinearIterator::getComponentIndex ( ) const

The component index of the vertex the iterator is currently at.

Returns
the current component index
const geom::LineString* geos::linearref::LinearIterator::getLine ( ) const

Gets the geom::LineString component the iterator is current at.

Returns
a linestring
geom::Coordinate geos::linearref::LinearIterator::getSegmentEnd ( ) const

Gets the second geom::Coordinate of the current segment. (the coordinate of the next vertex). If the iterator is at the end of a line, null is returned.

Returns
a Coordinate or null
geom::Coordinate geos::linearref::LinearIterator::getSegmentStart ( ) const

Gets the first geom::Coordinate of the current segment. (the coordinate of the current vertex).

Returns
a Coordinate
size_t geos::linearref::LinearIterator::getVertexIndex ( ) const

The vertex index of the vertex the iterator is currently at.

Returns
the current vertex index
bool geos::linearref::LinearIterator::hasNext ( ) const

Tests whether there are any vertices left to iterator over.

Returns
true if there are more vertices to scan
bool geos::linearref::LinearIterator::isEndOfLine ( ) const

Checks whether the iterator cursor is pointing to the endpoint of a component geom::LineString.

Returns
true if the iterator is at an endpoint
void geos::linearref::LinearIterator::loadCurrentLine ( )
private

Invariant: currentLine <> null if the iterator is pointing at a valid coordinate

Exceptions
IllegalArgumentExceptionif linearGeom is not Lineal
void geos::linearref::LinearIterator::next ( )

Moves the iterator ahead to the next vertex and (possibly) linear component.

LinearIterator& geos::linearref::LinearIterator::operator= ( const LinearIterator rhs)
privatedelete
static size_t geos::linearref::LinearIterator::segmentEndVertexIndex ( const LinearLocation loc)
staticprivate

Member Data Documentation

size_t geos::linearref::LinearIterator::componentIndex
private

Definition at line 138 of file LinearIterator.h.

const geom::LineString* geos::linearref::LinearIterator::currentLine
private

Definition at line 136 of file LinearIterator.h.

const geom::Geometry* geos::linearref::LinearIterator::linear
private

Definition at line 139 of file LinearIterator.h.

const size_t geos::linearref::LinearIterator::numLines
private

Definition at line 140 of file LinearIterator.h.

size_t geos::linearref::LinearIterator::vertexIndex
private

Definition at line 137 of file LinearIterator.h.


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