Class ReferencedEnvelope3D
- All Implemented Interfaces:
Serializable
,Comparable
,BoundingBox
,BoundingBox3D
,Bounds
- Author:
- Niels Charlier
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic ReferencedEnvelope3D
A ReferencedEnvelope containing "everything"Fields inherited from class ReferencedEnvelope
crs
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a null envelope with a null coordinate reference system.ReferencedEnvelope3D
(double x1, double x2, double y1, double y2, double z1, double z2, CoordinateReferenceSystem crs) Creates an envelope for a region defined by maximum and minimum values.Creates a new envelope from an existing bounding box.ReferencedEnvelope3D
(Bounds envelope) Creates a new envelope from an existing OGC envelope.Creates a null envelope with the specified coordinate reference system.ReferencedEnvelope3D
(ReferencedEnvelope3D envelope) Creates a new envelope from an existing envelope.ReferencedEnvelope3D
(ReferencedEnvelope3D envelope, CoordinateReferenceSystem crs) Creates a new envelope from an existing JTS envelope.ReferencedEnvelope3D
(Envelope envelope, CoordinateReferenceSystem crs) Creates a new envelope from an existing JTS envelope. -
Method Summary
Modifier and TypeMethodDescriptionboolean
boundsEquals3D
(Bounds other, double eps) Compare the bounds of this envelope with those of another.centre()
Computes the coordinate of the centre of this envelope (as long as it is non-nullboolean
contains
(double x, double y, double z) Tests if the given point lies in or on the envelope.boolean
contains
(BoundingBox3D bbox) Returnstrue
if the provided bounds are contained by this bounding box.boolean
Returnstrue
if the provided location is contained by this bounding box.boolean
Tests if the given point lies in or on the envelope.boolean
covers
(double x, double y, double z) Tests if the given point lies in or on the envelope.boolean
covers
(ReferencedEnvelope3D other) Tests if theEnvelope other
lies wholely inside thisEnvelope
(inclusive of the boundary).boolean
covers
(Coordinate p) Tests if the given point lies in or on the envelope.double
Computes the distance between this and anotherEnvelope
.boolean
Compares the specified object with this envelope for equality.void
expandBy
(double distance) Expands this envelope by a given distance in all directions.void
expandBy
(double deltaX, double deltaY, double deltaZ) Expands this envelope by a given distance in all directions.void
expandToInclude
(double x, double y, double z) Enlarges thisEnvelope
so that it contains the given point.void
Expand to include the provided DirectPositionvoid
Enlarges thisEnvelope
so that it contains theother
Envelope.void
Enlarges thisEnvelope
so that it contains the givenCoordinate
.double
getDepth()
Returns the difference between the maximum and minimum z values.int
Returns the number of dimensions.A coordinate position consisting of all the minimal ordinates for each dimension for all points within theEnvelope
.double
getMaximum
(int dimension) Returns the maximal ordinate along the specified dimension.double
getMaxZ()
Returns theEnvelope
s maximum z-value. min z > max z indicates that this is a nullEnvelope
.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
getMinZ()
Returns theEnvelope
s minimum z-value. min z > max z indicates that this is a nullEnvelope
.double
getSpan
(int dimension) Returns the envelope length along the specified dimension.A coordinate position consisting of all the maximal ordinates for each dimension for all points within theEnvelope
.double
Gets the volume of this envelope.int
hashCode()
Returns a hash value for this envelope.void
include
(double x, double y) Include the provided coordinates, expanding as necessary.void
include
(double x, double y, double z) Include the provided coordinates, expanding as necessary.void
include
(BoundingBox3D bbox) Include the provided bounding box, expanding as necessary.void
init()
Initialize to a nullEnvelope
.void
init
(double x1, double x2, double y1, double y2, double z1, double z2) Initialize anEnvelope
for a region defined by maximum and minimum values.void
init
(BoundingBox bounds) Sets this envelope to the specified bounding box.void
init
(ReferencedEnvelope3D env) Initialize anEnvelope
from an existing 3D Envelope.void
init
(Coordinate p) Initialize anEnvelope
to a region defined by a single Coordinate.void
init
(Coordinate p1, Coordinate p2) Initialize anEnvelope
to a region defined by two Coordinates.void
Computes the intersection of twoEnvelope
s.boolean
intersects
(double x, double y, double z) Check if the point(x, y)
overlaps (lies inside) the region of thisEnvelope
.boolean
intersects
(BoundingBox3D bbox) Check if this bounding box intersects the provided bounds.boolean
intersects
(ReferencedEnvelope3D other) Check if the region defined byother
overlaps (intersects) the region of thisEnvelope
.boolean
Check if the pointp
overlaps (lies inside) the region of thisEnvelope
.static boolean
intersects
(Coordinate p1, Coordinate p2, Coordinate q) Test the point q to see whether it intersects the Envelope defined by p1-p2static boolean
intersects
(Coordinate p1, Coordinate p2, Coordinate q1, Coordinate q2) Test the envelope defined by p1-p2 for intersection with the envelope defined by q1-q2boolean
isEmpty()
Returnstrue
if lengths along all dimension are zero.double
Gets the maximum extent of this envelope across both dimensions.double
Gets the minimum extent of this envelope across all three dimensions.boolean
Deprecated.Use #intersects instead.void
setBounds
(BoundingBox3D bbox) Initialize the bounding box with another bounding box.void
Makes thisEnvelope
a "null" envelope, that is, the envelope of the empty geometry.toBounds
(CoordinateReferenceSystem targetCRS) Returns a new bounding box which contains the transformed shape of this bounding box.transform
(CoordinateReferenceSystem targetCRS, boolean lenient) Transforms the referenced envelope to the specified coordinate reference system.transform
(CoordinateReferenceSystem targetCRS, boolean lenient, int numPointsForTransformation) Transforms the referenced envelope to the specified coordinate reference system using the specified amount of points.void
translate
(double transX, double transY, double transZ) Translates this envelope by given amounts in the X and Y direction.Methods inherited from class ReferencedEnvelope
boundsEquals, boundsEquals2D, boundsEquals2D, checkCoordinateReferenceSystemDimension, contains, contains, create, create, create, create, create, ensureCompatibleReferenceSystem, ensureCompatibleReferenceSystem, envelope, expandToInclude, expandToInclude, getCenterX, getCenterY, getCoordinateReferenceSystem, include, intersection, intersects, rect, rect, rect, rect, reference, reference, reference, setBounds, setCoordinateReferenceSystem, setFrame, setFrameFromCenter, setFrameFromDiagonal, toString
Methods inherited from class Envelope
compareTo, contains, contains, containsProperly, copy, covers, covers, disjoint, distance, expandBy, expandToInclude, getArea, getDiameter, getHeight, getMaxX, getMaxY, getMinX, getMinY, getWidth, init, intersects, intersects, intersects, isNull, overlaps, overlaps, translate
Methods inherited from interface BoundingBox
contains, contains, getHeight, getMaxX, getMaxY, getMinX, getMinY, getWidth, include, intersects, setBounds
Methods inherited from interface Bounds
getCoordinateReferenceSystem
-
Field Details
-
EVERYTHING
A ReferencedEnvelope containing "everything"
-
-
Constructor Details
-
ReferencedEnvelope3D
public ReferencedEnvelope3D()Creates a null envelope with a null coordinate reference system. -
ReferencedEnvelope3D
Creates a null envelope with the specified coordinate reference system.- Parameters:
crs
- The coordinate reference system.- Throws:
MismatchedDimensionException
- if the CRS dimension is not valid.
-
ReferencedEnvelope3D
public ReferencedEnvelope3D(double x1, double x2, double y1, double y2, double z1, double z2, CoordinateReferenceSystem crs) throws MismatchedDimensionException Creates an envelope for a region defined by maximum and minimum values.- Parameters:
x1
- The first x-value.x2
- The second x-value.y1
- The first y-value.y2
- The second y-value.z1
- The first y-value.z2
- The second y-value.crs
- The coordinate reference system.- Throws:
MismatchedDimensionException
- if the CRS dimension is not valid.
-
ReferencedEnvelope3D
Creates a new envelope from an existing envelope.- Parameters:
envelope
- The envelope to initialize from- Throws:
MismatchedDimensionException
- if the CRS dimension is not valid.
-
ReferencedEnvelope3D
Creates a new envelope from an existing bounding box.NOTE: if the bounding box is empty, the resulting ReferencedEnvelope will not be. In case this is needed use
ReferencedEnvelope.create(bbox, bbox.getCoordinateReferenceSystem())
- Parameters:
bbox
- The bounding box to initialize from.- Throws:
MismatchedDimensionException
- if the CRS dimension is not valid.
-
ReferencedEnvelope3D
public ReferencedEnvelope3D(Envelope envelope, CoordinateReferenceSystem crs) throws MismatchedDimensionException Creates a new envelope from an existing JTS envelope.- Parameters:
envelope
- The envelope to initialize from.crs
- The coordinate reference system.- Throws:
MismatchedDimensionExceptionif
- the CRS dimension is not valid.MismatchedDimensionException
-
ReferencedEnvelope3D
Creates a new envelope from an existing OGC envelope.NOTE: if the envelope is empty, the resulting ReferencedEnvelope will not be. In case this is needed use
ReferencedEnvelope.create(envelope, envelope.getCoordinateReferenceSystem())
- Parameters:
envelope
- The envelope to initialize from.- Throws:
MismatchedDimensionException
- if the CRS dimension is not valid.
-
ReferencedEnvelope3D
public ReferencedEnvelope3D(ReferencedEnvelope3D envelope, CoordinateReferenceSystem crs) throws MismatchedDimensionException Creates a new envelope from an existing JTS envelope.- Parameters:
envelope
- The envelope to initialize from.crs
- The coordinate reference system.- Throws:
MismatchedDimensionExceptionif
- the CRS dimension is not valid.MismatchedDimensionException
-
-
Method Details
-
intersects
Test the point q to see whether it intersects the Envelope defined by p1-p2- Parameters:
p1
- one extremal point of the envelopep2
- another extremal point of the envelopeq
- the point to test for intersection- Returns:
true
if q intersects the envelope p1-p2
-
intersects
Test the envelope defined by p1-p2 for intersection with the envelope defined by q1-q2- Parameters:
p1
- one extremal point of the envelope Pp2
- another extremal point of the envelope Pq1
- one extremal point of the envelope Qq2
- another extremal point of the envelope Q- Returns:
true
if Q intersects P
-
init
public void init()Initialize to a nullEnvelope
. -
init
public void init(double x1, double x2, double y1, double y2, double z1, double z2) Initialize anEnvelope
for a region defined by maximum and minimum values.- Parameters:
x1
- the first x-valuex2
- the second x-valuey1
- the first y-valuey2
- the second y-valuez1
- the first z-valuez2
- the second z-value
-
init
Initialize anEnvelope
to a region defined by two Coordinates. -
init
Initialize anEnvelope
to a region defined by a single Coordinate. -
init
-
init
Initialize anEnvelope
from an existing 3D Envelope.- Parameters:
env
- the 3D Envelope to initialize from
-
setToNull
public void setToNull()Makes thisEnvelope
a "null" envelope, that is, the envelope of the empty geometry. -
getDepth
public double getDepth()Returns the difference between the maximum and minimum z values.- Returns:
- max z - min z, or 0 if this is a null
Envelope
-
getMinZ
public double getMinZ()Returns theEnvelope
s minimum z-value. min z > max z indicates that this is a nullEnvelope
.- Specified by:
getMinZ
in interfaceBoundingBox3D
- Returns:
- the minimum z-coordinate
-
getMaxZ
public double getMaxZ()Returns theEnvelope
s maximum z-value. min z > max z indicates that this is a nullEnvelope
.- Specified by:
getMaxZ
in interfaceBoundingBox3D
- Returns:
- the maximum z-coordinate
-
getVolume
public double getVolume()Gets the volume of this envelope.- Returns:
- the volume of the envelope, 0.0 if the envelope is null
-
minExtent
public double minExtent()Gets the minimum extent of this envelope across all three dimensions. -
maxExtent
public double maxExtent()Gets the maximum extent of this envelope across both dimensions. -
expandToInclude
Enlarges thisEnvelope
so that it contains the givenCoordinate
. Has no effect if the point is already on or within the envelope.- Overrides:
expandToInclude
in classEnvelope
- Parameters:
p
- the Coordinate to expand to include
-
expandBy
public void expandBy(double distance) Expands this envelope by a given distance in all directions. Both positive and negative distances are supported. -
expandBy
public void expandBy(double deltaX, double deltaY, double deltaZ) Expands this envelope by a given distance in all directions. Both positive and negative distances are supported.- Parameters:
deltaX
- the distance to expand the envelope along the the X axisdeltaY
- the distance to expand the envelope along the the Y axis
-
expandToInclude
public void expandToInclude(double x, double y, double z) Enlarges thisEnvelope
so that it contains the given point. Has no effect if the point is already on or within the envelope.- Parameters:
x
- the value to lower the minimum x to or to raise the maximum x toy
- the value to lower the minimum y to or to raise the maximum y toz
- the value to lower the minimum z to or to raise the maximum z to
-
expandToInclude
Description copied from class:ReferencedEnvelope
Expand to include the provided DirectPosition- Overrides:
expandToInclude
in classReferencedEnvelope
-
translate
public void translate(double transX, double transY, double transZ) Translates this envelope by given amounts in the X and Y direction.- Parameters:
transX
- the amount to translate along the X axistransY
- the amount to translate along the Y axistransZ
- the amount to translate along the Z axis
-
centre
Computes the coordinate of the centre of this envelope (as long as it is non-null -
intersects
Check if the region defined byother
overlaps (intersects) the region of thisEnvelope
.- Parameters:
other
- theEnvelope
which thisEnvelope
is being checked for overlapping- Returns:
true
if theEnvelope
s overlap
-
intersects
Check if the pointp
overlaps (lies inside) the region of thisEnvelope
.- Overrides:
intersects
in classEnvelope
- Parameters:
p
- theCoordinate
to be tested- Returns:
true
if the point overlaps thisEnvelope
-
overlaps
Deprecated.Use #intersects instead. -
intersects
public boolean intersects(double x, double y, double z) Check if the point(x, y)
overlaps (lies inside) the region of thisEnvelope
.- Parameters:
x
- the x-ordinate of the pointy
- the y-ordinate of the pointz
- the z-ordinate of the point- Returns:
true
if the point overlaps thisEnvelope
-
contains
Tests if the given point lies in or on the envelope.Note that this is not the same definition as the SFS contains, which would exclude the envelope boundary.
-
contains
public boolean contains(double x, double y, double z) Tests if the given point lies in or on the envelope.Note that this is not the same definition as the SFS contains, which would exclude the envelope boundary.
- Specified by:
contains
in interfaceBoundingBox3D
- Parameters:
x
- the x-coordinate of the point which thisEnvelope
is being checked for containingy
- the y-coordinate of the point which thisEnvelope
is being checked for containingz
- The second ordinate value.- Returns:
true
if(x, y)
lies in the interior or on the boundary of thisEnvelope
.- See Also:
-
covers
public boolean covers(double x, double y, double z) Tests if the given point lies in or on the envelope.- Parameters:
x
- the x-coordinate of the point which thisEnvelope
is being checked for containingy
- the y-coordinate of the point which thisEnvelope
is being checked for containing- Returns:
true
if(x, y)
lies in the interior or on the boundary of thisEnvelope
.
-
covers
Tests if the given point lies in or on the envelope. -
covers
Tests if theEnvelope other
lies wholely inside thisEnvelope
(inclusive of the boundary).- Parameters:
other
- theEnvelope
to check- Returns:
- true if this
Envelope
covers theother
-
distance
Computes the distance between this and anotherEnvelope
. The distance between overlapping Envelopes is 0. Otherwise, the distance is the Euclidean distance between the closest points. -
init
Sets this envelope to the specified bounding box.- Overrides:
init
in classReferencedEnvelope
-
getDimension
public int getDimension()Returns the number of dimensions.- Specified by:
getDimension
in interfaceBounds
- Overrides:
getDimension
in classReferencedEnvelope
- Returns:
- The dimensionality of this envelope.
-
getMinimum
public double getMinimum(int dimension) Returns the minimal ordinate along the specified dimension.- Specified by:
getMinimum
in interfaceBounds
- Overrides:
getMinimum
in classReferencedEnvelope
- Parameters:
dimension
- The dimension for which to obtain the ordinate value.- Returns:
- The minimal ordinate at the given dimension.
- See Also:
-
getMaximum
public double getMaximum(int dimension) Returns the maximal ordinate along the specified dimension.- Specified by:
getMaximum
in interfaceBounds
- Overrides:
getMaximum
in classReferencedEnvelope
- Parameters:
dimension
- The dimension for which to obtain the ordinate value.- Returns:
- The maximal ordinate at the given dimension.
- See Also:
-
getMedian
public double getMedian(int dimension) Returns the center ordinate along the specified dimension.- Specified by:
getMedian
in interfaceBounds
- Overrides:
getMedian
in classReferencedEnvelope
- Parameters:
dimension
- The dimension for which to obtain the ordinate value.- Returns:
- The median ordinate at the given dimension.
- See Also:
-
getSpan
public double getSpan(int dimension) Returns the envelope length along the specified dimension. This length is equals to the maximum ordinate minus the minimal ordinate.- Specified by:
getSpan
in interfaceBounds
- Overrides:
getSpan
in classReferencedEnvelope
- Parameters:
dimension
- The dimension for which to obtain the ordinate value.- Returns:
- The span (typically width or height) at the given dimension.
- See Also:
-
getLowerCorner
A coordinate position consisting of all the minimal ordinates for each dimension for all points within theEnvelope
.- Specified by:
getLowerCorner
in interfaceBounds
- Overrides:
getLowerCorner
in classReferencedEnvelope
- Returns:
- The lower corner.
-
getUpperCorner
A coordinate position consisting of all the maximal ordinates for each dimension for all points within theEnvelope
.- Specified by:
getUpperCorner
in interfaceBounds
- Overrides:
getUpperCorner
in classReferencedEnvelope
- Returns:
- The upper corner.
-
isEmpty
public boolean isEmpty()Returnstrue
if lengths along all dimension are zero.- Specified by:
isEmpty
in interfaceBoundingBox
- Overrides:
isEmpty
in classReferencedEnvelope
- Returns:
true
if this bounding box is empty.
-
contains
Returnstrue
if the provided location is contained by this bounding box.- Specified by:
contains
in interfaceBoundingBox
- Overrides:
contains
in classReferencedEnvelope
- Parameters:
pos
- The direct position to test for inclusion.- Returns:
true
if the given position is inside this bounds.
-
contains
Returnstrue
if the provided bounds are contained by this bounding box. -
intersects
Check if this bounding box intersects the provided bounds. -
intersection
Computes the intersection of twoEnvelope
s.- Parameters:
env
- the envelope to intersect with- Returns:
- a new Envelope representing the intersection of the envelopes (this will be the null envelope if either argument is null, or they do not intersect
-
include
Include the provided bounding box, expanding as necessary. -
expandToInclude
Enlarges thisEnvelope
so that it contains theother
Envelope. Has no effect ifother
is wholly on or within the envelope.- Parameters:
other
- theEnvelope
to expand to include
-
include
public void include(double x, double y, double z) Include the provided coordinates, expanding as necessary.- Specified by:
include
in interfaceBoundingBox3D
- Parameters:
x
- The first ordinate value.y
- The second ordinate value.z
- The third ordinate value.
-
setBounds
Initialize the bounding box with another bounding box.- Since:
- 2.4
-
toBounds
Returns a new bounding box which contains the transformed shape of this bounding box. This is a convenience method that delegate its work to thetransform
method.- Specified by:
toBounds
in interfaceBoundingBox
- Specified by:
toBounds
in interfaceBoundingBox3D
- Overrides:
toBounds
in classReferencedEnvelope
- 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.
-
transform
public ReferencedEnvelope transform(CoordinateReferenceSystem targetCRS, boolean lenient) throws TransformException, FactoryException Transforms the referenced envelope to the specified coordinate reference system.This method can handle the case where the envelope contains the North or South pole, or when it cross the ±180� longitude.
- Overrides:
transform
in classReferencedEnvelope
- Parameters:
targetCRS
- The target coordinate reference system.lenient
-true
if datum shift should be applied even if there is insuffisient information. Otherwise (iffalse
), an exception is thrown in such case.- Returns:
- The transformed envelope.
- Throws:
FactoryException
- if the math transform can't be determined.TransformException
- if at least one coordinate can't be transformed.- See Also:
-
transform
public ReferencedEnvelope transform(CoordinateReferenceSystem targetCRS, boolean lenient, int numPointsForTransformation) throws TransformException, FactoryException Transforms the referenced envelope to the specified coordinate reference system using the specified amount of points.This method can handle the case where the envelope contains the North or South pole, or when it cross the ±180� longitude.
- Overrides:
transform
in classReferencedEnvelope
- Parameters:
targetCRS
- The target coordinate reference system.lenient
-true
if datum shift should be applied even if there is insuffisient information. Otherwise (iffalse
), an exception is thrown in such case.numPointsForTransformation
- The number of points to use for sampling the envelope.- Returns:
- The transformed envelope.
- Throws:
FactoryException
- if the math transform can't be determined.TransformException
- if at least one coordinate can't be transformed.- 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:
hashCode
in classReferencedEnvelope
-
equals
Compares the specified object with this envelope for equality.- Overrides:
equals
in classReferencedEnvelope
-
boundsEquals3D
Compare the bounds of this envelope with those of another.Note: in this test:
- the coordinate reference systems of the envelopes are not examined
- only the first three dimensions of the envelopes are compared
- it is assumed that each dimension equates to the same axis for both envelopes
- Parameters:
other
- other envelopeeps
- a small tolerance factor (e.g. 1.0e-6d) which will be scaled relative to this envlope's width and height- Returns:
- true if all bounding coordinates are equal within the set tolerance; false otherwise
-
include
public void include(double x, double y) Description copied from class:ReferencedEnvelope
Include the provided coordinates, expanding as necessary.- Specified by:
include
in interfaceBoundingBox
- Overrides:
include
in classReferencedEnvelope
- Parameters:
x
- The first ordinate value.y
- The second ordinate value.
-