Avoid referring to repo[id] inside asynchronus code as this could already be removed again

This commit is contained in:
Nathan Gass 2020-12-18 19:14:30 +01:00
parent c89a5ae029
commit 005bfe5620

View file

@ -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;