(
    src_dst: Union[DatasetReader, DatasetWriter, WarpedVRT],
    tilesize: int = 256,
    tms: morecantile.TileMatrixSet = morecantile.tms.get("WebMercatorQuad"),
    zoom_level_strategy: str = "auto",
)
return (min_zoom, max_zoom)
Calculate raster min/max zoom level.
Calculate raster min/max zoom level.
Calculate raster min / max zoom level .
def get_zooms(
    src_dst: Union[DatasetReader, DatasetWriter, WarpedVRT],
    tilesize: int = 256,
    tms: morecantile.TileMatrixSet = morecantile.tms.get("WebMercatorQuad"),
    zoom_level_strategy: str = "auto",
) -> Tuple[int, int]:
    """Calculate raster min/max zoom level."""
    # If the raster is not in the TMS CRS we calculate its projected properties (height, width, resolution)
    if src_dst.crs != tms.rasterio_crs:
        aff, w, h = calculate_default_transform(
            src_dst.crs,
            tms.rasterio_crs,
            src_dst.width,
            src_dst.height,
            *src_dst.bounds,
        )
    else:
        aff = list(src_dst.transform)
        w = src_dst.width
        h = src_dst.height

    resolution = max(abs(aff[0]), abs(aff[4]))

    # The maxzoom is defined by finding the minimum difference between
    # the raster resolution and the zoom level resolution
    max_zoom = tms.zoom_for_res(
        resolution, max_z=30, zoom_level_strategy=zoom_level_strategy,
    )

    # The minzoom is defined by the resolution of the maximum theoretical overview level
    max_possible_overview_level = get_maximum_overview_level(w, h, minsize=tilesize)
    ovr_resolution = resolution * (2 ** max_possible_overview_level)
    min_zoom = tms.zoom_for_res(ovr_resolution, max_z=30)

    return (min_zoom, max_zoom)
def get_zooms ( src_dst : Union [ DatasetReader , DatasetWriter , WarpedVRT ] , tilesize : int = 256 , tms : morecantile . TileMatrixSet = morecantile . tms . get ( "WebMercatorQuad" ) , zoom_level_strategy : str = "auto" , ) -> Tuple [ int , int ] : # If the raster is not in the TMS CRS we calculate its projected properties (height, width, resolution) if src_dst . crs != tms . rasterio_crs : aff , w , h = calculate_default_transform ( src_dst . crs , tms . rasterio_crs , src_dst . width , src_dst . height , * src_dst . bounds , ) else : aff = list ( src_dst . transform ) w = src_dst . width h = src_dst . height resolution = max ( abs ( aff [ 0 ] ) , abs ( aff [ 4 ] ) ) # The maxzoom is defined by finding the minimum difference between # the raster resolution and the zoom level resolution max_zoom = tms . zoom_for_res ( resolution , max_z = 30 , zoom_level_strategy = zoom_level_strategy , ) # The minzoom is defined by the resolution of the maximum theoretical overview level max_possible_overview_level = get_maximum_overview_level ( w , h , minsize = tilesize ) ovr_resolution = resolution * ( 2 ** max_possible_overview_level ) min_zoom = tms . zoom_for_res ( ovr_resolution , max_z = 30 ) return ( min_zoom , max_zoom )