Package mil.nga.geopackage
Class BoundingBox
- java.lang.Object
-
- mil.nga.geopackage.BoundingBox
-
public class BoundingBox extends Object
Bounding Box with longitude and latitude ranges in degrees- Author:
- osbornb
-
-
Constructor Summary
Constructors Constructor Description BoundingBox()
ConstructorBoundingBox(double minLongitude, double minLatitude, double maxLongitude, double maxLatitude)
ConstructorBoundingBox(BoundingBox boundingBox)
ConstructorBoundingBox(Geometry geometry)
ConstructorBoundingBox(GeometryEnvelope envelope)
Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description BoundingBox
boundCoordinates(double maxProjectionLongitude)
Bound the bounding box longitudes within the min and max possible projection values.BoundingBox
boundWebMercatorCoordinates()
Bound the bounding box coordinates within Web Mercator range valuesBoundingBox
boundWgs84Coordinates()
Bound the bounding box coordinates within WGS84 range valuesGeometryEnvelope
buildEnvelope()
Build a Geometry Envelope from the bounding boxstatic GeometryEnvelope
buildEnvelope(BoundingBox boundingBox)
Build a Geometry Envelope from the bounding boxGeometry
buildGeometry()
Build a geometry representation of the bounding boxstatic Geometry
buildGeometry(BoundingBox boundingBox)
Build a geometry representation of the bounding boxBoundingBox
complementary(double maxProjectionLongitude)
If the bounding box spans the Anti-Meridian, attempt to get a complementary bounding box using the max longitude of the unit projectionBoundingBox
complementaryWebMercator()
If the bounding box spans the Anti-Meridian, attempt to get a complementary Web Mercator bounding boxBoundingBox
complementaryWgs84()
If the bounding box spans the Anti-Meridian, attempt to get a complementary WGS84 bounding boxboolean
contains(BoundingBox boundingBox)
Determine if inclusively contains the provided bounding boxBoundingBox
copy()
Copy the bounding boxboolean
equals(Object obj)
BoundingBox
expandCoordinates(double maxProjectionLongitude)
Expand the bounding box max longitude above the max possible projection value if needed to create a bounding box where the max longitude is numerically larger than the min longitude.BoundingBox
expandWebMercatorCoordinates()
Expand the bounding box max longitude above the max Web Mercator projection value if needed to create a bounding box where the max longitude is numerically larger than the min longitude.BoundingBox
expandWgs84Coordinates()
Expand the bounding box max longitude above the max WGS84 projection value if needed to create a bounding box where the max longitude is numerically larger than the min longitude.Point
getCentroid()
Get the bounding box centroid pointstatic Point
getCentroid(BoundingBox boundingBox)
Get the bounding box centroid pointstatic Point
getCentroid(BoundingBox boundingBox, Projection projection)
Get the centroid for the bounding box and projectionPoint
getCentroid(Projection projection)
Get the centroid for the bounding box and projectionPoint
getDegreesCentroid()
Get the centroid for the bounding box in degreesstatic Point
getDegreesCentroid(BoundingBox boundingBox)
Get the centroid for a bounding box in degreesdouble
getLatitudeRange()
Get the latitude rangedouble
getLongitudeRange()
Get the longitude rangedouble
getMaxLatitude()
Get the max latitudedouble
getMaxLongitude()
Get the max longitudedouble
getMinLatitude()
Get the min latitudedouble
getMinLongitude()
Get the min longitudeint
hashCode()
boolean
intersects(BoundingBox boundingBox)
Determine if intersects with the provided bounding boxboolean
intersects(BoundingBox boundingBox, boolean allowEmpty)
Determine if intersects with the provided bounding boxboolean
isPoint()
Determine if the bounding box is of a single pointBoundingBox
overlap(BoundingBox boundingBox)
Get the overlapping bounding box with the provided bounding boxBoundingBox
overlap(BoundingBox boundingBox, boolean allowEmpty)
Get the overlapping bounding box with the provided bounding boxvoid
setMaxLatitude(double maxLatitude)
Set the max latitudevoid
setMaxLongitude(double maxLongitude)
Set the max longitudevoid
setMinLatitude(double minLatitude)
Set the min latitudevoid
setMinLongitude(double minLongitude)
Set the min longitudeBoundingBox
squareExpand()
Expand the bounding box to an equally sized width and height bounding boxBoundingBox
squareExpand(double bufferPercentage)
Expand the bounding box to an equally sized width and height bounding box with optional empty edge bufferString
toString()
BoundingBox
transform(ProjectionTransform transform)
Transform the bounding box using the provided projection transformBoundingBox
transform(GeometryTransform transform)
Transform the bounding box using the provided projection transformBoundingBox
union(BoundingBox boundingBox)
Get the union bounding box with the provided bounding boxstatic BoundingBox
worldWebMercator()
Create a new Web Mercator bounding box with world bounds (meters)static BoundingBox
worldWGS84()
Create a new WGS84 bounding box with world bounds (degrees)static BoundingBox
worldWGS84WithWebMercatorLimits()
Create a new WGS84 bounding box bounded by Web Mercator limits
-
-
-
Constructor Detail
-
BoundingBox
public BoundingBox()
Constructor
-
BoundingBox
public BoundingBox(double minLongitude, double minLatitude, double maxLongitude, double maxLatitude)
Constructor- Parameters:
minLongitude
- min longitudeminLatitude
- min latitudemaxLongitude
- max longitudemaxLatitude
- max latitude- Since:
- 2.0.0
-
BoundingBox
public BoundingBox(BoundingBox boundingBox)
Constructor- Parameters:
boundingBox
- bounding box- Since:
- 1.1.6
-
BoundingBox
public BoundingBox(GeometryEnvelope envelope)
Constructor- Parameters:
envelope
- geometry envelope- Since:
- 2.0.0
-
BoundingBox
public BoundingBox(Geometry geometry)
Constructor- Parameters:
geometry
- geometry- Since:
- 6.2.0
-
-
Method Detail
-
worldWGS84
public static BoundingBox worldWGS84()
Create a new WGS84 bounding box with world bounds (degrees)- Returns:
- new bounding box
- Since:
- 6.2.0
-
worldWebMercator
public static BoundingBox worldWebMercator()
Create a new Web Mercator bounding box with world bounds (meters)- Returns:
- new bounding box
- Since:
- 6.2.0
-
worldWGS84WithWebMercatorLimits
public static BoundingBox worldWGS84WithWebMercatorLimits()
Create a new WGS84 bounding box bounded by Web Mercator limits- Returns:
- new bounding box
- Since:
- 6.6.0
-
getMinLongitude
public double getMinLongitude()
Get the min longitude- Returns:
- min longitude
-
setMinLongitude
public void setMinLongitude(double minLongitude)
Set the min longitude- Parameters:
minLongitude
- min longitude
-
getMaxLongitude
public double getMaxLongitude()
Get the max longitude- Returns:
- max longitude
-
setMaxLongitude
public void setMaxLongitude(double maxLongitude)
Set the max longitude- Parameters:
maxLongitude
- max longitude
-
getMinLatitude
public double getMinLatitude()
Get the min latitude- Returns:
- min latitude
-
setMinLatitude
public void setMinLatitude(double minLatitude)
Set the min latitude- Parameters:
minLatitude
- min latitude
-
getMaxLatitude
public double getMaxLatitude()
Get the max latitude- Returns:
- max latitude
-
setMaxLatitude
public void setMaxLatitude(double maxLatitude)
Set the max latitude- Parameters:
maxLatitude
- max latitude
-
getLongitudeRange
public double getLongitudeRange()
Get the longitude range- Returns:
- longitude range
- Since:
- 3.5.0
-
getLatitudeRange
public double getLatitudeRange()
Get the latitude range- Returns:
- latitude range
- Since:
- 3.5.0
-
getCentroid
public Point getCentroid()
Get the bounding box centroid point- Returns:
- centroid point
- Since:
- 6.2.0
-
getCentroid
public static Point getCentroid(BoundingBox boundingBox)
Get the bounding box centroid point- Parameters:
boundingBox
- bounding box- Returns:
- centroid point
- Since:
- 6.2.0
-
getCentroid
public Point getCentroid(Projection projection)
Get the centroid for the bounding box and projection- Parameters:
projection
- projection of the bounding box- Returns:
- centroid point
- Since:
- 6.2.0
-
getCentroid
public static Point getCentroid(BoundingBox boundingBox, Projection projection)
Get the centroid for the bounding box and projection- Parameters:
boundingBox
- bounding boxprojection
- projection of the bounding box- Returns:
- centroid point
- Since:
- 6.2.0
-
getDegreesCentroid
public Point getDegreesCentroid()
Get the centroid for the bounding box in degrees- Returns:
- centroid point
- Since:
- 6.2.0
-
getDegreesCentroid
public static Point getDegreesCentroid(BoundingBox boundingBox)
Get the centroid for a bounding box in degrees- Parameters:
boundingBox
- bounding box in degrees- Returns:
- centroid point
- Since:
- 6.2.0
-
buildEnvelope
public GeometryEnvelope buildEnvelope()
Build a Geometry Envelope from the bounding box- Returns:
- geometry envelope
- Since:
- 1.1.0
-
buildEnvelope
public static GeometryEnvelope buildEnvelope(BoundingBox boundingBox)
Build a Geometry Envelope from the bounding box- Parameters:
boundingBox
- bounding box- Returns:
- geometry envelope
- Since:
- 3.2.0
-
buildGeometry
public Geometry buildGeometry()
Build a geometry representation of the bounding box- Returns:
- geometry, polygon or point
- Since:
- 6.2.0
-
buildGeometry
public static Geometry buildGeometry(BoundingBox boundingBox)
Build a geometry representation of the bounding box- Parameters:
boundingBox
- bounding box- Returns:
- geometry, polygon or point
- Since:
- 6.2.0
-
complementary
public BoundingBox complementary(double maxProjectionLongitude)
If the bounding box spans the Anti-Meridian, attempt to get a complementary bounding box using the max longitude of the unit projection- Parameters:
maxProjectionLongitude
- max longitude of the world for the current bounding box units- Returns:
- complementary bounding box or nil if none
- Since:
- 2.0.0
-
complementaryWgs84
public BoundingBox complementaryWgs84()
If the bounding box spans the Anti-Meridian, attempt to get a complementary WGS84 bounding box- Returns:
- complementary bounding box or nil if none
- Since:
- 2.0.0
-
complementaryWebMercator
public BoundingBox complementaryWebMercator()
If the bounding box spans the Anti-Meridian, attempt to get a complementary Web Mercator bounding box- Returns:
- complementary bounding box or nil if none
- Since:
- 2.0.0
-
boundCoordinates
public BoundingBox boundCoordinates(double maxProjectionLongitude)
Bound the bounding box longitudes within the min and max possible projection values. This may result in a max longitude numerically lower than the min longitude.- Parameters:
maxProjectionLongitude
- max longitude of the world for the current bounding box units- Returns:
- bounded bounding box
- Since:
- 2.0.0
-
boundWgs84Coordinates
public BoundingBox boundWgs84Coordinates()
Bound the bounding box coordinates within WGS84 range values- Returns:
- bounded bounding box
- Since:
- 2.0.0
-
boundWebMercatorCoordinates
public BoundingBox boundWebMercatorCoordinates()
Bound the bounding box coordinates within Web Mercator range values- Returns:
- bounded bounding box
- Since:
- 2.0.0
-
expandCoordinates
public BoundingBox expandCoordinates(double maxProjectionLongitude)
Expand the bounding box max longitude above the max possible projection value if needed to create a bounding box where the max longitude is numerically larger than the min longitude.- Parameters:
maxProjectionLongitude
- max longitude of the world for the current bounding box units- Returns:
- expanded bounding box
- Since:
- 2.0.0
-
expandWgs84Coordinates
public BoundingBox expandWgs84Coordinates()
Expand the bounding box max longitude above the max WGS84 projection value if needed to create a bounding box where the max longitude is numerically larger than the min longitude.- Returns:
- expanded bounding box
- Since:
- 2.0.0
-
expandWebMercatorCoordinates
public BoundingBox expandWebMercatorCoordinates()
Expand the bounding box max longitude above the max Web Mercator projection value if needed to create a bounding box where the max longitude is numerically larger than the min longitude.- Returns:
- expanded bounding box
- Since:
- 2.0.0
-
transform
public BoundingBox transform(ProjectionTransform transform)
Transform the bounding box using the provided projection transform- Parameters:
transform
- projection transform- Returns:
- transformed bounding box
- Since:
- 3.0.0
-
transform
public BoundingBox transform(GeometryTransform transform)
Transform the bounding box using the provided projection transform- Parameters:
transform
- geometry transform- Returns:
- transformed bounding box
- Since:
- 6.0.0
-
intersects
public boolean intersects(BoundingBox boundingBox)
Determine if intersects with the provided bounding box- Parameters:
boundingBox
- bounding box- Returns:
- true if intersects
- Since:
- 3.1.0
-
intersects
public boolean intersects(BoundingBox boundingBox, boolean allowEmpty)
Determine if intersects with the provided bounding box- Parameters:
boundingBox
- bounding boxallowEmpty
- allow empty ranges when determining intersection- Returns:
- true if intersects
- Since:
- 3.1.0
-
overlap
public BoundingBox overlap(BoundingBox boundingBox)
Get the overlapping bounding box with the provided bounding box- Parameters:
boundingBox
- bounding box- Returns:
- bounding box
- Since:
- 3.1.0
-
overlap
public BoundingBox overlap(BoundingBox boundingBox, boolean allowEmpty)
Get the overlapping bounding box with the provided bounding box- Parameters:
boundingBox
- bounding boxallowEmpty
- allow empty ranges when determining overlap- Returns:
- bounding box
- Since:
- 3.1.0
-
union
public BoundingBox union(BoundingBox boundingBox)
Get the union bounding box with the provided bounding box- Parameters:
boundingBox
- bounding box- Returns:
- bounding box
- Since:
- 3.1.0
-
contains
public boolean contains(BoundingBox boundingBox)
Determine if inclusively contains the provided bounding box- Parameters:
boundingBox
- bounding box- Returns:
- true if contains
- Since:
- 3.1.0
-
squareExpand
public BoundingBox squareExpand()
Expand the bounding box to an equally sized width and height bounding box- Returns:
- new square expanded bounding box
- Since:
- 3.5.0
-
squareExpand
public BoundingBox squareExpand(double bufferPercentage)
Expand the bounding box to an equally sized width and height bounding box with optional empty edge buffer- Parameters:
bufferPercentage
- bounding box edge buffer percentage. A value of 0.1 adds a 10% buffer on each side of the squared bounding box.- Returns:
- new square expanded bounding box
- Since:
- 3.5.0
-
isPoint
public boolean isPoint()
Determine if the bounding box is of a single point- Returns:
- true if a single point bounds
- Since:
- 3.5.0
-
copy
public BoundingBox copy()
Copy the bounding box- Returns:
- bounding box copy
- Since:
- 6.2.0
-
-