com.vividsolutions.jts.linearref
Class LinearIterator
java.lang.Object
com.vividsolutions.jts.linearref.LinearIterator
public class LinearIterator
extends java.lang.Object
An iterator over the components and coordinates of a linear geometry
(
LineString
s and
MultiLineString
s.
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
...
}
LinearIterator
public LinearIterator(Geometry linear)
Creates an iterator initialized to the start of a linear
Geometry
linear
- the linear geometry to iterate over
LinearIterator
public LinearIterator(Geometry linear,
LinearLocation start)
linear
- the linear geometry to iterate overstart
- the location to start at
LinearIterator
public LinearIterator(Geometry linear,
int componentIndex,
int vertexIndex)
Creates an iterator starting at
a component and vertex in a linear
Geometry
linear
- the linear geometry to iterate overcomponentIndex
- the component to start atvertexIndex
- the vertex to start at
getComponentIndex
public int getComponentIndex()
The component index of the vertex the iterator is currently at.
- the current component index
getSegmentEnd
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.
getSegmentStart
public Coordinate getSegmentStart()
Gets the first
Coordinate
of the current segment.
(the coordinate of the current vertex).
getVertexIndex
public int getVertexIndex()
The vertex index of the vertex the iterator is currently at.
hasNext
public boolean hasNext()
Tests whether there are any vertices left to iterator over.
true
if there are more vertices to scan
isEndOfLine
public boolean isEndOfLine()
Checks whether the iterator cursor is pointing to the
endpoint of a linestring.
true if the iterator is at an endpoint
next
public void next()
Moves the iterator ahead to the next vertex and (possibly) linear component.