Class PackedCoordinateSequence

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, CoordinateSequence
    Direct Known Subclasses:
    PackedCoordinateSequence.Double, PackedCoordinateSequence.Float

    public abstract class PackedCoordinateSequence
    extends java.lang.Object
    implements CoordinateSequence, java.io.Serializable
    A CoordinateSequence implementation based on a packed arrays. In this implementation, Coordinates returned by #toArray and #get are copies of the internal values. To change the actual values, use the provided setters.

    For efficiency, created Coordinate arrays are cached using a soft reference. The cache is cleared each time the coordinate sequence contents are modified through a setter method.

    Version:
    1.7
    See Also:
    Serialized Form
    • Method Detail

      • getMeasures

        public int getMeasures()
        Description copied from interface: CoordinateSequence
        Returns the number of measures included in CoordinateSequence.getDimension() for each coordinate for this sequence. For a measured coordinate sequence a non-zero value is returned.
        • For XY sequence measures is zero
        • For XYM sequence measure is one
        • For XYZ sequence measure is zero
        • For XYZM sequence measure is one
        • Values greater than one are supported
        Specified by:
        getMeasures in interface CoordinateSequence
        Returns:
        the number of measures included in dimension
        See Also:
        CoordinateSequence.getMeasures()
      • getCoordinate

        public Coordinate getCoordinate​(int i)
        Description copied from interface: CoordinateSequence
        Returns (possibly a copy of) the i'th coordinate in this sequence. Whether or not the Coordinate returned is the actual underlying Coordinate or merely a copy depends on the implementation.

        Note that in the future the semantics of this method may change to guarantee that the Coordinate returned is always a copy. Callers should not to assume that they can modify a CoordinateSequence by modifying the object returned by this method.

        Specified by:
        getCoordinate in interface CoordinateSequence
        Parameters:
        i - the index of the coordinate to retrieve
        Returns:
        the i'th coordinate in the sequence
        See Also:
        CoordinateSequence.getCoordinate(int)
      • getCoordinateCopy

        public Coordinate getCoordinateCopy​(int i)
        Description copied from interface: CoordinateSequence
        Returns a copy of the i'th coordinate in this sequence. This method optimizes the situation where the caller is going to make a copy anyway - if the implementation has already created a new Coordinate object, no further copy is needed.
        Specified by:
        getCoordinateCopy in interface CoordinateSequence
        Parameters:
        i - the index of the coordinate to retrieve
        Returns:
        a copy of the i'th coordinate in the sequence
        See Also:
        CoordinateSequence.getCoordinate(int)
      • toCoordinateArray

        public Coordinate[] toCoordinateArray()
        Description copied from interface: CoordinateSequence
        Returns (possibly copies of) the Coordinates in this collection. Whether or not the Coordinates returned are the actual underlying Coordinates or merely copies depends on the implementation. Note that if this implementation does not store its data as an array of Coordinates, this method will incur a performance penalty because the array needs to be built from scratch.
        Specified by:
        toCoordinateArray in interface CoordinateSequence
        Returns:
        a array of coordinates containing the point values in this sequence
        See Also:
        CoordinateSequence.toCoordinateArray()
      • setX

        public void setX​(int index,
                         double value)
        Sets the first ordinate of a coordinate in this sequence.
        Parameters:
        index - the coordinate index
        value - the new ordinate value
      • setY

        public void setY​(int index,
                         double value)
        Sets the second ordinate of a coordinate in this sequence.
        Parameters:
        index - the coordinate index
        value - the new ordinate value
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • clone

        public abstract java.lang.Object clone()
        Deprecated.
        Description copied from interface: CoordinateSequence
        Returns a deep copy of this collection. Called by Geometry#clone.
        Specified by:
        clone in interface CoordinateSequence
        Returns:
        a copy of the coordinate sequence containing copies of all points
        See Also:
        Object.clone(), CoordinateSequence.clone()
      • setOrdinate

        public abstract void setOrdinate​(int index,
                                         int ordinate,
                                         double value)
        Sets the ordinate of a coordinate in this sequence.
        Warning: for performance reasons the ordinate index is not checked - if it is over dimensions you may not get an exception but a meaningless value.
        Specified by:
        setOrdinate in interface CoordinateSequence
        Parameters:
        index - the coordinate index
        ordinate - the ordinate index in the coordinate, 0 based, smaller than the number of dimensions
        value - the new ordinate value