BoundingBox.fromLatLongs constructor
Creates a BoundingBox that encompasses all the given coordinates.
Calculates the minimum and maximum latitude/longitude values from the provided coordinate list to create the smallest bounding box that contains all points.
latLongs List of coordinates to encompass (must not be empty)
Returns a BoundingBox containing all the coordinates
Implementation
factory BoundingBox.fromLatLongs(List<ILatLong> latLongs) {
assert(latLongs.isNotEmpty);
double minLatitude = double.infinity;
double minLongitude = double.infinity;
double maxLatitude = double.negativeInfinity;
double maxLongitude = double.negativeInfinity;
for (ILatLong latLong in latLongs) {
double latitude = latLong.latitude;
double longitude = latLong.longitude;
minLatitude = min(minLatitude, latitude);
minLongitude = min(minLongitude, longitude);
maxLatitude = max(maxLatitude, latitude);
maxLongitude = max(maxLongitude, longitude);
}
// Projection.checkLatitude(minLatitude);
// Projection.checkLongitude(minLongitude);
// Projection.checkLatitude(maxLatitude);
// Projection.checkLongitude(maxLongitude);
return BoundingBox(minLatitude, minLongitude, maxLatitude, maxLongitude);
}