Chore: housekeeping

This commit is contained in:
Pieter Vander Vennet 2025-06-19 21:55:28 +02:00
parent 4c001d718e
commit 6f7d94890a
29 changed files with 430 additions and 308 deletions

View file

@ -300,37 +300,37 @@ class GenerateLayouts extends Script {
if (url.endsWith(".pmtiles")) {
continue
}
try{
console.log("Downloading ", url)
const styleSpec = await Utils.downloadJsonCached(url, 1000 * 120, {
Origin: "https://mapcomplete.org",
})
for (const key of Object.keys(styleSpec?.["sources"] ?? {})) {
const url = styleSpec["sources"][key].url
if (!url) {
continue
}
let urlClipped = url
if (url.indexOf("?") > 0) {
urlClipped = url?.substring(0, url.indexOf("?"))
}
console.log("Source url ", key, url)
urls.push(url)
if (urlClipped.endsWith(".json")) {
const tileInfo = await Utils.downloadJsonCached(url, 1000 * 120, {
Origin: "https://mapcomplete.org",
})
urls.push(tileInfo["tiles"] ?? [])
try {
console.log("Downloading ", url)
const styleSpec = await Utils.downloadJsonCached(url, 1000 * 120, {
Origin: "https://mapcomplete.org",
})
for (const key of Object.keys(styleSpec?.["sources"] ?? {})) {
const url = styleSpec["sources"][key].url
if (!url) {
continue
}
let urlClipped = url
if (url.indexOf("?") > 0) {
urlClipped = url?.substring(0, url.indexOf("?"))
}
console.log("Source url ", key, url)
urls.push(url)
if (urlClipped.endsWith(".json")) {
const tileInfo = await Utils.downloadJsonCached(url, 1000 * 120, {
Origin: "https://mapcomplete.org",
})
urls.push(tileInfo["tiles"] ?? [])
}
}
urls.push(...(styleSpec["tiles"] ?? []))
urls.push(styleSpec["sprite"])
urls.push(styleSpec["glyphs"])
} catch (e) {
console.error(
"ERROR: could not download a resource, some sprites might not be whitelisted and thus not load"
)
}
urls.push(...(styleSpec["tiles"] ?? []))
urls.push(styleSpec["sprite"])
urls.push(styleSpec["glyphs"])
}catch (e) {
console.error("ERROR: could not download a resource, some sprites might not be whitelisted and thus not load")
}
}
}
this.eliUrlsCached = urls