Class SimpleDirectPosition

    • Field Detail

      • ordinates

        public final double[] ordinates
        The ordinate values. The length of this array is the dimension of this direct position.

        This array is public for allowing more efficient ordinates operations, for example using the Arrays methods. However we encourage to use only the methods from the DirectPosition interface in most cases.

        See Also:
        getCoordinate()
      • crs

        protected CoordinateReferenceSystem crs
        The coordinate reference system associated to this direct position, or null if unspecified.

        The SimpleDirectPosition class does not provide any setter for this field, since uncontrolled modifications of geometry CRS is often undesirable. The decision to allow modifications or not is left to subclasses.

        See Also:
        getCoordinateReferenceSystem()
    • Constructor Detail

      • SimpleDirectPosition

        public SimpleDirectPosition​(int dimension)
        Creates a new direct position of the given dimension. The Coordinate Reference System is left unspecified. All ordinate values are initialized to zero.
        Parameters:
        dimension - the dimension.
      • SimpleDirectPosition

        public SimpleDirectPosition​(CoordinateReferenceSystem crs)
        Creates a new direct position associated to the given coordinate reference system. The dimension of the new direct position is the dimension of the given CRS. All ordinate values are initialized to zero.
        Parameters:
        crs - the coordinate reference system to associate to the new direct position.
      • SimpleDirectPosition

        public SimpleDirectPosition​(CoordinateReferenceSystem crs,
                                    double... ordinates)
                             throws MismatchedDimensionException
        Creates a new direct position initialized to the given ordinate values. If the given CRS is non-null, then its dimension shall be equal to the length of the given ordinates array.

        This constructor assigns the given array directly (without clone) to the ordinates field, because that field is public anyway. Defensive copy would not protect the state of this object.

        Parameters:
        crs - the coordinate reference system, or null.
        ordinates - the ordinate values. This array is not cloned.
        Throws:
        MismatchedDimensionException - if the given CRS is not null and its dimension is not equals to the length of the ordinates array.
      • SimpleDirectPosition

        public SimpleDirectPosition​(DirectPosition position)
        Creates a new direct position initialized to the CRS and ordinate values of the given direct position. This is a copy constructor.
        Parameters:
        position - the direct position from which to copy the CRS and ordinate values.
    • Method Detail

      • getCoordinateReferenceSystem

        public CoordinateReferenceSystem getCoordinateReferenceSystem()
        Returns the coordinate reference system in which the coordinate is given. May be null if no CRS were specified at construction time. In such case, this particular direct position is assumed included in a larger object with such a reference to a coordinate reference system.
        Specified by:
        getCoordinateReferenceSystem in interface DirectPosition
        Returns:
        the coordinate reference system, or null.
      • getDirectPosition

        public DirectPosition getDirectPosition()
        Unconditionally returns this, since this object is already a direct position.
        Specified by:
        getDirectPosition in interface Position
      • equals

        public boolean equals​(Object object)
        Returns true if the specified object is also a DirectPosition with equal coordinate and equal CRS. This method performs the comparison as documented in the DirectPosition.equals(Object) Javadoc. In particular, the given object is not required to be of the same implementation class. Consequently, it should be possible to mix different DirectPosition implementations in the same hash map.
        Specified by:
        equals in interface DirectPosition
        Overrides:
        equals in class Object
      • hashCode

        public int hashCode()
        Returns a hash code value for this direct position. This method returns a value compliant with the contract documented in the DirectPosition.hashCode() javadoc. Consequently, it should be possible to mix different DirectPosition implementations in the same hash map.
        Specified by:
        hashCode in interface DirectPosition
        Overrides:
        hashCode in class Object
        Returns:
        a hash code value for this position.
      • toString

        public String toString()
        Returns a string representation of this direct position in Well-Known Text (WKT) format.
        Overrides:
        toString in class Object
        Returns:
        the Well-Known Text representation of this direct position.
        See Also:
        Well-known text on Wikipedia