

PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 
Object RectangularShape Rectangle2D Rectangle2D.Double Envelope2D
public class Envelope2D
A twodimensional envelope on top of 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.
GeneralEnvelope
,
ReferencedEnvelope
,
GeographicBoundingBox
,
Serialized FormNested Class Summary 

Nested classes/interfaces inherited from class Rectangle2D 

Rectangle2D.Double, Rectangle2D.Float 
Field Summary 

Fields inherited from class Rectangle2D.Double 

height, width, x, y 
Fields inherited from class Rectangle2D 

OUT_BOTTOM, OUT_LEFT, OUT_RIGHT, OUT_TOP 
Constructor Summary  

Envelope2D()
Constructs an initially empty envelope with no CRS. 

Envelope2D(CoordinateReferenceSystem crs)
Constructs an initially empty envelope with the defined CRS. 

Envelope2D(CoordinateReferenceSystem crs,
double x,
double y,
double width,
double height)
Constructs twodimensional envelope defined by the specified coordinates. 

Envelope2D(CoordinateReferenceSystem crs,
Rectangle2D rect)
Constructs twodimensional envelope defined by an other Rectangle2D . 

Envelope2D(DirectPosition2D minDP,
DirectPosition2D maxDP)
Constructs twodimensional envelope defined by the specified coordinates. 

Envelope2D(Envelope envelope)
Constructs twodimensional envelope defined by an other Envelope . 
Method Summary  

boolean 
boundsEquals(Envelope that,
int xDim,
int yDim,
double eps)
Returns true if this envelope bounds is equals to that envelope
bounds in two specified dimensions. 
boolean 
contains(BoundingBox bounds)
Returns true if the provided bounds are contained by this bounding box. 
boolean 
contains(DirectPosition location)
Returns true if the provided location is contained by this bounding box. 
boolean 
equals(Object object)
Compares the specified object with this envelope for equality. 
double 
getCenter(int dimension)
Deprecated. Renamed as getMedian(int) . 
CoordinateReferenceSystem 
getCoordinateReferenceSystem()
Returns the coordinate reference system in which the coordinates are given. 
int 
getDimension()
Returns the number of dimensions. 
double 
getLength(int dimension)
Deprecated. Renamed as getSpan(int) . 
DirectPosition 
getLowerCorner()
A coordinate position consisting of all the minimal ordinates for each dimension for all points within the Envelope . 
double 
getMaximum(int dimension)
Returns the maximal ordinate along the specified dimension. 
double 
getMedian(int dimension)
Returns the median ordinate along the specified dimension. 
double 
getMinimum(int dimension)
Returns the minimal ordinate along the specified dimension. 
double 
getSpan(int dimension)
Returns the envelope span (typically width or height) along the specified dimension. 
DirectPosition 
getUpperCorner()
A coordinate position consisting of all the maximal ordinates for each dimension for all points within the Envelope . 
int 
hashCode()
Returns a hash value for this envelope. 
void 
include(BoundingBox bounds)
Includes the provided bounding box, expanding as necesary. 
void 
include(double x,
double y)
Includes the provided coordinates, expanding as necessary. 
boolean 
intersects(BoundingBox bounds)
Returns true if the interior of this bounds intersects the interior of the provided
bounds. 
void 
setBounds(BoundingBox bounds)
Sets this bounding box to be the same as the specified box. 
void 
setCoordinateReferenceSystem(CoordinateReferenceSystem crs)
Set the coordinate reference system in which the coordinate are given. 
BoundingBox 
toBounds(CoordinateReferenceSystem targetCRS)
Transforms this box to the specified CRS and returns a new bounding box for the transformed shape. 
String 
toString()
Returns a string representation of this envelope. 
Methods inherited from class Rectangle2D.Double 

createIntersection, createUnion, getBounds2D, getHeight, getWidth, getX, getY, isEmpty, outcode, setRect, setRect 
Methods inherited from class Rectangle2D 

add, add, add, contains, contains, getPathIterator, getPathIterator, intersect, intersects, intersectsLine, intersectsLine, outcode, setFrame, union 
Methods inherited from class RectangularShape 

clone, contains, contains, getBounds, getCenterX, getCenterY, getFrame, getMaxX, getMaxY, getMinX, getMinY, intersects, setFrame, setFrame, setFrameFromCenter, setFrameFromCenter, setFrameFromDiagonal, setFrameFromDiagonal 
Methods inherited from class Object 

finalize, getClass, notify, notifyAll, wait, wait, wait 
Methods inherited from interface BoundingBox 

contains, getHeight, getMaxX, getMaxY, getMinX, getMinY, getWidth, isEmpty 
Methods inherited from interface Cloneable 

clone 
Constructor Detail 

