from typing import Dict
from typing import Any
from typing import Tuple


def calculate_centroid(metadata: Dict[str, Any]) -> Tuple[float, float, int]:
    """Calculate a rough centroid for the metadata provided by rio-tiler.

    Args:
        metadata: the metadata generated by rio-tiler for a compliant image

    Returns:
        The centroid of the bounds polygon with the min zoom.

    """
    bounds = metadata["bounds"]["value"]
    lon = (bounds[0] + bounds[2]) / 2
    lat = (bounds[1] + bounds[3]) / 2
    return lon, lat, metadata["minzoom"]