public class ReferencedEnvelope extends Envelope implements Envelope, BoundingBox
Envelope2D
,
GeneralEnvelope
,
GeographicBoundingBox
,
Serialized FormModifier and Type | Field and Description |
---|---|
protected CoordinateReferenceSystem |
crs
The coordinate reference system, or
null . |
static ReferencedEnvelope |
EVERYTHING
A ReferencedEnvelope containing "everything"
|
Constructor and Description |
---|
ReferencedEnvelope()
Creates a null envelope with a null coordinate reference system.
|
ReferencedEnvelope(BoundingBox bbox)
Creates a new envelope from an existing bounding box.
|
ReferencedEnvelope(CoordinateReferenceSystem crs)
Creates a null envelope with the specified coordinate reference system.
|
ReferencedEnvelope(double x1,
double x2,
double y1,
double y2,
CoordinateReferenceSystem crs)
Creates an envelope for a region defined by maximum and minimum values.
|
ReferencedEnvelope(Envelope envelope)
Creates a new envelope from an existing OGC envelope.
|
ReferencedEnvelope(Envelope envelope,
CoordinateReferenceSystem crs)
Creates a new envelope from an existing JTS envelope.
|
ReferencedEnvelope(Rectangle2D rectangle,
CoordinateReferenceSystem crs)
Creates an envelope for a Java2D rectangle.
|
ReferencedEnvelope(ReferencedEnvelope envelope)
Creates a new envelope from an existing envelope.
|
Modifier and Type | Method and Description |
---|---|
boolean |
boundsEquals2D(Envelope other,
double eps)
Compare the bounds of this envelope with those of another.
|
protected void |
checkCoordinateReferenceSystemDimension()
Convenience method for checking coordinate reference system validity.
|
boolean |
contains(BoundingBox bbox)
Returns
true if the provided bounds are contained by this bounding box. |
boolean |
contains(DirectPosition pos)
Returns
true if the provided location is contained by this bounding box. |
static ReferencedEnvelope |
create(CoordinateReferenceSystem crs)
Factory method to create the correct ReferencedEnvelope implementation for the provided
CoordinateReferenceSystem.
|
static ReferencedEnvelope |
create(Envelope env,
CoordinateReferenceSystem crs)
Utility method to create a ReferencedEnvelope from an opengis Envelope class, supporting 2d
as well as 3d envelopes (returning the right class).
|
static ReferencedEnvelope |
create(Envelope env,
CoordinateReferenceSystem crs)
Utility method to create a ReferencedEnvelope from an JTS Envelope class, supporting 2d as
well as 3d envelopes (returning the right class).
|
static ReferencedEnvelope |
create(Rectangle2D rectangle,
CoordinateReferenceSystem crs)
Utility method to create a ReferencedEnvelope from a Java2D Rectangle class, supporting empty
rectangles.
|
static ReferencedEnvelope |
create(ReferencedEnvelope original)
Factory method to create the correct ReferencedEnvelope.
|
static ReferencedEnvelope |
create(ReferencedEnvelope env,
CoordinateReferenceSystem crs)
Utility method to create a ReferencedEnvelope from an opengis Envelope class, supporting 2d
as well as 3d envelopes (returning the right class).
|
CoordinateReferenceSystem |
crs()
Deprecated.
Use
getCoordinateReferenceSystem() , since it is the method inherited from
the interface. |
protected void |
ensureCompatibleReferenceSystem(BoundingBox bbox)
Make sure that the specified bounding box uses the same CRS than this one.
|
protected void |
ensureCompatibleReferenceSystem(DirectPosition location)
Make sure that the specified location uses the same CRS as this one.
|
boolean |
equals(Object object)
Compares the specified object with this envelope for equality.
|
void |
expandToInclude(DirectPosition pt)
Expand to include the provided DirectPosition
|
void |
expandToInclude(Envelope other)
Include the provided envelope, expanding as necessary.
|
double |
getCenter(int dimension)
Deprecated.
Use
getMedian(int) . |
CoordinateReferenceSystem |
getCoordinateReferenceSystem()
Returns the coordinate reference system associated with this envelope.
|
int |
getDimension()
Returns the number of dimensions.
|
double |
getLength(int dimension)
Deprecated.
Use
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 center ordinate along the specified dimension.
|
double |
getMinimum(int dimension)
Returns the minimal ordinate along the specified dimension.
|
double |
getSpan(int dimension)
Returns the envelope length 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 bbox)
Include the provided bounding box, expanding as necessary.
|
void |
include(double x,
double y)
Include the provided coordinates, expanding as necessary.
|
void |
init(BoundingBox bounds)
Sets this envelope to the specified bounding box.
|
ReferencedEnvelope |
intersection(Envelope env)
Check if this bounding box intersects the provided bounds.
|
boolean |
intersects(BoundingBox bbox)
Check if this bounding box intersects the provided bounds.
|
boolean |
isEmpty()
Returns
true if lengths along all dimension are zero. |
double |
maxX()
Deprecated.
Use
Envelope.getMaxX() . |
double |
maxY()
Deprecated.
Use
Envelope.getMaxY() . |
double |
minX()
Deprecated.
Use
Envelope.getMinX() . |
double |
minY()
Deprecated.
Use
Envelope.getMinY() . |
static ReferencedEnvelope |
reference(Envelope e)
Cast to a ReferencedEnvelope (used to ensure that an Envelope is a ReferencedEnvelope).
|
static ReferencedEnvelope |
reference(Envelope env)
Cast to a ReferencedEnvelope (used to ensure that an Envelope if a ReferencedEnvelope).
|
static ReferencedEnvelope |
reference(ReferencedEnvelope e)
Utility method to ensure that an BoundingBox in a ReferencedEnvelope.
|
void |
setBounds(BoundingBox bbox)
Initialize the bounding box with another bounding box.
|
BoundingBox |
toBounds(CoordinateReferenceSystem targetCRS)
Returns a new bounding box which contains the transformed shape of this bounding box.
|
String |
toString()
Returns a string representation of this envelope.
|
ReferencedEnvelope |
transform(CoordinateReferenceSystem targetCRS,
boolean lenient)
Transforms the referenced envelope to the specified coordinate reference system.
|
ReferencedEnvelope |
transform(CoordinateReferenceSystem targetCRS,
boolean lenient,
int numPointsForTransformation)
Transforms the referenced envelope to the specified coordinate reference system using the
specified amount of points.
|
centre, compareTo, contains, contains, contains, covers, covers, covers, distance, expandBy, expandBy, expandToInclude, expandToInclude, getArea, getHeight, getMaxX, getMaxY, getMinX, getMinY, getWidth, init, init, init, init, init, intersects, intersects, intersects, intersects, intersects, intersects, isNull, maxExtent, minExtent, overlaps, overlaps, overlaps, setToNull, translate
public static ReferencedEnvelope EVERYTHING
protected CoordinateReferenceSystem crs
null
.public ReferencedEnvelope()
public ReferencedEnvelope(CoordinateReferenceSystem crs) throws MismatchedDimensionException
crs
- The coordinate reference system.MismatchedDimensionException
- if the CRS dimension is not valid.public ReferencedEnvelope(double x1, double x2, double y1, double y2, CoordinateReferenceSystem crs) throws MismatchedDimensionException
x1
- The first x-value.x2
- The second x-value.y1
- The first y-value.y2
- The second y-value.crs
- The coordinate reference system.MismatchedDimensionException
- if the CRS dimension is not valid.public ReferencedEnvelope(Rectangle2D rectangle, CoordinateReferenceSystem crs) throws MismatchedDimensionException
NOTE: if the rectangle is empty, the resulting ReferencedEnvelope will not be. In case
this is needed use ReferencedEnvelope.create(rectangle, crs)
rectangle
- The rectangle.crs
- The coordinate reference system.MismatchedDimensionException
- if the CRS dimension is not valid.public ReferencedEnvelope(ReferencedEnvelope envelope) throws MismatchedDimensionException
envelope
- The envelope to initialize fromMismatchedDimensionException
- if the CRS dimension is not valid.public ReferencedEnvelope(BoundingBox bbox) throws MismatchedDimensionException
NOTE: if the bounding box is empty, the resulting ReferencedEnvelope will not be. In case
this is needed use ReferencedEnvelope.create(bbox, bbox.getCoordinateReferenceSystem())
bbox
- The bounding box to initialize from.MismatchedDimensionException
- if the CRS dimension is not valid.public ReferencedEnvelope(Envelope envelope) throws MismatchedDimensionException
NOTE: if the envelope is empty, the resulting ReferencedEnvelope will not be. In case this
is needed use ReferencedEnvelope.create(envelope, envelope.getCoordinateReferenceSystem())
envelope
- The envelope to initialize from.MismatchedDimensionException
- if the CRS dimension is not valid.public ReferencedEnvelope(Envelope envelope, CoordinateReferenceSystem crs) throws MismatchedDimensionException
envelope
- The envelope to initialize from.crs
- The coordinate reference system.MismatchedDimensionExceptionif
- the CRS dimension is not valid.MismatchedDimensionException
public void init(BoundingBox bounds)
protected void checkCoordinateReferenceSystemDimension() throws MismatchedDimensionException
IllegalArgumentException
- if the CRS dimension is not valid.MismatchedDimensionException
protected void ensureCompatibleReferenceSystem(BoundingBox bbox) throws MismatchedReferenceSystemException
bbox
- The other bounding box to test for compatibility.MismatchedReferenceSystemException
- if the CRS are incompatible.protected void ensureCompatibleReferenceSystem(DirectPosition location)
location
- MismatchedReferenceSystemException
- if the CRS are incompatible.public CoordinateReferenceSystem getCoordinateReferenceSystem()
getCoordinateReferenceSystem
in interface Envelope
null
if unknown.public CoordinateReferenceSystem crs()
getCoordinateReferenceSystem()
, since it is the method inherited from
the interface.public int getDimension()
getDimension
in interface Envelope
public double getMinimum(int dimension)
getMinimum
in interface Envelope
dimension
- The dimension for which to obtain the ordinate value.RectangularShape.getMinX()
,
RectangularShape.getMinY()
public double minX()
Envelope.getMinX()
.public double minY()
Envelope.getMinY()
.public double getMaximum(int dimension)
getMaximum
in interface Envelope
dimension
- The dimension for which to obtain the ordinate value.RectangularShape.getMaxX()
,
RectangularShape.getMaxY()
public double maxX()
Envelope.getMaxX()
.public double maxY()
Envelope.getMaxY()
.public double getCenter(int dimension)
getMedian(int)
.public double getMedian(int dimension)
getMedian
in interface Envelope
dimension
- The dimension for which to obtain the ordinate value.RectangularShape.getCenterX()
,
RectangularShape.getCenterY()
public double getLength(int dimension)
getSpan(int)
.public double getSpan(int dimension)
getSpan
in interface Envelope
dimension
- The dimension for which to obtain the ordinate value.RectangularShape.getWidth()
,
RectangularShape.getHeight()
public DirectPosition getLowerCorner()
Envelope
.getLowerCorner
in interface Envelope
public DirectPosition getUpperCorner()
Envelope
.getUpperCorner
in interface Envelope
public boolean isEmpty()
true
if lengths along all dimension are zero.isEmpty
in interface BoundingBox
true
if this bounding box is empty.public boolean contains(DirectPosition pos)
true
if the provided location is contained by this bounding box.contains
in interface BoundingBox
pos
- The direct position to test for inclusion.true
if the given position is inside this bounds.public boolean contains(BoundingBox bbox)
true
if the provided bounds are contained by this bounding box.contains
in interface BoundingBox
bbox
- The bounds to test for inclusion.true
if the given bounds is inside this bounds.public boolean intersects(BoundingBox bbox)
intersects
in interface BoundingBox
bbox
- The bounds to test for intersection.true
if the two bounds intersect.public ReferencedEnvelope intersection(Envelope env)
intersection
in class Envelope
public void include(BoundingBox bbox)
include
in interface BoundingBox
bbox
- The bounds to add to this geographic bounding box.public void expandToInclude(DirectPosition pt)
pt
- public void expandToInclude(Envelope other)
expandToInclude
in class Envelope
public void include(double x, double y)
include
in interface BoundingBox
x
- The first ordinate value.y
- The second ordinate value.public void setBounds(BoundingBox bbox)
setBounds
in interface BoundingBox
bbox
- The new bounds.public BoundingBox toBounds(CoordinateReferenceSystem targetCRS) throws TransformException
transform
method.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.public ReferencedEnvelope transform(CoordinateReferenceSystem targetCRS, boolean lenient) throws TransformException, FactoryException
This method can handle the case where the envelope contains the North or South pole, or when it cross the ±180� longitude.
targetCRS
- The target coordinate reference system.lenient
- true
if datum shift should be applied even if there is insuffisient
information. Otherwise (if false
), an exception is thrown in such case.FactoryException
- if the math transform can't be determined.TransformException
- if at least one coordinate can't be transformed.CRS.transform(CoordinateOperation, org.opengis.geometry.Envelope)
public ReferencedEnvelope transform(CoordinateReferenceSystem targetCRS, boolean lenient, int numPointsForTransformation) throws TransformException, FactoryException
This method can handle the case where the envelope contains the North or South pole, or when it cross the ±180� longitude.
targetCRS
- The target coordinate reference system.lenient
- true
if datum shift should be applied even if there is insuffisient
information. Otherwise (if false
), an exception is thrown in such case.numPointsForTransformation
- The number of points to use for sampling the envelope.FactoryException
- if the math transform can't be determined.TransformException
- if at least one coordinate can't be transformed.CRS.transform(CoordinateOperation, org.opengis.geometry.Envelope)
public int hashCode()
hashCode
in class Envelope
public boolean equals(Object object)
equals
in class Envelope
public boolean boundsEquals2D(Envelope other, double eps)
Note: in this test:
other
- other envelopeeps
- a small tolerance factor (e.g. 1.0e-6d) which will be scaled relative to this
envlope's width and heightpublic String toString()
toString
in class Envelope
public static ReferencedEnvelope create(ReferencedEnvelope original)
original
- ReferencedEnvelope being duplicatedpublic static ReferencedEnvelope create(CoordinateReferenceSystem crs)
crs
- CoordinateReferenceSystem used to select ReferencedEnvelope implementationpublic static ReferencedEnvelope create(Envelope env, CoordinateReferenceSystem crs)
env
- The opgenis Envelope object#reference(org.opengis.geometry.Envelope)}
public static ReferencedEnvelope create(ReferencedEnvelope env, CoordinateReferenceSystem crs)
env
- The opgenis Envelope objectpublic static ReferencedEnvelope create(Envelope env, CoordinateReferenceSystem crs)
env
- The JTS Envelope objectpublic static ReferencedEnvelope reference(Envelope e)
This method first checks if e is an instanceof ReferencedEnvelope
, if it
is, itself is returned. If not new ReferencedEnvelpe(e,null)
is returned.
If e is null, null is returned.
e
- The envelope. Can be null.public static ReferencedEnvelope reference(ReferencedEnvelope e)
This method first checks if e is an instanceof ReferencedEnvelope
, if it
is, itself is returned. If not new ReferencedEnvelpe(e)
is returned.
e
- The envelope.public static ReferencedEnvelope reference(Envelope env)
env
- The opgenis Envelope objectpublic static ReferencedEnvelope create(Rectangle2D rectangle, CoordinateReferenceSystem crs)
rectangle
- The Java2D Rectangle objectCopyright © 1996–2019 Geotools. All rights reserved.