boundingBoxBits method
Calculates the maximum number of bits of a geohash to get a bounding box that is larger than a given size at the given coordinate.
@param coordinate The coordinate as a latitude, longitude
pair.
@param size The size of the bounding box.
@returns The number of bits necessary for the geohash.
Implementation
int boundingBoxBits(GeoPoint point, double size) {
var latDeltaDegrees = size / _METERS_PER_DEGREE_LATITUDE;
double latitudeNorth = min(90, point.latitude + latDeltaDegrees);
double latitudeSouth = max(-90, point.latitude - latDeltaDegrees);
var bitsLat = (latitudeBitsForResolution(size)).floor() * 2;
var bitsLongNorth =
(longitudeBitsForResolution(size, latitudeNorth)).floor() * 2 - 1;
var bitsLongSouth =
(longitudeBitsForResolution(size, latitudeSouth)).floor() * 2 - 1;
return [bitsLat, bitsLongNorth, bitsLongSouth, _MAXIMUM_BITS_PRECISION]
.reduce(min);
}