expandByMeters method

BoundingBox expandByMeters(
  1. double meters
)

Expands the bounding box by a specified buffer distance in meters

Implementation

BoundingBox expandByMeters(double meters) {
  // Rough approximation: 1 degree of latitude is about 111km
  // Longitude varies with latitude
  final latBuffer = meters / 111000;

  // Longitude degrees get wider as you move away from equator
  // cos(lat) gives a decent approximation
  final avgLat = (southwest.lat + northeast.lat) / 2;
  final lngBuffer = meters / (111000 * math.cos(_toRadians(avgLat)));

  return BoundingBox(
    southwest: RaliPosition(
      southwest.lng - lngBuffer,
      southwest.lat - latBuffer,
    ),
    northeast: RaliPosition(
      northeast.lng + lngBuffer,
      northeast.lat + latBuffer,
    ),
  );
}