public class BoundingBox
extends java.lang.Object
implements java.io.Serializable
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 Point
s or four coordinates which define the
box. A 3rd dimensional bounding box can be produced if elevation or altitude is defined.
Modifier and Type | Method and Description |
---|---|
double |
east()
Convenience method for getting the bounding box most easterly point (longitude) as a double
coordinate.
|
boolean |
equals(java.lang.Object obj) |
static BoundingBox |
fromCoordinates(double west,
double south,
double east,
double north)
Deprecated.
As of 3.1.0, use
fromLngLats(double, double, double, double) instead. |
static BoundingBox |
fromCoordinates(double west,
double south,
double southwestAltitude,
double east,
double north,
double northEastAltitude)
Deprecated.
As of 3.1.0, use
fromLngLats(double, double, double, double) instead. |
static BoundingBox |
fromJson(java.lang.String json)
Create a new instance of this class by passing in a formatted valid JSON String.
|
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.
|
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.
|
static BoundingBox |
fromPoints(Point southwest,
Point northeast)
Define a new instance of this class by passing in two
Point s, representing both the
southwest and northwest corners of the bounding box. |
int |
hashCode() |
double |
north()
Convenience method for getting the bounding box most northerly point (latitude) as a double
coordinate.
|
Point |
northeast()
Provides the
Point which represents the northeast corner of this bounding box when the
map is facing due north. |
double |
south()
Convenience method for getting the bounding box most southerly point (latitude) as a double
coordinate.
|
Point |
southwest()
Provides the
Point which represents the southwest corner of this bounding box when the
map is facing due north. |
java.lang.String |
toJson()
This takes the currently defined values found inside this instance and converts it to a GeoJson
string.
|
java.lang.String |
toString() |
static com.google.gson.TypeAdapter<BoundingBox> |
typeAdapter(com.google.gson.Gson gson)
Gson TYPE adapter for parsing Gson to this class.
|
double |
west()
Convenience method for getting the bounding box most westerly point (longitude) as a double
coordinate.
|
public static BoundingBox fromJson(java.lang.String json)
json
- a formatted valid JSON string defining a Bounding Boxpublic static BoundingBox fromPoints(@NonNull Point southwest, @NonNull Point northeast)
Point
s, representing both the
southwest and northwest corners of the bounding box.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@Deprecated public static BoundingBox fromCoordinates(double west, double south, double east, double north)
fromLngLats(double, double, double, double)
instead.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@Deprecated public static BoundingBox fromCoordinates(double west, double south, double southwestAltitude, double east, double north, double northEastAltitude)
fromLngLats(double, double, double, double)
instead.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
northpublic static BoundingBox fromLngLats(double west, double south, double east, double north)
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 northpublic static BoundingBox fromLngLats(double west, double south, double southwestAltitude, double east, double north, double northEastAltitude)
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@NonNull public Point southwest()
Point
which represents the southwest corner of this bounding box when the
map is facing due north.Point
which defines this bounding boxes southwest corner@NonNull public Point northeast()
Point
which represents the northeast corner of this bounding box when the
map is facing due north.Point
which defines this bounding boxes northeast cornerpublic final double west()
public final double south()
public final double east()
public final double north()
public static com.google.gson.TypeAdapter<BoundingBox> typeAdapter(com.google.gson.Gson gson)
gson
- the built Gson
objectpublic final java.lang.String toJson()
public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object