Class SimpleEnvelope

  • All Implemented Interfaces:
    Serializable, Envelope

    public class SimpleEnvelope
    extends Object
    implements Envelope, Serializable
    An unmodifiable Envelope implementation defined by two corners. This implementation can store an optional reference to an existing Coordinate Reference System.

    This simple implementation does not support envelopes crossing the anti-meridian. Consequently, lower ordinate values shall not be greater than corresponding upper ordinate values.

    Since:
    3.1
    See Also:
    Serialized Form
    • Method Summary

      Modifier and Type Method Description
      boolean equals​(Object object)
      Compares this envelope with the specified object for equality.
      CoordinateReferenceSystem getCoordinateReferenceSystem()
      Returns the envelope coordinate reference system, or null if unknown.
      int getDimension()
      Returns the length of coordinate sequence (the number of entries) in this envelope.
      DirectPosition getLowerCorner()
      The limits in the direction of decreasing ordinate values for each dimension.
      double getMaximum​(int dimension)
      Returns the maximal ordinate value for the specified dimension.
      double getMedian​(int dimension)
      Returns the median ordinate along the specified dimension.
      double getMinimum​(int dimension)
      Returns the minimal ordinate value for the specified dimension.
      double getSpan​(int dimension)
      Returns the envelope span (typically width or height) along the specified dimension.
      DirectPosition getUpperCorner()
      The limits in the direction of increasing ordinate values for each dimension.
      int hashCode()
      Returns an arbitrary hash code value for this envelope.
      String toString()
      Formats this envelope in the Well-Known Text (WKT) format.
    • Constructor Detail

      • SimpleEnvelope

        public SimpleEnvelope​(Envelope envelope)
        Constructs a new envelope with the same data than the specified envelope. This is a copy constructor.
        Parameters:
        envelope - the envelope to copy.
        Throws:
        IllegalArgumentException - if an ordinate value in the lower corner is greater than the corresponding ordinate value in the upper corner.
    • Method Detail

      • getDimension

        public final int getDimension()
        Returns the length of coordinate sequence (the number of entries) in this envelope.
        Specified by:
        getDimension in interface Envelope
        Returns:
        the dimensionality of this envelope.
      • getLowerCorner

        public DirectPosition getLowerCorner()
        The limits in the direction of decreasing ordinate values for each dimension. This is typically a coordinate position consisting of all the minimal ordinates for each dimension for all points within the Envelope.

        This method returns a copy of the lower corner. Changes in the returned position will not be reflected in this envelope.

        Specified by:
        getLowerCorner in interface Envelope
        Returns:
        the lower corner, typically (but not necessarily) containing minimal ordinate values.
      • getUpperCorner

        public DirectPosition getUpperCorner()
        The limits in the direction of increasing ordinate values for each dimension. This is typically a coordinate position consisting of all the maximal ordinates for each dimension for all points within the Envelope.

        This method returns a copy of the upper corner. Changes in the returned position will not be reflected in this envelope.

        Specified by:
        getUpperCorner in interface Envelope
        Returns:
        the upper corner, typically (but not necessarily) containing maximal ordinate values.
      • getMinimum

        public double getMinimum​(int dimension)
                          throws IndexOutOfBoundsException
        Returns the minimal ordinate value for the specified dimension. Since this simple class does not support envelopes crossing the anti-meridian, this method is equivalent to the following code:
        return getLowerCorner().getOrdinate(dimension);
        Specified by:
        getMinimum in interface Envelope
        Parameters:
        dimension - the dimension for which to obtain the ordinate value.
        Returns:
        the minimal ordinate at the given dimension.
        Throws:
        IndexOutOfBoundsException - if the given index is negative or is equals or greater than the envelope dimension.
      • getMaximum

        public double getMaximum​(int dimension)
                          throws IndexOutOfBoundsException
        Returns the maximal ordinate value for the specified dimension. Since this simple class does not support envelopes crossing the anti-meridian, this method is equivalent to the following code:
        return getUpperCorner().getOrdinate(dimension);
        Specified by:
        getMaximum in interface Envelope
        Parameters:
        dimension - the dimension for which to obtain the ordinate value.
        Returns:
        the maximal ordinate at the given dimension.
        Throws:
        IndexOutOfBoundsException - if the given index is negative or is equals or greater than the envelope dimension.
      • getMedian

        public double getMedian​(int dimension)
                         throws IndexOutOfBoundsException
        Returns the median ordinate along the specified dimension. Since this simple class does not support envelopes crossing the anti-meridian, this method is equivalent to the following code:
        return 0.5*(getMinimum(dimension) + getMaximum(dimension));
        Specified by:
        getMedian in interface Envelope
        Throws:
        IndexOutOfBoundsException
      • getSpan

        public double getSpan​(int dimension)
                       throws IndexOutOfBoundsException
        Returns the envelope span (typically width or height) along the specified dimension. Since this simple class does not support envelopes crossing the anti-meridian, this method is equivalent to the following code:
        return getMaximum(dimension) - getMinimum(dimension);
        Specified by:
        getSpan in interface Envelope
        Throws:
        IndexOutOfBoundsException
      • equals

        public boolean equals​(Object object)
        Compares this envelope with the specified object for equality. Since the equals(Object) and hashCode() methods are not documented in the Envelope interface, this method returns false if the given object is not an instance of the same SimpleEnvelope class. We do that in order to preserve consistency with hashCode().
        Overrides:
        equals in class Object
        Parameters:
        object - the object to compare with this envelope, or null.
        Returns:
        true if the given object is an instance of the same SimpleEnvelope class, and have equal ordinate values and equal CRS.
      • hashCode

        public int hashCode()
        Returns an arbitrary hash code value for this envelope.
        Overrides:
        hashCode in class Object
        Returns:
        a hash code value.