geohashQueryBounds method
Calculates a set of query bounds to fully contain a given circle, each being a start, end
pair
where any geohash is guaranteed to be lexicographically larger than start and smaller than end.
@param center The center given as latitude, longitude
pair.
@param radius The radius of the circle.
@return An array of geohash query bounds, each containing a start, end
pair.
Implementation
List<List<String>> geohashQueryBounds(GeoPoint center, double radius) {
validateLocation(center);
int queryBits = max(1, boundingBoxBits(center, radius));
var geohashPrecision = (queryBits / _BITS_PER_CHAR).ceil();
var coordinates = boundingBoxCoordinates(center, radius);
var queries = coordinates.map((coordinate) {
return geohashQuery(
geoHashForLocation(coordinate, precision: geohashPrecision),
queryBits)
.toList();
});
List<List<String>> filteredList = [];
var tempList =
queries.toList().map((e) => e.toString()).toList().toSet().toList();
for (int i = 0; i < tempList.length; i++) {
filteredList.add([
tempList[i].split(',')[0].replaceAll('[', '').trim(),
tempList[i].split(',')[1].replaceAll(']', '').trim()
]);
}
return filteredList;
}