from haversine import Unit, haversine from dmp.locations.types import BoundingBox, Point def get_bounding_center_and_radius_in_km( bounding_box: BoundingBox, ) -> tuple[Point, float]: min_lat, min_lon, max_lat, max_lon = bounding_box center = Point((min_lat + max_lat) / 2, (min_lon + max_lon) / 2) sides = [ Point(max_lat, center[1]), Point(min_lat, center[1]), Point(center[0], max_lon), Point(center[0], min_lon), ] return center, max(haversine(center, side, unit=Unit.KILOMETERS) for side in sides)