Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## 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
       ...
     }

Version:
  1.7

Constructor Summary
`LinearIterator(Geometry linear)` Creates an iterator initialized to the start of a linear `Geometry`
`LinearIterator(Geometry linear, int componentIndex, int vertexIndex)` Creates an iterator starting at a component and vertex in a linear `Geometry`
`LinearIterator(Geometry linear, LinearLocation start)` Creates an iterator starting at a `LinearLocation` on a linear `Geometry`

Method Summary
`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 linestring.
`void` | `next()` Moves the iterator ahead to the next vertex and (possibly) linear component.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### LinearIterator

    public LinearIterator(Geometry linear)

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

Parameters:
  `linear` - the linear geometry to iterate over

### LinearIterator

    public LinearIterator(Geometry linear,
                          LinearLocation start)

  Creates an iterator starting at a `LinearLocation` on a linear `Geometry`

Parameters:
  `linear` - the linear geometry to iterate over
  `start` - 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`

Parameters:
  `linear` - the linear geometry to iterate over
  `componentIndex` - the component to start at
  `vertexIndex` - the vertex to start at

Method Detail

### hasNext

    public boolean hasNext()

  Tests whether there are any vertices left to iterator over.

  Returns:
    `true` if there are more vertices to scan

### next

    public void next()

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

### isEndOfLine

    public boolean isEndOfLine()

  Checks whether the iterator cursor is pointing to the endpoint of a linestring.

  Returns:
    `true if the iterator is at an endpoint`

### getComponentIndex

    public int getComponentIndex()

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

  Returns:
    the current component index

### getVertexIndex

    public int getVertexIndex()

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

  Returns:
    the current vertex index

### getLine

    public LineString getLine()

  Gets the `LineString` component the iterator is current at.

  Returns:
    a linestring

### getSegmentStart

    public Coordinate getSegmentStart()

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

  Returns:
    a `Coordinate`

### 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.

  Returns:
    a `Coordinate` or `null`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD