From 005bfe5620e35c3fe5b2f295c13a72c4c06c1cf7 Mon Sep 17 00:00:00 2001 From: Nathan Gass Date: Fri, 18 Dec 2020 19:14:30 +0100 Subject: [PATCH] Avoid referring to repo[id] inside asynchronus code as this could already be removed again --- src/serve_rendered.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/serve_rendered.js b/src/serve_rendered.js index 11b6bfb00..289929b13 100644 --- a/src/serve_rendered.js +++ b/src/serve_rendered.js @@ -723,7 +723,7 @@ module.exports = { tileJSON.tiles = params.domains || options.domains; utils.fixTileJSONCenter(tileJSON); - repo[id] = { + const repoobj = { tileJSON, publicUrl, map, @@ -731,6 +731,7 @@ module.exports = { lastModified: new Date().toUTCString(), watermark: params.watermark || options.watermark }; + repo[id] = repoobj; const queue = []; for (const name of Object.keys(styleJSON.sources)) { @@ -771,11 +772,11 @@ module.exports = { return; } - if (!repo[id].dataProjWGStoInternalWGS && info.proj4) { + if (!repoobj.dataProjWGStoInternalWGS && info.proj4) { // how to do this for multiple sources with different proj4 defs? const to3857 = proj4('EPSG:3857'); const toDataProj = proj4(info.proj4); - repo[id].dataProjWGStoInternalWGS = xy => to3857.inverse(toDataProj.forward(xy)); + repoobj.dataProjWGStoInternalWGS = xy => to3857.inverse(toDataProj.forward(xy)); } const type = source.type;