Class Envelope<P extends Position>


  • public class Envelope<P extends Position>
    extends Object
    An envelope or bounding box implementation.

    An Envelope is characterised by a lower-left and an upper-right coordinate.

    An Envelope is empty if the set of enclosed points is empty.

    An empty Envelope has Double.NaN for its lowerleft/upperright coordinates.

    Author:
    Karel Maesen, Geovise BVBA, 2011
    • Constructor Detail

      • Envelope

        public Envelope​(P lowerLeft,
                        P upperRight,
                        CoordinateReferenceSystem<P> crs)
        Creates an instance from specified lower-left and upper-right Points. If the positions have coordinate dimension > 2, the Z/M coordinate values will be set to 0 in the constructed Envelope
        Parameters:
        lowerLeft - the Point designating the lower-left coordinates
        upperRight - the Point designating the upper-right coordinates of the envelope.
      • Envelope

        public Envelope​(double minC1,
                        double minC2,
                        double maxC1,
                        double maxC2,
                        CoordinateReferenceSystem<P> crs)
        Create an instance using the specified coordinates and CoordinateReferenceSystem. If the CoordinateReferenceSystem has coordinate dimension > 2, the Z/M coordinate values will be set to 0 in the envelope
        Parameters:
        minC1 - minimum first coordinate
        minC2 - minimum second coordinate
        maxC1 - maximum first coordinate
        maxC2 - maximum second coordinate
        crs - the CoordinateReferenceSystem for the coordinates of the envelope.
    • Method Detail

      • getCoordinateReferenceSystem

        public CoordinateReferenceSystem<P> getCoordinateReferenceSystem()
        Returns the CoordinateReferenceSystem for this Envelope
        Returns:
      • lowerLeft

        public P lowerLeft()
        Returns the lower-left point of this Envelope.
        Returns:
        the lower-left point
      • upperRight

        public P upperRight()
        Returns the upper-right point of this Envelope.
        Returns:
        the upper-right point
      • upperLeft

        public P upperLeft()
        Returns the upper-left point of this Envelope.
        Returns:
        the upper-left point
      • lowerRight

        public P lowerRight()
        Returns the lower-right point of this Envelope.
        Returns:
        the lower-right point
      • toArray

        public double[] toArray()
        Returns the lowerleft and upperright coordinates in 2D for this envelope.
        Returns:
        [ll.x, ll.y, ur.x, ur.y] for Cartesian envelopes; [ll.lon, ll.lat, ur.lon, ur.lat] for Geographic envelopes
      • getMinC0

        protected double getMinC0()
      • getMinC1

        protected double getMinC1()
      • getMaxC0

        protected double getMaxC0()
      • getMaxC1

        protected double getMaxC1()
      • union

        public Envelope<P> union​(Envelope<P> other)
        Creates an Envelope that is the set-theoretic union of this Envelope with the specified Envelope
        Parameters:
        other - other Envelope
        Returns:
        an Envelope that encompasses both operands.
        Throws:
        IllegalArgumentException - when the operand Envelopes don't have the same coordinate reference system.
      • intersect

        public Envelope<P> intersect​(Envelope<P> other)
        Intersects the specified Envelope with this Envelope and returns the result.
        Parameters:
        other - the Envelope to intersect with this instance
        Returns:
        the set-theoretic intersection of this Envelope and the specified Envelope.
        Throws:
        IllegalArgumentException - when the specified Envelope doesn't have the same coordinate reference system as this instance.
      • isEmpty

        public boolean isEmpty()
        Checks whether this Envelope is empty.
        Returns:
        true iff this instance is empty (the empty set).
      • within

        public boolean within​(Envelope<P> other)
        Checks whether this Envelope is contained within the specified Envelope
        Parameters:
        other - the other Envelope
        Returns:
        true iff this instance is contained within the specified Envelope
        Throws:
        IllegalArgumentException - when the specified Envelope doesn't have the same coordinate reference system as this instance.
      • extentAlongDimension

        public double extentAlongDimension​(int i)
      • contains

        public boolean contains​(Envelope other)
        Checks whether this Envelope contains the specifies Envelope.
        Parameters:
        other - the other Envelope
        Returns:
        true iff this instance contains the specified Envelope
        Throws:
        IllegalArgumentException - when the specified Envelope doesn't have the same coordinate reference system as this instance.
      • contains

        public boolean contains​(P p)
        Checks whether this Envelope contains the specifies Envelope.
        Parameters:
        p - the Point
        Returns:
        true iff this instance contains the specified Point
        Throws:
        IllegalArgumentException - when the specified Point doesn't have the same coordinate reference system as this instance.
      • intersects

        public boolean intersects​(Envelope<P> other)
        Checks whether this Envelope intersects the specifies Envelope.

        Two instances intersect when their set-theoretic intersection is non-empty.

        Parameters:
        other - the other Envelope
        Returns:
        true iff this instance intersects with the other Envelope
        Throws:
        IllegalArgumentException - when the specified Envelope doesn't have the same coordinate reference system as this instance.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object