fix: lint
Signed-off-by: Andrew Calcutt <acalcutt@techidiots.net>
This commit is contained in:
parent
052a2753ae
commit
cc664af068
1 changed files with 27 additions and 13 deletions
|
|
@ -49,7 +49,7 @@ const PATH_PATTERN =
|
||||||
const httpTester = /^(http(s)?:)?\/\//;
|
const httpTester = /^(http(s)?:)?\/\//;
|
||||||
|
|
||||||
const mercator = new SphericalMercator();
|
const mercator = new SphericalMercator();
|
||||||
const mercator_512 = new SphericalMercator({size: 512});
|
const mercator_512 = new SphericalMercator({ size: 512 });
|
||||||
const getScale = (scale) => (scale || '@1x').slice(1, 2) | 0;
|
const getScale = (scale) => (scale || '@1x').slice(1, 2) | 0;
|
||||||
|
|
||||||
mlgl.on('message', (e) => {
|
mlgl.on('message', (e) => {
|
||||||
|
|
@ -414,9 +414,8 @@ const respondImage = (
|
||||||
pool = item.map.renderersStatic[scale];
|
pool = item.map.renderersStatic[scale];
|
||||||
}
|
}
|
||||||
pool.acquire((err, renderer) => {
|
pool.acquire((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;
|
||||||
if (width === 512) {
|
if (width === 512) {
|
||||||
mlglZ = Math.max(0, z);
|
mlglZ = Math.max(0, z);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -462,7 +461,10 @@ const respondImage = (
|
||||||
|
|
||||||
if (z > 0 && tileMargin > 0) {
|
if (z > 0 && tileMargin > 0) {
|
||||||
const y = mercator.px(params.center, z)[1];
|
const y = mercator.px(params.center, z)[1];
|
||||||
const yoffset = Math.max(Math.min(0, y - 128 - tileMargin), y + 128 + tileMargin - Math.pow(2, z + 8));
|
const yoffset = Math.max(
|
||||||
|
Math.min(0, y - 128 - tileMargin),
|
||||||
|
y + 128 + tileMargin - Math.pow(2, z + 8),
|
||||||
|
);
|
||||||
image.extract({
|
image.extract({
|
||||||
left: tileMargin * scale,
|
left: tileMargin * scale,
|
||||||
top: (tileMargin + yoffset) * scale,
|
top: (tileMargin + yoffset) * scale,
|
||||||
|
|
@ -472,7 +474,7 @@ const respondImage = (
|
||||||
}
|
}
|
||||||
|
|
||||||
// END 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.
|
// END 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);
|
||||||
}
|
}
|
||||||
// END HACK(Part 2)
|
// END HACK(Part 2)
|
||||||
|
|
@ -576,9 +578,21 @@ export const serve_rendered = {
|
||||||
|
|
||||||
let tileCenter;
|
let tileCenter;
|
||||||
if (tileSize === 512) {
|
if (tileSize === 512) {
|
||||||
tileCenter = mercator_512.ll([((x + 0.5) / (1 << z)) * (tileSize << z),((y + 0.5) / (1 << z)) * (tileSize << z)],z);
|
tileCenter = mercator_512.ll(
|
||||||
|
[
|
||||||
|
((x + 0.5) / (1 << z)) * (tileSize << z),
|
||||||
|
((y + 0.5) / (1 << z)) * (tileSize << z),
|
||||||
|
],
|
||||||
|
z,
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
tileCenter = mercator.ll([((x + 0.5) / (1 << z)) * (tileSize << z),((y + 0.5) / (1 << z)) * (tileSize << z)],z);
|
tileCenter = mercator.ll(
|
||||||
|
[
|
||||||
|
((x + 0.5) / (1 << z)) * (tileSize << z),
|
||||||
|
((y + 0.5) / (1 << z)) * (tileSize << z),
|
||||||
|
],
|
||||||
|
z,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue