Class LinearIterator

Hierarchy: Object , LinearIterator
public class LinearIterator
An iterator over the components and coordinates of a linear geometry ( LineStrings and MultiLineStrings. 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
   ...
 }
 

Other

  • version: 1.7
public LinearIterator(Geometry linear)
Creates an iterator initialized to the start of a linear Geometry
Parameters:
linear - linear the linear geometry to iterate over
Throws:
IllegalArgumentException - IllegalArgumentException if linearGeom is not lineal
public LinearIterator(Geometry linear, LinearLocation start)
Creates an iterator starting at a LinearLocation on a linear Geometry
Parameters:
linear - linear the linear geometry to iterate over
start - start the location to start at
Throws:
IllegalArgumentException - IllegalArgumentException if linearGeom is not lineal
public LinearIterator(Geometry linearGeom, int componentIndex, int vertexIndex)
Creates an iterator starting at a specified component and vertex in a linear Geometry
Parameters:
linearGeom - linearGeom the linear geometry to iterate over
componentIndex - componentIndex the component to start at
vertexIndex - vertexIndex the vertex to start at
Throws:
IllegalArgumentException - IllegalArgumentException if linearGeom is not lineal
public boolean hasNext()
Tests whether there are any vertices left to iterator over. Specifically, hasNext() return true if the current state of the iterator represents a valid location on the linear geometry.
Returns:
true if there are more vertices to scan
public void next()
Moves the iterator ahead to the next vertex and (possibly) linear component.
public boolean isEndOfLine()
Checks whether the iterator cursor is pointing to the endpoint of a component LineString.
Returns:
true if the iterator is at an endpoint
public int getComponentIndex()
The component index of the vertex the iterator is currently at.
Returns:
the current component index
public int getVertexIndex()
The vertex index of the vertex the iterator is currently at.
Returns:
the current vertex index
public LineString getLine()
Gets the LineString component the iterator is current at.
Returns:
a linestring
public Coordinate getSegmentStart()
Gets the first Coordinate of the current segment. (the coordinate of the current vertex).
Returns:
a Coordinate
public Coordinate getSegmentEnd()
Gets the second 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