BoundingBox.fromPositions constructor
- List<
RaliPosition> positions
Creates a BoundingBox that contains all provided positions
Implementation
factory BoundingBox.fromPositions(List<RaliPosition> positions) {
if (positions.isEmpty) {
throw ArgumentError('Cannot create BoundingBox from empty positions list');
}
double minLat = positions[0].lat;
double maxLat = positions[0].lat;
double minLng = positions[0].lng;
double maxLng = positions[0].lng;
for (final position in positions) {
minLat = math.min(minLat, position.lat);
maxLat = math.max(maxLat, position.lat);
minLng = math.min(minLng, position.lng);
maxLng = math.max(maxLng, position.lng);
}
return BoundingBox(
southwest: RaliPosition(minLng, minLat),
northeast: RaliPosition(maxLng, maxLat),
);
}