Skip to main content

raster_tile_zoom

Function raster_tile_zoom 

Source
pub fn raster_tile_zoom(bbox: [f64; 4], width_px: u32, tile_size: f64) -> u8
Expand description

Compute tile zoom from bbox width and target pixel width.

Handles anti-meridian bboxes (xmin > xmax) by computing the wrapped width: (EARTH_HALF − xmin) + (xmax + EARTH_HALF). Raster tile zoom as MapLibre picks it for a raster source with tiles of tile_size px: round(zoom + log2(512 / tile_size)) (its roundZoom), i.e. the rounded zoom at which one tile spans tile_size canvas px.