Class Envelope2DArchived
- All Implemented Interfaces:
Shape,Serializable,Cloneable,BoundingBox,Bounds,Cloneable
Rectangle2D. This implementation is provided for interoperability
between Java2D and GeoAPI.
Note: This class inherits x and y fields. But despite their names, they don't need to be oriented toward East and North respectively. The (x,y) axis can have any orientation and should be understood as "ordinate 0" and "ordinate 1" values instead. This is not specific to this implementation; in Java2D too, the visual axis orientation depend on the affine transform in the graphics context.
- Since:
- 2.1
- Author:
- Martin Desruisseaux (IRD)
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class Rectangle2D
Rectangle2D.Double, Rectangle2D.Float -
Field Summary
Fields inherited from class Rectangle2D.Double
height, width, x, yFields inherited from class Rectangle2D
OUT_BOTTOM, OUT_LEFT, OUT_RIGHT, OUT_TOP -
Constructor Summary
ConstructorsConstructorDescriptionConstructs an initially empty envelope with no CRS.Envelope2DArchived(Bounds envelope) Constructs two-dimensional envelope defined by an otherBounds.Constructs an initially empty envelope with the defined CRS.Envelope2DArchived(CoordinateReferenceSystem crs, double x, double y, double width, double height) Constructs two-dimensional envelope defined by the specified coordinates.Constructs two-dimensional envelope defined by an otherRectangle2D.Envelope2DArchived(Position2D minDP, Position2D maxDP) Constructs two-dimensional envelope defined by the specified coordinates. -
Method Summary
Modifier and TypeMethodDescriptionbooleanboundsEquals(Bounds that, int xDim, int yDim, double eps) Returnstrueifthisenvelope bounds is equals tothatenvelope bounds in two specified dimensions.booleancontains(BoundingBox bounds) Returnstrueif the provided bounds are contained by this bounding box.booleanReturnstrueif the provided location is contained by this bounding box.booleanCompares the specified object with this envelope for equality.Returns the coordinate reference system in which the coordinates are given.final intReturns the number of dimensions.A coordinate position consisting of all the minimal ordinates for each dimension for all points within theEnvelope.final doublegetMaximum(int dimension) Returns the maximal ordinate along the specified dimension.final doublegetMedian(int dimension) Returns the median ordinate along the specified dimension.final doublegetMinimum(int dimension) Returns the minimal ordinate along the specified dimension.final doublegetSpan(int dimension) Returns the envelope span (typically width or height) along the specified dimension.A coordinate position consisting of all the maximal ordinates for each dimension for all points within theEnvelope.inthashCode()Returns a hash value for this envelope.voidinclude(double x, double y) Includes the provided coordinates, expanding as necessary.voidinclude(BoundingBox bounds) Includes the provided bounding box, expanding as necessary.booleanintersects(BoundingBox bounds) Returnstrueif the interior of this bounds intersects the interior of the provided bounds.voidsetBounds(BoundingBox bounds) Sets this bounding box to be the same as the specified box.voidSet the coordinate reference system in which the coordinate are given.toBounds(CoordinateReferenceSystem targetCRS) Transforms this box to the specified CRS and returns a new bounding box for the transformed shape.toString()Returns a string representation of this envelope.Methods inherited from class Rectangle2D.Double
createIntersection, createUnion, getBounds2D, getHeight, getWidth, getX, getY, isEmpty, outcode, setRect, setRectMethods inherited from class Rectangle2D
add, add, add, contains, contains, getPathIterator, getPathIterator, intersect, intersects, intersectsLine, intersectsLine, outcode, setFrame, unionMethods inherited from class RectangularShape
clone, contains, contains, getBounds, getCenterX, getCenterY, getFrame, getMaxX, getMaxY, getMinX, getMinY, intersects, setFrame, setFrame, setFrameFromCenter, setFrameFromCenter, setFrameFromDiagonal, setFrameFromDiagonal
-
Constructor Details
-
Envelope2DArchived
public Envelope2DArchived()Constructs an initially empty envelope with no CRS.Unlike a normal Envelope2DArchived we set the width and height to -1 so we can tell the difference between:
- Since:
- 2.5
-
Envelope2DArchived
Constructs an initially empty envelope with the defined CRS.- Parameters:
crs- The coordinate reference system, ornull.
-
Envelope2DArchived
Constructs two-dimensional envelope defined by an otherBounds.- Parameters:
envelope- The envelope to copy.
-
Envelope2DArchived
Constructs two-dimensional envelope defined by an otherRectangle2D.- Parameters:
crs- The coordinate reference system, ornull.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, ornull.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
minDPandmaxDParguments 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 Details
-
getCoordinateReferenceSystem
Returns the coordinate reference system in which the coordinates are given.- Specified by:
getCoordinateReferenceSystemin interfaceBounds- Returns:
- The coordinate reference system, or
null.
-
setCoordinateReferenceSystem
Set the coordinate reference system in which the coordinate are given.- Parameters:
crs- The new coordinate reference system, ornull.
-
getDimension
public final int getDimension()Returns the number of dimensions.- Specified by:
getDimensionin interfaceBounds- Returns:
- The dimensionality of this envelope.
-
getLowerCorner
A coordinate position consisting of all the minimal ordinates for each dimension for all points within theEnvelope.- Specified by:
getLowerCornerin interfaceBounds- Returns:
- The lower corner.
-
getUpperCorner
A coordinate position consisting of all the maximal ordinates for each dimension for all points within theEnvelope.- Specified by:
getUpperCornerin interfaceBounds- Returns:
- The upper corner.
-
getMinimum
Returns the minimal ordinate along the specified dimension.- Specified by:
getMinimumin interfaceBounds- Parameters:
dimension- The dimension to query.- Returns:
- The minimal ordinate value along the given dimension.
- Throws:
IndexOutOfBoundsException- If the given index is out of bounds.- See Also:
-
getMaximum
Returns the maximal ordinate along the specified dimension.- Specified by:
getMaximumin interfaceBounds- Parameters:
dimension- The dimension to query.- Returns:
- The maximal ordinate value along the given dimension.
- Throws:
IndexOutOfBoundsException- If the given index is out of bounds.- See Also:
-
getMedian
Returns the median ordinate along the specified dimension. The result should be equals (minus rounding error) to(getMaximum(dimension) - getMinimum(dimension)) / 2.- Specified by:
getMedianin interfaceBounds- Parameters:
dimension- The dimension to query.- Returns:
- The mid ordinate value along the given dimension.
- Throws:
IndexOutOfBoundsException- If the given index is out of bounds.- See Also:
-
getSpan
Returns the envelope span (typically width or height) along the specified dimension. The result should be equals (minus rounding error) togetMaximum(dimension) - getMinimum(dimension).- Specified by:
getSpanin interfaceBounds- Parameters:
dimension- The dimension to query.- Returns:
- The difference along maximal and minimal ordinates in the given dimension.
- Throws:
IndexOutOfBoundsException- If the given index is out of bounds.- See Also:
-
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:
hashCodein classRectangle2D
-
equals
Compares the specified object with this envelope for equality.- Overrides:
equalsin classRectangle2D- Parameters:
object- The object to compare with this envelope.- Returns:
trueif the given object is equals to this envelope.
-
boundsEquals
Returnstrueifthisenvelope bounds is equals tothatenvelope 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 ofthatenvelope to compare to the x dimension ofthisenvelope.yDim- The dimension ofthatenvelope to compare to the y dimension ofthisenvelope.eps- A small tolerance number for floating point number comparaisons. This value will be scaled according this envelope width and height.- Returns:
trueif the envelope bounds are the same (up to the specified tolerance level) in the specified dimensions, orfalseotherwise.
-
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 ofCoordinateFormat.- Overrides:
toStringin classRectangle2D.Double- Since:
- 2.4
-
setBounds
Description copied from interface:BoundingBoxSets this bounding box to be the same as the specified box.- Specified by:
setBoundsin interfaceBoundingBox- Parameters:
bounds- The new bounds.
-
include
Description copied from interface:BoundingBoxIncludes the provided bounding box, expanding as necessary.- Specified by:
includein interfaceBoundingBox- Parameters:
bounds- The bounds to add to this geographic bounding box.
-
include
public void include(double x, double y) Description copied from interface:BoundingBoxIncludes 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:
includein interfaceBoundingBox- Parameters:
x- The first ordinate value.y- The second ordinate value.
-
intersects
Returnstrueif 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:
intersectsin interfaceBoundingBox- Parameters:
bounds- The bounds to test for intersection.- Returns:
trueif the two bounds intersect.
-
contains
Description copied from interface:BoundingBoxReturnstrueif the provided bounds are contained by this bounding box.- Specified by:
containsin interfaceBoundingBox- Parameters:
bounds- The bounds to test for inclusion.- Returns:
trueif the given bounds is inside this bounds.
-
contains
Description copied from interface:BoundingBoxReturnstrueif the provided location is contained by this bounding box.- Specified by:
containsin interfaceBoundingBox- Parameters:
location- The direct position to test for inclusion.- Returns:
trueif the given position is inside this bounds.
-
toBounds
Description copied from interface:BoundingBoxTransforms 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
boxis a bounding box using a geographic CRS with WGS84 datum, then one can write:
Be aware thatGeographicCRS targetCRS = crsAuthorityFactory.createGeographicCRS("EPSG:4326"); BoundingBox targetBox = box.toBounds(targetCRS); double minEasting = targetBox.getMinY(); double minNorthing = targetBox.getMinX();
"EPSG:4326"has (latitude, longitude) axis order, thus the inversion of X and Y in the above code.Sophisticated applications will typically provide more efficient way to perform similar transformations in their context. This method is provided for convenience in simple cases.
- Specified by:
toBoundsin interfaceBoundingBox- 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.
-