"""Various helper functions"""
import math as m

def create_bbox(coords: tuple[float, float], radius: int):
    """
    Create a bounding box around the given coordinates.

    Args:
        coords (tuple[float, float]): The latitude and longitude of the center of the bounding box.
        radius (int): The half-side length of the bounding box in meters.

    Returns:
        tuple[float, float, float, float]: The minimum latitude, minimum longitude, maximum latitude, and maximum longitude
                                            defining the bounding box.
    """
    # Earth's radius in meters
    R = 6378137
    lat, lon = coords
    d_lat = radius / R
    d_lon = radius / (R * m.cos(m.pi * lat / 180))

    lat_min = lat - d_lat * 180 / m.pi
    lat_max = lat + d_lat * 180 / m.pi
    lon_min = lon - d_lon * 180 / m.pi
    lon_max = lon + d_lon * 180 / m.pi

    return (lat_min, lon_min, lat_max, lon_max)
