forked from MapComplete/MapComplete
Chore: housekeeping
This commit is contained in:
parent
4c001d718e
commit
6f7d94890a
29 changed files with 430 additions and 308 deletions
|
@ -41,18 +41,19 @@ function genImages(dryrun = false) {
|
|||
const svgBody = svg
|
||||
.replace(
|
||||
"<svg ",
|
||||
"<svg {...$$$$restProps} on:click on:mouseover on:mouseenter on:mouseleave on:keydown on:focus ",
|
||||
"<svg {...$$$$restProps} on:click on:mouseover on:mouseenter on:mouseleave on:keydown on:focus "
|
||||
)
|
||||
.replace(/\\"/g, "\"")
|
||||
.replace(/\\"/g, '"')
|
||||
.replace(/(rgb\(0%,0%,0%\)|#000000|#000)/g, "{color}")
|
||||
|
||||
const hasColor = svgBody.indexOf("{color}") >= 0
|
||||
|
||||
const svelteCode =
|
||||
["<script>",
|
||||
"export " + (hasColor ? "let" : "const") + " color = \"#000000\"",
|
||||
"</script>",
|
||||
svgBody].join("\n")
|
||||
const svelteCode = [
|
||||
"<script>",
|
||||
"export " + (hasColor ? "let" : "const") + ' color = "#000000"',
|
||||
"</script>",
|
||||
svgBody,
|
||||
].join("\n")
|
||||
|
||||
fs.writeFileSync("./src/assets/svg/" + nameUC + ".svelte", svelteCode, "utf8")
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -130,9 +130,9 @@ export class OsmPoiDatabase {
|
|||
}
|
||||
|
||||
async deleteAllButLatest() {
|
||||
const dbs = await this.findSuitableDatabases() ?? []
|
||||
const dbs = (await this.findSuitableDatabases()) ?? []
|
||||
console.log(["Found databases:", ...dbs].join("\n "))
|
||||
console.log("Database ",dbs.at(-1)," is the latest database and will be preserved")
|
||||
console.log("Database ", dbs.at(-1), " is the latest database and will be preserved")
|
||||
for (let i = 0; i < dbs.length - 1; i++) {
|
||||
await this.deleteDatabase(dbs[i])
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue