Package com.mapbox.geojson
Class BoundingBox
- java.lang.Object
-
- com.mapbox.geojson.BoundingBox
-
- All Implemented Interfaces:
java.io.Serializable
public class BoundingBox extends java.lang.Object implements java.io.SerializableA 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
bboxvalue 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:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description doubleeast()Convenience method for getting the bounding box most easterly point (longitude) as a double coordinate.booleanequals(java.lang.Object obj)static BoundingBoxfromCoordinates(double west, double south, double east, double north)Deprecated.As of 3.1.0, usefromLngLats(double, double, double, double)instead.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 BoundingBoxfromJson(java.lang.String json)Create 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()doublenorth()Convenience method for getting the bounding box most westerly point (longitude) as a double coordinate.Pointnortheast()Provides thePointwhich represents the northeast corner of this bounding box when the map is facing due north.doublesouth()Convenience method for getting the bounding box most southerly point (latitude) as a double coordinate.Pointsouthwest()Provides thePointwhich represents the southwest corner of this bounding box when the map is facing due north.java.lang.StringtoJson()This takes the currently defined values found inside this instance and converts it to a GeoJson string.java.lang.StringtoString()static com.google.gson.TypeAdapter<BoundingBox>typeAdapter(com.google.gson.Gson gson)Gson TYPE adapter for parsing Gson to this class.doublewest()Convenience method for getting the bounding box most westerly point (longitude) as a double coordinate.
-
-
-
Method Detail
-
fromJson
public static BoundingBox fromJson(java.lang.String json)
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
public static BoundingBox fromPoints(@NonNull Point southwest, @NonNull Point northeast)
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
public static BoundingBox fromLngLats(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. 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
@NonNull public Point 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
@NonNull public Point 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
public static com.google.gson.TypeAdapter<BoundingBox> typeAdapter(com.google.gson.Gson gson)
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
public final java.lang.String 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
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-