def get_maximum_overview_level(src_dst, minsize=512):
    """
    Calculate the maximum overview level.

    Attributes
    ----------
    src_dst : rasterio.io.DatasetReader
        Rasterio io.DatasetReader object.
    minsize : int (default: 512)
        Minimum overview size.

    Returns
    -------
    nlevel: int
        overview level.

    """
    width = src_dst.width
    height = src_dst.height

    nlevel = 0
    overview = 1

    while min(width // overview, height // overview) > minsize:
        overview *= 2
        nlevel += 1

    return nlevel