calculateRadGeopoints function
Calculates a list of GeoPoints representing the lower-left and upper-right corners of a bounding box around a given position, based on a specified radius.
Parameters:
position
: The central GeoPoint around which the bounding box is calculated.radiusKilometers
: The radius of the bounding box in kilometers.
Returns: A list of two GeoPoints: the lower-left and upper-right corners of the bounding box.
Implementation
List<GeoPoint> calculateRadGeopoints(GeoPoint position, int radiusKilometers) {
double lat = 0.0144927536231884;
double lon = 0.0181818181818182;
double distance = 0.621371 * radiusKilometers;
double lowerLat = position.latitude - (lat * distance);
double lowerLon = position.longitude - (lon * distance);
double greaterLat = position.latitude + (lat * distance);
double greaterLon = position.longitude + (lon * distance);
return [GeoPoint(lowerLat, lowerLon), GeoPoint(greaterLat, greaterLon)];
}