Warp plan for a picture or tile
32-bit, display onlyHow finely a map image is cut into patches so that it lands in the right place on screen.
tolerance = 0.25 ÷ zoom project units, rounded to a half power of 2
The tolerance is a quarter of a screen pixel at the current zoom. The subdivision depth handed to basemap.js is 0 for a layer already in the drawing's system and 7 otherwise.
// ---------------------------------------------------------------- painting
// V = { T (project → CSS px), w, h, dpr, ox, oy, zoom (CSS px per project unit) }
function planFor(store, key, w, h, pixToSrc, cv, zoom) {
const tolProj = 0.25 / zoom, bucket = Math.round(Math.log2(tolProj) * 2) / 2;
const k = key + '|' + bucket + '|' + fcache.gen;
let plan = store.get(k);
if (!plan) {
plan = B.planWarp((u, v) => { const s = pixToSrc(u, v); try { return cv.fromSrc(s[0], s[1]); } catch { return null; } }, w, h, { tol: 2 ** bucket, maxDepth: cv.same ? 0 : 7 });
if (store.size > 8) store.clear();
store.set(k, plan);
}
return plan;
}