public Envelope2D()
Unlike a normal Envelope2D we set the width and height to 1 so we can tell the difference between:
public Envelope2D(CoordinateReferenceSystem crs)
crs
 The coordinate reference system, or null
.public Envelope2D(Envelope envelope)
Envelope
.
envelope
 The envelope to copy.public Envelope2D(CoordinateReferenceSystem crs, Rectangle2D rect)
Rectangle2D
.
crs
 The coordinate reference system, or null
.rect
 The rectangle to copy.public Envelope2D(CoordinateReferenceSystem crs, double x, double y, double width, double height)
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.public Envelope2D(DirectPosition2D minDP, DirectPosition2D maxDP) throws MismatchedReferenceSystemException
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.
minDP
 The fist position.maxDP
 The second position.
MismatchedReferenceSystemException
 if the two positions don't use the same CRS.Method Detail 

public final CoordinateReferenceSystem getCoordinateReferenceSystem()
getCoordinateReferenceSystem
in interface Envelope
null
.public void setCoordinateReferenceSystem(CoordinateReferenceSystem crs)
crs
 The new coordinate reference system, or null
.public final int getDimension()
getDimension
in interface Envelope
public DirectPosition getLowerCorner()
Envelope
.
getLowerCorner
in interface Envelope
public DirectPosition getUpperCorner()
Envelope
.
getUpperCorner
in interface Envelope
public final double getMinimum(int dimension) throws IndexOutOfBoundsException
getMinimum
in interface Envelope
dimension
 The dimension to query.
IndexOutOfBoundsException
 If the given index is out of bounds.RectangularShape.getMinX()
,
RectangularShape.getMinY()
public final double getMaximum(int dimension) throws IndexOutOfBoundsException
getMaximum
in interface Envelope
dimension
 The dimension to query.
IndexOutOfBoundsException
 If the given index is out of bounds.RectangularShape.getMaxX()
,
RectangularShape.getMaxY()
@Deprecated public final double getCenter(int dimension)
getMedian(int)
.
dimension
 The dimension to query.
public final double getMedian(int dimension) throws IndexOutOfBoundsException
(getMaximum(dimension) 
getMinimum(dimension)) / 2
.
getMedian
in interface Envelope
dimension
 The dimension to query.
IndexOutOfBoundsException
 If the given index is out of bounds.RectangularShape.getCenterX()
,
RectangularShape.getCenterY()
@Deprecated public final double getLength(int dimension)
getSpan(int)
.
dimension
 The dimension to query.
public final double getSpan(int dimension) throws IndexOutOfBoundsException
getMaximum(dimension)  getMinimum(dimension)
.
getSpan
in interface Envelope
dimension
 The dimension to query.
IndexOutOfBoundsException
 If the given index is out of bounds.RectangularShape.getWidth()
,
RectangularShape.getHeight()
public int hashCode()
hashCode
in class Rectangle2D
public boolean equals(Object object)
equals
in class Rectangle2D
object
 The object to compare with this envelope.
true
if the given object is equals to this envelope.public boolean boundsEquals(Envelope that, int xDim, int yDim, double eps)
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.
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.
true
if the envelope bounds are the same (up to the specified tolerance
level) in the specified dimensions, or false
otherwise.public String toString()
CoordinateFormat
.
toString
in class Rectangle2D.Double
public void setBounds(BoundingBox bounds)
BoundingBox
setBounds
in interface BoundingBox
bounds
 The new bounds.public void include(BoundingBox bounds)
BoundingBox
include
in interface BoundingBox
bounds
 The bounds to add to this geographic bounding box.public void include(double x, double y)
BoundingBox
include
in interface BoundingBox
x
 The first ordinate value.y
 The second ordinate value.public boolean intersects(BoundingBox bounds)
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( (Envelope2D) bounds ) in order to correctly check that
the coordinate reference systems match.
intersects
in interface BoundingBox
bounds
 The bounds to test for intersection.
true
if the two bounds intersect.public boolean contains(BoundingBox bounds)
BoundingBox
true
if the provided bounds are contained by this bounding box.
contains
in interface BoundingBox
bounds
 The bounds to test for inclusion.
true
if the given bounds is inside this bounds.public boolean contains(DirectPosition location)
BoundingBox
true
if the provided location is contained by this bounding box.
contains
in interface BoundingBox
location
 The direct position to test for inclusion.
true
if the given position is inside this bounds.public BoundingBox toBounds(CoordinateReferenceSystem targetCRS) throws TransformException
BoundingBox
Example: if box
is 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.
Sophesticated applications will typically provide more efficient way to perform similar transformations in their context. For example Canvas store precomputed objective to display transforms.
toBounds
in interface BoundingBox
targetCRS
 The target CRS for the bounding box to be returned.
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.


PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 