Class PackedCoordinateSequence

java.lang.Object
org.apache.sis.internal.feature.jts.PackedCoordinateSequence
All Implemented Interfaces:
Serializable, Cloneable, org.locationtech.jts.geom.CoordinateSequence
Direct Known Subclasses:
PackedCoordinateSequence.Double, PackedCoordinateSequence.Float

abstract class PackedCoordinateSequence extends Object implements org.locationtech.jts.geom.CoordinateSequence, Serializable
A JTS coordinate sequence which stores coordinates in a single float[] or double[] array. This class serves the same purpose than PackedCoordinateSequence but without caching the Coordinate[] array.
Since:
1.2
Version:
1.2
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    (package private) static final class 
    Coordinate sequence storing values in a packed double[] array.
    (package private) static final class 
    Coordinate sequence storing values in a packed float[] array.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final int
    Number of dimensions for this coordinate sequence.
    private final int
    Whether this coordinate sequence has z and/or M coordinate values.
    private static final int
    Bit to set to 1 in the hasZM mask if this coordinate sequence has z and/or M coordinate values.
    private static final long
    For cross-version compatibility.
    private static final int
    Bit to set to 1 in the hasZM mask if this coordinate sequence has z and/or M coordinate values.

    Fields inherited from interface org.locationtech.jts.geom.CoordinateSequence

    M, X, Y, Z
  • Constructor Summary

    Constructors
    Constructor
    Description
    PackedCoordinateSequence(int dimension, int measures)
    Creates a new coordinate sequence for the given number of dimensions.
    Creates a new sequence initialized to a copy of the given sequence.
  • Method Summary

    Modifier and Type
    Method
    Description
    final Object
    Deprecated.
    Inherits the deprecation status from JTS.
    (package private) abstract double
    coordinate(int index)
    Returns the coordinate value at the given index in the packed array.
    boolean
    Compares the given object with this sequence for equality.
    final org.locationtech.jts.geom.Coordinate
    getCoordinate(int index)
    Returns the coordinate tuple at the given index.
    final void
    getCoordinate(int index, org.locationtech.jts.geom.Coordinate dest)
    Copies the coordinate tuple at the given index into the specified target.
    final org.locationtech.jts.geom.Coordinate
    getCoordinateCopy(int index)
    Returns the coordinate tuple at given index.
    final int
    Returns the number of dimensions for all coordinates in this sequence, including measures.
    final double
    getM(int index)
    Returns the first M coordinate value for the tuple at the given index, or
    invalid reference
    java.lang.Double.NaN
    if this sequence has no M coordinates.
    final int
    Returns the number of M coordinates.
    final double
    getOrdinate(int index, int dim)
    Returns a coordinate value from the coordinate tuple at the given index.
    private static int
    Returns the number of spatial dimensions, which is 2<G> or 3<G>.
    final double
    getX(int index)
    Returns the x coordinate value for the tuple at the given index.
    final double
    getY(int index)
    Returns the y coordinate value for the tuple at the given index.
    final double
    getZ(int index)
    Returns the z coordinate value for the tuple at the given index, or
    invalid reference
    java.lang.Double.NaN
    if this sequence has no z coordinates.
    int
    Returns a hash code value for this sequence.
    final boolean
    Returns whether this coordinate sequence has M coordinate values.
    final boolean
    Returns whether this coordinate sequence has z coordinate values.
    (package private) abstract void
    setCoordinates(org.locationtech.jts.geom.Coordinate[] values)
    Sets all coordinates in this sequence.
    (package private) void
    setCoordinates(org.locationtech.jts.geom.CoordinateSequence values)
    Sets all coordinates in this sequence.
    final org.locationtech.jts.geom.Coordinate[]
    Returns a copy of all coordinates in this sequence.
    final String
    Returns a string representation of this coordinate sequence.

    Methods inherited from class java.lang.Object

    finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.locationtech.jts.geom.CoordinateSequence

    copy, createCoordinate, expandEnvelope, setOrdinate, size
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      For cross-version compatibility.
      See Also:
    • dimension

      protected final int dimension
      Number of dimensions for this coordinate sequence.
      See Also:
    • hasZM

      private final int hasZM
      Whether this coordinate sequence has z and/or M coordinate values. This is a combination of Z_MASK and M_MASK bit masks.
      See Also:
    • Z_MASK

      private static final int Z_MASK
      Bit to set to 1 in the hasZM mask if this coordinate sequence has z and/or M coordinate values.
      See Also:
    • M_MASK

      private static final int M_MASK
      Bit to set to 1 in the hasZM mask if this coordinate sequence has z and/or M coordinate values.
      See Also:
  • Constructor Details

    • PackedCoordinateSequence

      PackedCoordinateSequence(PackedCoordinateSequence original)
      Creates a new sequence initialized to a copy of the given sequence. This is for constructors implementing the CoordinateSequence.copy() method.
    • PackedCoordinateSequence

      PackedCoordinateSequence(int dimension, int measures)
      Creates a new coordinate sequence for the given number of dimensions.
      Parameters:
      dimension - number of dimensions, including the number of measures.
      measures - number of M coordinates.
  • Method Details

    • getSpatialDimension

      private static int getSpatialDimension(int hasZM)
      Returns the number of spatial dimensions, which is 2<G> or 3<G>.
    • getDimension

      public final int getDimension()
      Returns the number of dimensions for all coordinates in this sequence, including measures.
      Specified by:
      getDimension in interface org.locationtech.jts.geom.CoordinateSequence
    • getMeasures

      public final int getMeasures()
      Returns the number of M coordinates.
      Specified by:
      getMeasures in interface org.locationtech.jts.geom.CoordinateSequence
    • hasZ

      public final boolean hasZ()
      Returns whether this coordinate sequence has z coordinate values.
      Specified by:
      hasZ in interface org.locationtech.jts.geom.CoordinateSequence
    • hasM

      public final boolean hasM()
      Returns whether this coordinate sequence has M coordinate values.
      Specified by:
      hasM in interface org.locationtech.jts.geom.CoordinateSequence
    • getX

      public final double getX(int index)
      Returns the x coordinate value for the tuple at the given index.
      Specified by:
      getX in interface org.locationtech.jts.geom.CoordinateSequence
    • getY

      public final double getY(int index)
      Returns the y coordinate value for the tuple at the given index.
      Specified by:
      getY in interface org.locationtech.jts.geom.CoordinateSequence
    • getZ

      public final double getZ(int index)
      Returns the z coordinate value for the tuple at the given index, or
      invalid reference
      java.lang.Double.NaN
      if this sequence has no z coordinates.
      Specified by:
      getZ in interface org.locationtech.jts.geom.CoordinateSequence
    • getM

      public final double getM(int index)
      Returns the first M coordinate value for the tuple at the given index, or
      invalid reference
      java.lang.Double.NaN
      if this sequence has no M coordinates.
      Specified by:
      getM in interface org.locationtech.jts.geom.CoordinateSequence
    • getCoordinate

      public final org.locationtech.jts.geom.Coordinate getCoordinate(int index)
      Returns the coordinate tuple at the given index.
      Specified by:
      getCoordinate in interface org.locationtech.jts.geom.CoordinateSequence
      Parameters:
      index - index of the coordinate tuple.
      Returns:
      coordinate tuple at the given index.
      Throws:
      ArrayIndexOutOfBoundsException - if the given index is out of bounds.
    • getCoordinate

      public final void getCoordinate(int index, org.locationtech.jts.geom.Coordinate dest)
      Copies the coordinate tuple at the given index into the specified target.
      Specified by:
      getCoordinate in interface org.locationtech.jts.geom.CoordinateSequence
      Parameters:
      index - index of the coordinate tuple.
      dest - where to copy the coordinates.
      Throws:
      ArrayIndexOutOfBoundsException - if the given index is out of bounds.
    • getCoordinateCopy

      public final org.locationtech.jts.geom.Coordinate getCoordinateCopy(int index)
      Returns the coordinate tuple at given index.
      Specified by:
      getCoordinateCopy in interface org.locationtech.jts.geom.CoordinateSequence
      Parameters:
      index - index of the coordinate tuple.
      Returns:
      coordinate tuple at the given index.
      Throws:
      ArrayIndexOutOfBoundsException - if the given index is out of bounds.
    • getOrdinate

      public final double getOrdinate(int index, int dim)
      Returns a coordinate value from the coordinate tuple at the given index. For performance reasons, this method does not check dim validity.
      Specified by:
      getOrdinate in interface org.locationtech.jts.geom.CoordinateSequence
      Parameters:
      index - index of the coordinate tuple.
      dim - index of the coordinate value in the tuple.
      Returns:
      value of the specified value in the coordinate tuple.
    • coordinate

      abstract double coordinate(int index)
      Returns the coordinate value at the given index in the packed array.
      Parameters:
      index - index in the packed array.
      Returns:
      coordinate value at the given index.
    • setCoordinates

      abstract void setCoordinates(org.locationtech.jts.geom.Coordinate[] values)
      Sets all coordinates in this sequence. The length of the given array shall be equal to CoordinateSequence.size() (this is not verified).
    • setCoordinates

      void setCoordinates(org.locationtech.jts.geom.CoordinateSequence values)
      Sets all coordinates in this sequence. The size of the given sequence shall be equal to CoordinateSequence.size() (this is not verified).
    • toCoordinateArray

      public final org.locationtech.jts.geom.Coordinate[] toCoordinateArray()
      Returns a copy of all coordinates in this sequence.
      Specified by:
      toCoordinateArray in interface org.locationtech.jts.geom.CoordinateSequence
    • toString

      public final String toString()
      Returns a string representation of this coordinate sequence.
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Returns a hash code value for this sequence.
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Compares the given object with this sequence for equality.
      Overrides:
      equals in class Object
    • clone

      @Deprecated public final Object clone()
      Deprecated.
      Inherits the deprecation status from JTS.
      Returns a copy of this sequence.
      Specified by:
      clone in interface org.locationtech.jts.geom.CoordinateSequence
      Overrides:
      clone in class Object