Update serve_rendered.js

This commit is contained in:
acalcutt 2025-01-05 02:02:52 -05:00
parent 340e5db60a
commit 7dddbf77d4

View file

@ -437,7 +437,7 @@ function calcZForBBox(bbox, w, h, query) {
* @param {string} mode Rendering mode ('tile' or 'static'). * @param {string} mode Rendering mode ('tile' or 'static').
* @returns {Promise<void>} * @returns {Promise<void>}
*/ */
const respondImage = async ( async function respondImage(
options, options,
item, item,
z, z,
@ -452,7 +452,7 @@ const respondImage = async (
res, res,
overlay = null, overlay = null,
mode = 'tile', mode = 'tile',
) => { ) {
if ( if (
Math.abs(lon) > 180 || Math.abs(lon) > 180 ||
Math.abs(lat) > 85.06 || Math.abs(lat) > 85.06 ||
@ -485,6 +485,7 @@ const respondImage = async (
} else { } else {
pool = item.map.renderersStatic[scale]; pool = item.map.renderersStatic[scale];
} }
pool.acquire(async (err, renderer) => { pool.acquire(async (err, renderer) => {
// For 512px tiles, use the actual maplibre-native zoom. For 256px tiles, use zoom - 1 // For 512px tiles, use the actual maplibre-native zoom. For 256px tiles, use zoom - 1
let mlglZ; let mlglZ;
@ -544,8 +545,8 @@ const respondImage = async (
height: height * scale, height: height * scale,
}); });
} }
// HACK(Part 2) 256px tiles are a zoom level lower than maplibre-native default tiles. this hack allows tileserver-gl to support zoom 0 256px tiles, which would actually be zoom -1 in maplibre-native. Since zoom -1 isn't supported, a double sized zoom 0 tile is requested and resized here. // HACK(Part 2) 256px tiles are a zoom level lower than maplibre-native default tiles. this hack allows tileserver-gl to support zoom 0 256px tiles, which would actually be zoom -1 in maplibre-native. Since zoom -1 isn't supported, a double sized zoom 0 tile is requested and resized here.
if (z === 0 && width === 256) { if (z === 0 && width === 256) {
image.resize(width * scale, height * scale); image.resize(width * scale, height * scale);
} }
@ -619,7 +620,7 @@ const respondImage = async (
}); });
}); });
}); });
}; }
/** /**
* Handles requests for tile images. * Handles requests for tile images.