GEOS 3.11.1
Public Member Functions | 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>

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, std::size_t componentIndex, std::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.
 
bool isEndOfLine () const
 Checks whether the iterator cursor is pointing to the endpoint of a component geom::LineString. More...
 
std::size_t getComponentIndex () const
 The component index of the vertex the iterator is currently at. More...
 
std::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...
 

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
...
}
An iterator over the components and coordinates of a linear geometry (LineString or MultiLineString).
Definition: LinearIterator.h:49
LinearIterator(const geom::Geometry *linear)
Creates an iterator initialized to the start of a linear Geometry.
Version
1.7

Constructor & Destructor Documentation

◆ LinearIterator() [1/3]

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

◆ LinearIterator() [2/3]

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

◆ LinearIterator() [3/3]

geos::linearref::LinearIterator::LinearIterator ( const geom::Geometry linear,
std::size_t  componentIndex,
std::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

Member Function Documentation

◆ getComponentIndex()

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

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

Returns
the current component index

◆ getLine()

const geom::LineString * geos::linearref::LinearIterator::getLine ( ) const

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

Returns
a linestring

◆ getSegmentEnd()

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

◆ getSegmentStart()

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

◆ getVertexIndex()

std::size_t geos::linearref::LinearIterator::getVertexIndex ( ) const

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

Returns
the current vertex index

◆ hasNext()

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

◆ isEndOfLine()

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

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