Fix loading of editor layer index

This commit is contained in:
Pieter Vander Vennet 2024-08-14 11:41:57 +02:00
parent 1e262359bb
commit 29cfe3672e
5 changed files with 8 additions and 818 deletions

View file

@ -1,6 +1,6 @@
{
"name": "mapcomplete",
"version": "0.45.2",
"version": "0.45.3",
"repository": "https://github.com/pietervdvn/MapComplete",
"description": "A small website to edit OSM easily",
"bugs": "https://github.com/pietervdvn/MapComplete/issues",

View file

@ -12,7 +12,8 @@ class DownloadEli extends Script {
async main(args: string[]): Promise<void> {
const url = "https://osmlab.github.io/editor-layer-index/imagery.geojson"
// Target should use '.json' instead of '.geojson', as the latter cannot be imported by the build systems
const target = args[0] ?? "src/assets/editor-layer-index.json"
const target = args[0] ?? "public/assets/data/editor-layer-index.json"
const targetBing = args[0] ?? "src/assets/bing.json"
const eli: Eli = await Utils.downloadJson(url)
const keptLayers: EliEntry[] = []
@ -104,9 +105,8 @@ class DownloadEli extends Script {
const bing = keptLayers.find(l => l.properties.id === "Bing")
if(bing){
const pth = target.replace(/.json$/, ".bing.json")
fs.writeFileSync(pth, JSON.stringify(bing), { encoding: "utf8" })
console.log("Written", pth)
fs.writeFileSync(targetBing, JSON.stringify(bing), { encoding: "utf8" })
console.log("Written", targetBing)
}else{
console.log("No bing entry found")
}

View file

@ -1,6 +1,6 @@
import { Feature, Polygon } from "geojson"
import * as globallayers from "../assets/global-raster-layers.json"
import * as bingJson from "../assets/editor-layer-index.bing.json"
import * as bingJson from "../assets/bing.json"
import { BBox } from "../Logic/BBox"
import { Store, Stores, UIEventSource } from "../Logic/UIEventSource"
@ -20,7 +20,7 @@ export class AvailableRasterLayers {
return AvailableRasterLayers._editorLayerIndex
}
console.debug("Downloading ELI")
const eli = await Utils.downloadJson<{ features: EditorLayerIndex }>("./src/assets/editor-layer-index.json")
const eli = await Utils.downloadJson<{ features: EditorLayerIndex }>("./assets/data/editor-layer-index.json")
this._editorLayerIndex = eli.features.filter(l => l.properties.id !== "Bing")
this._editorLayerIndexStore.set(this._editorLayerIndex)
return this._editorLayerIndex

View file

@ -1 +1 @@
{"properties":{"name":"Bing Maps Aerial","id":"Bing","url":"https://ecn.t1.tiles.virtualearth.net/tiles/a{quadkey}.jpeg?g=14634&pr=odbl&n=f","type":"bing","category":"photo","min_zoom":1,"max_zoom":22},"type":"Feature","geometry":null}
{"properties":{"name":"Bing Maps Aerial","id":"Bing","url":"https://ecn.t3.tiles.virtualearth.net/tiles/a{quadkey}.jpeg?g=14634&pr=odbl&n=f","type":"bing","category":"photo","min_zoom":1,"max_zoom":22},"type":"Feature","geometry":null}

File diff suppressed because one or more lines are too long