Class CoordinateArraySequence

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, CoordinateSequence

    public class CoordinateArraySequence
    extends java.lang.Object
    implements CoordinateSequence, java.io.Serializable
    A CoordinateSequence backed by an array of Coordinates. This is the implementation that Geometrys use by default. Coordinates returned by #toArray and #getCoordinate are live -- modifications to them are actually changing the CoordinateSequence's underlying data. A dimension may be specified for the coordinates in the sequence, which may be 2 or 3. The actual coordinates will always have 3 ordinates, but the dimension is useful as metadata in some situations.
    Version:
    1.7
    See Also:
    Serialized Form
    • Constructor Detail

      • CoordinateArraySequence

        public CoordinateArraySequence​(Coordinate[] coordinates)
        Constructs a sequence based on the given array of Coordinates (the array is not copied). The coordinate dimension defaults to 3.
        Parameters:
        coordinates - the coordinate array that will be referenced.
      • CoordinateArraySequence

        public CoordinateArraySequence​(Coordinate[] coordinates,
                                       int dimension)
        Constructs a sequence based on the given array of Coordinates (the array is not copied).
        Parameters:
        coordinates - the coordinate array that will be referenced.
        dimension - the dimension of the coordinates
      • CoordinateArraySequence

        public CoordinateArraySequence​(Coordinate[] coordinates,
                                       int dimension,
                                       int measures)
        Constructs a sequence based on the given array of Coordinates (the array is not copied).
        Parameters:
        coordinates - the coordinate array that will be referenced.
        dimension - the dimension of the coordinates
      • CoordinateArraySequence

        public CoordinateArraySequence​(int size)
        Constructs a sequence of a given size, populated with new Coordinates.
        Parameters:
        size - the size of the sequence to create
      • CoordinateArraySequence

        public CoordinateArraySequence​(int size,
                                       int dimension)
        Constructs a sequence of a given size, populated with new Coordinates.
        Parameters:
        size - the size of the sequence to create
        dimension - the dimension of the coordinates
      • CoordinateArraySequence

        public CoordinateArraySequence​(int size,
                                       int dimension,
                                       int measures)
        Constructs a sequence of a given size, populated with new Coordinates.
        Parameters:
        size - the size of the sequence to create
        dimension - the dimension of the coordinates
      • CoordinateArraySequence

        public CoordinateArraySequence​(CoordinateSequence coordSeq)
        Creates a new sequence based on a deep copy of the given CoordinateSequence. The coordinate dimension is set to equal the dimension of the input.
        Parameters:
        coordSeq - the coordinate sequence that will be copied.
    • 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
      • getCoordinate

        public Coordinate getCoordinate​(int i)
        Get the Coordinate with index i.
        Specified by:
        getCoordinate in interface CoordinateSequence
        Parameters:
        i - the index of the coordinate
        Returns:
        the requested Coordinate instance
      • getCoordinateCopy

        public Coordinate getCoordinateCopy​(int i)
        Get a copy of the Coordinate with index i.
        Specified by:
        getCoordinateCopy in interface CoordinateSequence
        Parameters:
        i - the index of the coordinate
        Returns:
        a copy of the requested Coordinate
      • getZ

        public double getZ​(int index)
        Description copied from interface: CoordinateSequence
        Returns ordinate Z of the specified coordinate if available.
        Specified by:
        getZ in interface CoordinateSequence
        Returns:
        the value of the Z ordinate in the index'th coordinate, or Double.NaN if not defined.
        See Also:
        CoordinateSequence.getZ(int)
      • getM

        public double getM​(int index)
        Description copied from interface: CoordinateSequence
        Returns ordinate M of the specified coordinate if available.
        Specified by:
        getM in interface CoordinateSequence
        Returns:
        the value of the M ordinate in the index'th coordinate, or Double.NaN if not defined.
        See Also:
        CoordinateSequence.getM(int)
      • clone

        public java.lang.Object clone()
        Deprecated.
        Creates a deep copy of the Object
        Specified by:
        clone in interface CoordinateSequence
        Returns:
        The deep copy
      • size

        public int size()
        Returns the size of the coordinate sequence
        Specified by:
        size in interface CoordinateSequence
        Returns:
        the number of coordinates
      • setOrdinate

        public void setOrdinate​(int index,
                                int ordinateIndex,
                                double value)
        Description copied from interface: CoordinateSequence
        Sets the value for a given ordinate of a coordinate in this sequence.
        Specified by:
        setOrdinate in interface CoordinateSequence
        Parameters:
        index - the coordinate index in the sequence
        ordinateIndex - the ordinate index in the coordinate (in range [0, dimension-1])
        value - the new ordinate value
        See Also:
        CoordinateSequence.setOrdinate(int, int, double)
      • expandEnvelope

        public Envelope expandEnvelope​(Envelope env)
        Description copied from interface: CoordinateSequence
        Expands the given Envelope to include the coordinates in the sequence. Allows implementing classes to optimize access to coordinate values.
        Specified by:
        expandEnvelope in interface CoordinateSequence
        Parameters:
        env - the envelope to expand
        Returns:
        a ref to the expanded envelope
      • toString

        public java.lang.String toString()
        Returns the string Representation of the coordinate array
        Overrides:
        toString in class java.lang.Object
        Returns:
        The string