public class LinearIterator
extends java.lang.Object
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 ... }
Modifier and Type | Field and Description |
---|---|
private int |
componentIndex |
private LineString |
currentLine
Invariant: currentLine <> null if the iterator is pointing at a valid coordinate
|
private Geometry |
linearGeom |
private int |
numLines |
private int |
vertexIndex |
Constructor and Description |
---|
LinearIterator(Geometry linear)
Creates an iterator initialized to the start of a linear
Geometry |
LinearIterator(Geometry linearGeom,
int componentIndex,
int vertexIndex)
Creates an iterator starting at
a specified component and vertex in a linear
Geometry |
LinearIterator(Geometry linear,
LinearLocation start)
Creates an iterator starting at
a
LinearLocation on a linear Geometry |
Modifier and Type | Method and Description |
---|---|
int |
getComponentIndex()
The component index of the vertex the iterator is currently at.
|
LineString |
getLine()
Gets the
LineString component the iterator is current at. |
Coordinate |
getSegmentEnd()
Gets the second
Coordinate of the current segment. |
Coordinate |
getSegmentStart()
Gets the first
Coordinate of the current segment. |
int |
getVertexIndex()
The vertex index of the vertex the iterator is currently at.
|
boolean |
hasNext()
Tests whether there are any vertices left to iterator over.
|
boolean |
isEndOfLine()
Checks whether the iterator cursor is pointing to the
endpoint of a component
LineString . |
private void |
loadCurrentLine() |
void |
next()
Moves the iterator ahead to the next vertex and (possibly) linear component.
|
private static int |
segmentEndVertexIndex(LinearLocation loc) |
private Geometry linearGeom
private final int numLines
private LineString currentLine
private int componentIndex
private int vertexIndex
public LinearIterator(Geometry linear)
Geometry
linear
- the linear geometry to iterate overjava.lang.IllegalArgumentException
- if linearGeom is not linealpublic LinearIterator(Geometry linear, LinearLocation start)
LinearLocation
on a linear Geometry
linear
- the linear geometry to iterate overstart
- the location to start atjava.lang.IllegalArgumentException
- if linearGeom is not linealpublic LinearIterator(Geometry linearGeom, int componentIndex, int vertexIndex)
Geometry
linearGeom
- the linear geometry to iterate overcomponentIndex
- the component to start atvertexIndex
- the vertex to start atjava.lang.IllegalArgumentException
- if linearGeom is not linealprivate static int segmentEndVertexIndex(LinearLocation loc)
private void loadCurrentLine()
public boolean hasNext()
true
if there are more vertices to scanpublic void next()
public boolean isEndOfLine()
LineString
.true
if the iterator is at an endpointpublic int getComponentIndex()
public int getVertexIndex()
public LineString getLine()
LineString
component the iterator is current at.public Coordinate getSegmentStart()
Coordinate
of the current segment.
(the coordinate of the current vertex).Coordinate
public Coordinate getSegmentEnd()
Coordinate
of the current segment.
(the coordinate of the next vertex).
If the iterator is at the end of a line, null
is returned.Coordinate
or null