Package com.mapbox.geojson
Class BoundingBox
java.lang.Object
com.mapbox.geojson.BoundingBox
- All Implemented Interfaces:
Serializable
A GeoJson object MAY have a member named "bbox" to include information on the coordinate range
for its Geometries, Features, or FeatureCollections.
This class simplifies the build process for creating a bounding box and working with them when
deserialized. specific parameter naming helps define which coordinates belong where when a
bounding box instance is being created. Note that since GeoJson objects only have the option of
including a bounding box JSON element, the bbox value returned by a GeoJson object might
be null.
At a minimum, a bounding box will have two Points or four coordinates which define the
box. A 3rd dimensional bounding box can be produced if elevation or altitude is defined.
- Since:
- 3.0.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionfinal doubleeast()Convenience method for getting the bounding box most easterly point (longitude) as a double coordinate.booleanstatic BoundingBoxfromCoordinates(double west, double south, double east, double north) Deprecated.static BoundingBoxfromCoordinates(double west, double south, double southwestAltitude, double east, double north, double northEastAltitude) Deprecated.As of 3.1.0, usefromLngLats(double, double, double, double)instead.static BoundingBoxCreate a new instance of this class by passing in a formatted valid JSON String.static BoundingBoxfromLngLats(double west, double south, double east, double north) Define a new instance of this class by passing in four coordinates in the same order they would appear in the serialized GeoJson form.static BoundingBoxfromLngLats(double west, double south, double southwestAltitude, double east, double north, double northEastAltitude) Define a new instance of this class by passing in four coordinates in the same order they would appear in the serialized GeoJson form.static BoundingBoxfromPoints(Point southwest, Point northeast) Define a new instance of this class by passing in twoPoints, representing both the southwest and northwest corners of the bounding box.inthashCode()final doublenorth()Convenience method for getting the bounding box most westerly point (longitude) as a double coordinate.Provides thePointwhich represents the northeast corner of this bounding box when the map is facing due north.final doublesouth()Convenience method for getting the bounding box most southerly point (latitude) as a double coordinate.Provides thePointwhich represents the southwest corner of this bounding box when the map is facing due north.final StringtoJson()This takes the currently defined values found inside this instance and converts it to a GeoJson string.toString()static com.google.gson.TypeAdapter<BoundingBox>typeAdapter(com.google.gson.Gson gson) Gson TYPE adapter for parsing Gson to this class.final doublewest()Convenience method for getting the bounding box most westerly point (longitude) as a double coordinate.
-
Method Details
-
fromJson
Create a new instance of this class by passing in a formatted valid JSON String.- Parameters:
json- a formatted valid JSON string defining a Bounding Box- Returns:
- a new instance of this class defined by the values passed inside this static factory method
- Since:
- 3.0.0
-
fromPoints
Define a new instance of this class by passing in twoPoints, representing both the southwest and northwest corners of the bounding box.- Parameters:
southwest- represents the bottom left corner of the bounding box when the camera is pointing due northnortheast- represents the top right corner of the bounding box when the camera is pointing due north- Returns:
- a new instance of this class defined by the provided points
- Since:
- 3.0.0
-
fromCoordinates
@Deprecated public static BoundingBox fromCoordinates(double west, double south, double east, double north) Deprecated.As of 3.1.0, usefromLngLats(double, double, double, double)instead.Define a new instance of this class by passing in four coordinates in the same order they would appear in the serialized GeoJson form. Limits are placed on the minimum and maximum coordinate values which can exist and comply with the GeoJson spec.- Parameters:
west- the left side of the bounding box when the map is facing due northsouth- the bottom side of the bounding box when the map is facing due northeast- the right side of the bounding box when the map is facing due northnorth- the top side of the bounding box when the map is facing due north- Returns:
- a new instance of this class defined by the provided coordinates
- Since:
- 3.0.0
-
fromCoordinates
@Deprecated public static BoundingBox fromCoordinates(double west, double south, double southwestAltitude, double east, double north, double northEastAltitude) Deprecated.As of 3.1.0, usefromLngLats(double, double, double, double)instead.Define a new instance of this class by passing in four coordinates in the same order they would appear in the serialized GeoJson form. Limits are placed on the minimum and maximum coordinate values which can exist and comply with the GeoJson spec.- Parameters:
west- the left side of the bounding box when the map is facing due northsouth- the bottom side of the bounding box when the map is facing due northsouthwestAltitude- the southwest corner altitude or elevation when the map is facing due northeast- the right side of the bounding box when the map is facing due northnorth- the top side of the bounding box when the map is facing due northnorthEastAltitude- the northeast corner altitude or elevation when the map is facing due north- Returns:
- a new instance of this class defined by the provided coordinates
- Since:
- 3.0.0
-
fromLngLats
Define a new instance of this class by passing in four coordinates in the same order they would appear in the serialized GeoJson form. Limits are placed on the minimum and maximum coordinate values which can exist and comply with the GeoJson spec.- Parameters:
west- the left side of the bounding box when the map is facing due northsouth- the bottom side of the bounding box when the map is facing due northeast- the right side of the bounding box when the map is facing due northnorth- the top side of the bounding box when the map is facing due north- Returns:
- a new instance of this class defined by the provided coordinates
- Since:
- 3.1.0
-
fromLngLats
public static BoundingBox fromLngLats(double west, double south, double southwestAltitude, double east, double north, double northEastAltitude) Define a new instance of this class by passing in four coordinates in the same order they would appear in the serialized GeoJson form. Limits are placed on the minimum and maximum coordinate values which can exist and comply with the GeoJson spec.- Parameters:
west- the left side of the bounding box when the map is facing due northsouth- the bottom side of the bounding box when the map is facing due northsouthwestAltitude- the southwest corner altitude or elevation when the map is facing due northeast- the right side of the bounding box when the map is facing due northnorth- the top side of the bounding box when the map is facing due northnorthEastAltitude- the northeast corner altitude or elevation when the map is facing due north- Returns:
- a new instance of this class defined by the provided coordinates
- Since:
- 3.1.0
-
southwest
Provides thePointwhich represents the southwest corner of this bounding box when the map is facing due north.- Returns:
- a
Pointwhich defines this bounding boxes southwest corner - Since:
- 3.0.0
-
northeast
Provides thePointwhich represents the northeast corner of this bounding box when the map is facing due north.- Returns:
- a
Pointwhich defines this bounding boxes northeast corner - Since:
- 3.0.0
-
west
public final double west()Convenience method for getting the bounding box most westerly point (longitude) as a double coordinate.- Returns:
- the most westerly coordinate inside this bounding box
- Since:
- 3.0.0
-
south
public final double south()Convenience method for getting the bounding box most southerly point (latitude) as a double coordinate.- Returns:
- the most southerly coordinate inside this bounding box
- Since:
- 3.0.0
-
east
public final double east()Convenience method for getting the bounding box most easterly point (longitude) as a double coordinate.- Returns:
- the most easterly coordinate inside this bounding box
- Since:
- 3.0.0
-
north
public final double north()Convenience method for getting the bounding box most westerly point (longitude) as a double coordinate.- Returns:
- the most westerly coordinate inside this bounding box
- Since:
- 3.0.0
-
typeAdapter
Gson TYPE adapter for parsing Gson to this class.- Parameters:
gson- the builtGsonobject- Returns:
- the TYPE adapter for this class
- Since:
- 3.0.0
-
toJson
This takes the currently defined values found inside this instance and converts it to a GeoJson string.- Returns:
- a JSON string which represents this Bounding box
- Since:
- 3.0.0
-
toString
-
equals
-
hashCode
public int hashCode()
-
fromLngLats(double, double, double, double)instead.