Class CompoundDirectPositions

java.lang.Object
org.apache.sis.math.CompoundDirectPositions
All Implemented Interfaces:
Iterable<org.opengis.geometry.DirectPosition>, Iterator<org.opengis.geometry.DirectPosition>, org.opengis.geometry.coordinate.Position, org.opengis.geometry.DirectPosition

final class CompoundDirectPositions extends Object implements org.opengis.geometry.DirectPosition, Iterable<org.opengis.geometry.DirectPosition>, Iterator<org.opengis.geometry.DirectPosition>
A sequence of DirectPositions which is a view over arrays of coordinate values. Each dimension is stored in a separated array. For example, this class can view three arrays (x[], y[], and z[]) as a sequence of three-dimensional DirectPosition.

Limitation

This class is also its own iterator. All calls to iterator() return the same iterator, and all calls to next() return the same DirectPosition instance. Consequently this class is not suitable for normal use where many objects may iterate over the sequence in same time.
Since:
0.5
Version:
0.8
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final Vector[]
    The arrays of coordinate values, for example (x[], y[], z[]).
    private int
    Index of the next element to be returned by next().
    private final int
    Length of all coordinate values minus one.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Wraps the given array of coordinate values.
  • Method Summary

    Modifier and Type
    Method
    Description
    double[]
    Not needed.
    org.opengis.referencing.crs.CoordinateReferenceSystem
    Returns null since there is no CRS associated to this object.
    int
    Returns the number of dimensions.
    org.opengis.geometry.DirectPosition
    Returns this since this object is already a direct position.
    double
    getOrdinate(int dimension)
    Return the coordinate value at the given dimension.
    boolean
    Returns true if there is more position to return.
    Iterator<org.opengis.geometry.DirectPosition>
    Starts a new iteration.
    org.opengis.geometry.DirectPosition
    Sets this object to the next position and return it.
    void
    setOrdinate(int dimension, double value)
    Not needed.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.opengis.geometry.DirectPosition

    equals, hashCode

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator

    Methods inherited from interface java.util.Iterator

    forEachRemaining, remove
  • Field Details

    • coordinates

      private final Vector[] coordinates
      The arrays of coordinate values, for example (x[], y[], z[]).
    • last

      private final int last
      Length of all coordinate values minus one.
    • index

      private int index
      Index of the next element to be returned by next().
  • Constructor Details

    • CompoundDirectPositions

      CompoundDirectPositions(Vector... coordinates)
      Wraps the given array of coordinate values.
  • Method Details

    • iterator

      public Iterator<org.opengis.geometry.DirectPosition> iterator()
      Starts a new iteration.
      Specified by:
      iterator in interface Iterable<org.opengis.geometry.DirectPosition>
      Returns:
      always this.
    • hasNext

      public boolean hasNext()
      Returns true if there is more position to return.
      Specified by:
      hasNext in interface Iterator<org.opengis.geometry.DirectPosition>
    • next

      public org.opengis.geometry.DirectPosition next()
      Sets this object to the next position and return it.
      Specified by:
      next in interface Iterator<org.opengis.geometry.DirectPosition>
      Returns:
      always this.
    • getDirectPosition

      public org.opengis.geometry.DirectPosition getDirectPosition()
      Returns this since this object is already a direct position.
      Specified by:
      getDirectPosition in interface org.opengis.geometry.coordinate.Position
      Returns:
      always this.
    • getCoordinateReferenceSystem

      public org.opengis.referencing.crs.CoordinateReferenceSystem getCoordinateReferenceSystem()
      Returns null since there is no CRS associated to this object.
      Specified by:
      getCoordinateReferenceSystem in interface org.opengis.geometry.DirectPosition
      Returns:
      always null.
    • getDimension

      public int getDimension()
      Returns the number of dimensions.
      Specified by:
      getDimension in interface org.opengis.geometry.DirectPosition
    • getOrdinate

      public double getOrdinate(int dimension)
      Return the coordinate value at the given dimension.
      Specified by:
      getOrdinate in interface org.opengis.geometry.DirectPosition
    • getCoordinate

      public double[] getCoordinate()
      Not needed.
      Specified by:
      getCoordinate in interface org.opengis.geometry.DirectPosition
    • setOrdinate

      public void setOrdinate(int dimension, double value)
      Not needed.
      Specified by:
      setOrdinate in interface org.opengis.geometry.DirectPosition