chore: try to explain the zoom=0 special case

Signed-off-by: Martin d'Allens <martin.dallens@liberty-rider.com>
This commit is contained in:
Martin d'Allens 2023-11-21 22:26:30 +01:00
parent 40ade063f9
commit c638a7c449

View file

@ -413,9 +413,8 @@ const respondImage = (
pool = item.map.renderersStatic[scale]; pool = item.map.renderersStatic[scale];
} }
pool.acquire((err, renderer) => { pool.acquire((err, renderer) => {
const mlglZ = Math.max(0, z - 1);
const params = { const params = {
zoom: mlglZ, zoom: z - 1, // Maplibre-native zoom 0 corresponds to our zoom 1.
center: [lon, lat], center: [lon, lat],
bearing, bearing,
pitch, pitch,
@ -424,6 +423,8 @@ const respondImage = (
}; };
if (z === 0) { if (z === 0) {
// params.zoom equals -1
params.zoom = 0;
params.width *= 2; params.width *= 2;
params.height *= 2; params.height *= 2;
} }
@ -464,7 +465,7 @@ const respondImage = (
} }
if (z === 0) { if (z === 0) {
// HACK: when serving zoom 0, resize the 0 tile from 512 to 256 // HACK: when serving zoom 0 (unsupported by Maplibre-native), generate at zoom 1 then downsize.
image.resize(width * scale, height * scale); image.resize(width * scale, height * scale);
} }