Represents a rectangular bounding box on Earth's surface.
A rectangle is defined by its minimum and maximum latitude/longitude coordinates. It can cross the dateline, in which case minLon > maxLon.
Key Features:
Example usage:
// Create a rectangle covering central London
Rectangle bbox = new Rectangle(51.4, 51.6, -0.2, 0.0);
// Create a rectangle crossing the dateline
Rectangle datelineBox = new Rectangle(20, 30, 170, -170);
// Create a bounding box around a point with given radius
Rectangle circle = Rectangle.fromPointDistance(lat, lon, radiusMeters);
Note: When working with areas near poles, consider that rectangles become highly distorted and may not provide accurate representation of the actual area.
| constant | type | note |
|---|---|---|
| AXISLAT_ERROR | double | maximum error from #axisLat(double, double). logic must be prepared to handle this |
| field | type | note |
|---|---|---|
| minLat | double | Minimum latitude in degrees (-90 to 90) |
| maxLat | double | Maximum latitude in degrees (-90 to 90) |
| minLon | double | Minimum longitude in degrees (-180 to 180). May be greater than maxLon when crossing the dateline. |
| maxLon | double | Maximum longitude in degrees (-180 to 180) |
<init>(double minLat, double maxLat, double minLon, double maxLon)Constructs a bounding box by first validating the provided latitude and longitude coordinates
axisLat(double centerLat, double radiusMeters)Calculate the latitude of a circle's intersections with its bbox meridians.
NOTE: the returned value will be +/- #AXISLAT_ERROR of the actual value.
| name | type | description |
|---|---|---|
| center_lat | double | The latitude of the circle center |
| radius_meters | double | The radius of the circle in meters |
Returns: A latitude
containsPoint(double lat, double lon, double minLat, double maxLat, double minLon, double maxLon)returns true if rectangle (defined by minLat, maxLat, minLon, maxLon) contains the lat lon point
fromPointDistance(double centerLat, double centerLon, double radiusMeters)Compute Bounding Box for a circle using WGS-84 parameters
crossesDateline()Returns true if this bounding box crosses the dateline
equals(Object o)hashCode()toString()