Class Envelope2DArchived

    • Constructor Detail

      • Envelope2DArchived

        public Envelope2DArchived​(CoordinateReferenceSystem crs)
        Constructs an initially empty envelope with the defined CRS.
        Parameters:
        crs - The coordinate reference system, or null.
      • Envelope2DArchived

        public Envelope2DArchived​(Bounds envelope)
        Constructs two-dimensional envelope defined by an other Bounds.
        Parameters:
        envelope - The envelope to copy.
      • Envelope2DArchived

        public Envelope2DArchived​(CoordinateReferenceSystem crs,
                                  Rectangle2D rect)
        Constructs two-dimensional envelope defined by an other Rectangle2D.
        Parameters:
        crs - The coordinate reference system, or null.
        rect - The rectangle to copy.
      • Envelope2DArchived

        public Envelope2DArchived​(CoordinateReferenceSystem crs,
                                  double x,
                                  double y,
                                  double width,
                                  double height)
        Constructs two-dimensional envelope defined by the specified coordinates. Despite their name, the (x,y) coordinates don't need to be oriented toward (East, North). Those parameter names simply match the x and y fields. The actual axis orientations are determined by the specified CRS. See the class javadoc for details.
        Parameters:
        crs - The coordinate reference system, or null.
        x - The x minimal value.
        y - The y minimal value.
        width - The envelope width.
        height - The envelope height.
      • Envelope2DArchived

        public Envelope2DArchived​(Position2D minDP,
                                  Position2D maxDP)
                           throws MismatchedReferenceSystemException
        Constructs two-dimensional envelope defined by the specified coordinates. Despite their name, the (x,y) coordinates don't need to be oriented toward (East, North). Those parameter names simply match the x and y fields. The actual axis orientations are determined by the specified CRS. See the class javadoc for details.

        The minDP and maxDP arguments usually contains the minimal and maximal ordinate values respectively, but this is not mandatory. The ordinates will be rearanged as needed.

        Parameters:
        minDP - The fist position.
        maxDP - The second position.
        Throws:
        MismatchedReferenceSystemException - if the two positions don't use the same CRS.
        Since:
        2.4
    • Method Detail

      • setCoordinateReferenceSystem

        public void setCoordinateReferenceSystem​(CoordinateReferenceSystem crs)
        Set the coordinate reference system in which the coordinate are given.
        Parameters:
        crs - The new coordinate reference system, or null.
      • getDimension

        public final int getDimension()
        Returns the number of dimensions.
        Specified by:
        getDimension in interface Bounds
        Returns:
        The dimensionality of this envelope.
      • getLowerCorner

        public Position getLowerCorner()
        A coordinate position consisting of all the minimal ordinates for each dimension for all points within the Envelope.
        Specified by:
        getLowerCorner in interface Bounds
        Returns:
        The lower corner.
      • getUpperCorner

        public Position getUpperCorner()
        A coordinate position consisting of all the maximal ordinates for each dimension for all points within the Envelope.
        Specified by:
        getUpperCorner in interface Bounds
        Returns:
        The upper corner.
      • hashCode

        public int hashCode()
        Returns a hash value for this envelope. This value need not remain consistent between different implementations of the same class.
        Overrides:
        hashCode in class Rectangle2D
      • equals

        public boolean equals​(Object object)
        Compares the specified object with this envelope for equality.
        Overrides:
        equals in class Rectangle2D
        Parameters:
        object - The object to compare with this envelope.
        Returns:
        true if the given object is equals to this envelope.
      • boundsEquals

        public boolean boundsEquals​(Bounds that,
                                    int xDim,
                                    int yDim,
                                    double eps)
        Returns true if this envelope bounds is equals to that envelope bounds in two specified dimensions. The coordinate reference system is not compared, since it doesn't need to have the same number of dimensions.
        Parameters:
        that - The envelope to compare to.
        xDim - The dimension of that envelope to compare to the x dimension of this envelope.
        yDim - The dimension of that envelope to compare to the y dimension of this envelope.
        eps - A small tolerance number for floating point number comparaisons. This value will be scaled according this envelope width and height.
        Returns:
        true if the envelope bounds are the same (up to the specified tolerance level) in the specified dimensions, or false otherwise.
      • toString

        public String toString()
        Returns a string representation of this envelope. The default implementation is okay for occasional formatting (for example for debugging purpose). But if there is a lot of envelopes to format, users will get more control by using their own instance of CoordinateFormat.
        Overrides:
        toString in class Rectangle2D.Double
        Since:
        2.4
      • setBounds

        public void setBounds​(BoundingBox bounds)
        Description copied from interface: BoundingBox
        Sets this bounding box to be the same as the specified box.
        Specified by:
        setBounds in interface BoundingBox
        Parameters:
        bounds - The new bounds.
      • include

        public void include​(BoundingBox bounds)
        Description copied from interface: BoundingBox
        Includes the provided bounding box, expanding as necesary.
        Specified by:
        include in interface BoundingBox
        Parameters:
        bounds - The bounds to add to this geographic bounding box.
      • include

        public void include​(double x,
                            double y)
        Description copied from interface: BoundingBox
        Includes the provided coordinates, expanding as necessary. Note that there is no guarantee that the (x, x) values are oriented toward (East, North), since it depends on the envelope CRS.
        Specified by:
        include in interface BoundingBox
        Parameters:
        x - The first ordinate value.
        y - The second ordinate value.
      • intersects

        public boolean intersects​(BoundingBox bounds)
        Returns true if the interior of this bounds intersects the interior of the provided bounds.

        Note this method conflicts with RectangularShape.intersects(Rectangle2D) so you may need to call it via envelope2d.intersects( (Envelope2DArchived) bounds ) in order to correctly check that the coordinate reference systems match.

        Specified by:
        intersects in interface BoundingBox
        Parameters:
        bounds - The bounds to test for intersection.
        Returns:
        true if the two bounds intersect.
      • contains

        public boolean contains​(BoundingBox bounds)
        Description copied from interface: BoundingBox
        Returns true if the provided bounds are contained by this bounding box.
        Specified by:
        contains in interface BoundingBox
        Parameters:
        bounds - The bounds to test for inclusion.
        Returns:
        true if the given bounds is inside this bounds.
      • contains

        public boolean contains​(Position location)
        Description copied from interface: BoundingBox
        Returns true if the provided location is contained by this bounding box.
        Specified by:
        contains in interface BoundingBox
        Parameters:
        location - The direct position to test for inclusion.
        Returns:
        true if the given position is inside this bounds.
      • toBounds

        public BoundingBox toBounds​(CoordinateReferenceSystem targetCRS)
                             throws TransformException
        Description copied from interface: BoundingBox
        Transforms this box to the specified CRS and returns a new bounding box for the transformed shape. This method provides a convenient (while not always efficient) way to get minimum and maximum ordinate values toward some specific axis directions, typically East and North.

        Example: if box is a bounding box using a geographic CRS with WGS84 datum, then one can write:

         GeographicCRS targetCRS   = crsAuthorityFactory.createGeographicCRS("EPSG:4326");
         BoundingBox   targetBox   = box.toBounds(targetCRS);
         double        minEasting  = targetBox.getMinY();
         double        minNorthing = targetBox.getMinX();
         
        Be aware that "EPSG:4326" has (latitude, longitude) axis order, thus the inversion of X and Y in the above code.

        Sophesticated applications will typically provide more efficient way to perform similar transformations in their context. For example Canvas store precomputed objective to display transforms.

        Specified by:
        toBounds in interface BoundingBox
        Parameters:
        targetCRS - The target CRS for the bounding box to be returned.
        Returns:
        A new bounding box wich includes the shape of this box transformed to the specified target CRS.
        Throws:
        TransformException - if no transformation path has been found from this box CRS to the specified target CRS, or if the transformation failed for an other reason.