TerrainTileMath
Standard XYZ/slippy-map Web Mercator tile math. Depends on no map stack, so the terrain extractor, the Google flavor's offline maps and MapLibre's node clustering share it.
Functions
lonLatAt for a point given in fractional tile units at zoom, e.g. x = 3.25 is a quarter into column 3.
Inverse of tileAt: the geographic point at a fractional position within tile — localX/localY in the tile's own [0,1]×[0,1] unit square, the same convention ContourPoint uses. Needed to place contour geometry (which ContourGenerator emits tile-local) on a real map; nothing here needed the inverse before.
How many tiles tilesAt would return for zoom/bounds, computed from the two corner indices rather than by materializing the list — stays O(1) per zoom regardless of how large the actual count is. Shared by TerrainRegionExtractor (to bound memory before enumerating) and :feature:map-maplibre's own pre-download estimate shown in the layers sheet.