Class ReferencedEnvelope3D
- All Implemented Interfaces:
Serializable,Comparable,BoundingBox,BoundingBox3D,Bounds
- Author:
- Niels Charlier
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic ReferencedEnvelope3DA 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 TypeMethodDescriptionbooleanboundsEquals3D(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-nullbooleancontains(double x, double y, double z) Tests if the given point lies in or on the envelope.booleancontains(BoundingBox3D bbox) Returnstrueif the provided bounds are contained by this bounding box.booleanReturnstrueif the provided location is contained by this bounding box.booleanTests if the given point lies in or on the envelope.booleancovers(double x, double y, double z) Tests if the given point lies in or on the envelope.booleancovers(ReferencedEnvelope3D other) Tests if theEnvelope otherlies wholely inside thisEnvelope(inclusive of the boundary).booleancovers(Coordinate p) Tests if the given point lies in or on the envelope.doubleComputes the distance between this and anotherEnvelope.booleanCompares the specified object with this envelope for equality.voidexpandBy(double distance) Expands this envelope by a given distance in all directions.voidexpandBy(double deltaX, double deltaY, double deltaZ) Expands this envelope by a given distance in all directions.voidexpandToInclude(double x, double y, double z) Enlarges thisEnvelopeso that it contains the given point.voidExpand to include the provided DirectPositionvoidEnlarges thisEnvelopeso that it contains theotherEnvelope.voidEnlarges thisEnvelopeso that it contains the givenCoordinate.doublegetDepth()Returns the difference between the maximum and minimum z values.intReturns the number of dimensions.A coordinate position consisting of all the minimal ordinates for each dimension for all points within theEnvelope.doublegetMaximum(int dimension) Returns the maximal ordinate along the specified dimension.doublegetMaxZ()Returns theEnvelopes maximum z-value. min z > max z indicates that this is a nullEnvelope.doublegetMedian(int dimension) Returns the center ordinate along the specified dimension.doublegetMinimum(int dimension) Returns the minimal ordinate along the specified dimension.doublegetMinZ()Returns theEnvelopes minimum z-value. min z > max z indicates that this is a nullEnvelope.doublegetSpan(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.doubleGets the volume of this envelope.inthashCode()Returns a hash value for this envelope.voidinclude(double x, double y) Include the provided coordinates, expanding as necessary.voidinclude(double x, double y, double z) Include the provided coordinates, expanding as necessary.voidinclude(BoundingBox3D bbox) Include the provided bounding box, expanding as necessary.voidinit()Initialize to a nullEnvelope.voidinit(double x1, double x2, double y1, double y2, double z1, double z2) Initialize anEnvelopefor a region defined by maximum and minimum values.voidinit(BoundingBox bounds) Sets this envelope to the specified bounding box.voidinit(ReferencedEnvelope3D env) Initialize anEnvelopefrom an existing 3D Envelope.voidinit(Coordinate p) Initialize anEnvelopeto a region defined by a single Coordinate.voidinit(Coordinate p1, Coordinate p2) Initialize anEnvelopeto a region defined by two Coordinates.voidComputes the intersection of twoEnvelopes.booleanintersects(double x, double y, double z) Check if the point(x, y)overlaps (lies inside) the region of thisEnvelope.booleanintersects(BoundingBox3D bbox) Check if this bounding box intersects the provided bounds.booleanintersects(ReferencedEnvelope3D other) Check if the region defined byotheroverlaps (intersects) the region of thisEnvelope.booleanCheck if the pointpoverlaps (lies inside) the region of thisEnvelope.static booleanintersects(Coordinate p1, Coordinate p2, Coordinate q) Test the point q to see whether it intersects the Envelope defined by p1-p2static booleanintersects(Coordinate p1, Coordinate p2, Coordinate q1, Coordinate q2) Test the envelope defined by p1-p2 for intersection with the envelope defined by q1-q2booleanisEmpty()Returnstrueif lengths along all dimension are zero.doubleGets the maximum extent of this envelope across both dimensions.doubleGets the minimum extent of this envelope across all three dimensions.booleanDeprecated.Use #intersects instead.voidsetBounds(BoundingBox3D bbox) Initialize the bounding box with another bounding box.voidMakes thisEnvelopea "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.voidtranslate(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, toStringMethods 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, translateMethods inherited from interface BoundingBox
contains, contains, getHeight, getMaxX, getMaxY, getMinX, getMinY, getWidth, include, intersects, setBoundsMethods 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:
trueif 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:
trueif 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 anEnvelopefor 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 anEnvelopeto a region defined by two Coordinates. -
init
Initialize anEnvelopeto a region defined by a single Coordinate. -
init
-
init
Initialize anEnvelopefrom an existing 3D Envelope.- Parameters:
env- the 3D Envelope to initialize from
-
setToNull
public void setToNull()Makes thisEnvelopea "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 theEnvelopes minimum z-value. min z > max z indicates that this is a nullEnvelope.- Specified by:
getMinZin interfaceBoundingBox3D- Returns:
- the minimum z-coordinate
-
getMaxZ
public double getMaxZ()Returns theEnvelopes maximum z-value. min z > max z indicates that this is a nullEnvelope.- Specified by:
getMaxZin 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 thisEnvelopeso that it contains the givenCoordinate. Has no effect if the point is already on or within the envelope.- Overrides:
expandToIncludein 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 thisEnvelopeso 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:ReferencedEnvelopeExpand to include the provided DirectPosition- Overrides:
expandToIncludein 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 byotheroverlaps (intersects) the region of thisEnvelope.- Parameters:
other- theEnvelopewhich thisEnvelopeis being checked for overlapping- Returns:
trueif theEnvelopes overlap
-
intersects
Check if the pointpoverlaps (lies inside) the region of thisEnvelope.- Overrides:
intersectsin classEnvelope- Parameters:
p- theCoordinateto be tested- Returns:
trueif 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:
trueif 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:
containsin interfaceBoundingBox3D- Parameters:
x- the x-coordinate of the point which thisEnvelopeis being checked for containingy- the y-coordinate of the point which thisEnvelopeis being checked for containingz- The second ordinate value.- Returns:
trueif(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 thisEnvelopeis being checked for containingy- the y-coordinate of the point which thisEnvelopeis being checked for containing- Returns:
trueif(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 otherlies wholely inside thisEnvelope(inclusive of the boundary).- Parameters:
other- theEnvelopeto check- Returns:
- true if this
Envelopecovers 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:
initin classReferencedEnvelope
-
getDimension
public int getDimension()Returns the number of dimensions.- Specified by:
getDimensionin interfaceBounds- Overrides:
getDimensionin classReferencedEnvelope- Returns:
- The dimensionality of this envelope.
-
getMinimum
public double getMinimum(int dimension) Returns the minimal ordinate along the specified dimension.- Specified by:
getMinimumin interfaceBounds- Overrides:
getMinimumin 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:
getMaximumin interfaceBounds- Overrides:
getMaximumin 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:
getMedianin interfaceBounds- Overrides:
getMedianin 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:
getSpanin interfaceBounds- Overrides:
getSpanin 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:
getLowerCornerin interfaceBounds- Overrides:
getLowerCornerin 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:
getUpperCornerin interfaceBounds- Overrides:
getUpperCornerin classReferencedEnvelope- Returns:
- The upper corner.
-
isEmpty
public boolean isEmpty()Returnstrueif lengths along all dimension are zero.- Specified by:
isEmptyin interfaceBoundingBox- Overrides:
isEmptyin classReferencedEnvelope- Returns:
trueif this bounding box is empty.
-
contains
Returnstrueif the provided location is contained by this bounding box.- Specified by:
containsin interfaceBoundingBox- Overrides:
containsin classReferencedEnvelope- Parameters:
pos- The direct position to test for inclusion.- Returns:
trueif the given position is inside this bounds.
-
contains
Returnstrueif the provided bounds are contained by this bounding box. -
intersects
Check if this bounding box intersects the provided bounds. -
intersection
Computes the intersection of twoEnvelopes.- 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 thisEnvelopeso that it contains theotherEnvelope. Has no effect ifotheris wholly on or within the envelope.- Parameters:
other- theEnvelopeto expand to include
-
include
public void include(double x, double y, double z) Include the provided coordinates, expanding as necessary.- Specified by:
includein 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 thetransformmethod.- Specified by:
toBoundsin interfaceBoundingBox- Specified by:
toBoundsin interfaceBoundingBox3D- Overrides:
toBoundsin 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:
transformin classReferencedEnvelope- Parameters:
targetCRS- The target coordinate reference system.lenient-trueif 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:
transformin classReferencedEnvelope- Parameters:
targetCRS- The target coordinate reference system.lenient-trueif 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:
hashCodein classReferencedEnvelope
-
equals
Compares the specified object with this envelope for equality.- Overrides:
equalsin 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:ReferencedEnvelopeInclude the provided coordinates, expanding as necessary.- Specified by:
includein interfaceBoundingBox- Overrides:
includein classReferencedEnvelope- Parameters:
x- The first ordinate value.y- The second ordinate value.
-