Themes: add compile time check for 'sameAs'-filters that the referenced layer actually exists
This commit is contained in:
parent
ea00c717de
commit
e188b96561
6 changed files with 25 additions and 4 deletions
|
@ -683,6 +683,10 @@
|
||||||
"en": "Who maintains this bicycle parking?",
|
"en": "Who maintains this bicycle parking?",
|
||||||
"nl": "Wie beheert deze fietsenstalling?"
|
"nl": "Wie beheert deze fietsenstalling?"
|
||||||
},
|
},
|
||||||
|
"render": {
|
||||||
|
"en": "This bicycle parking is maintained by {operator}",
|
||||||
|
"nl": "Deze fietsenstalling wordt beheerd door {operator}"
|
||||||
|
},
|
||||||
"freeform": {
|
"freeform": {
|
||||||
"key": "operator"
|
"key": "operator"
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@
|
||||||
"minzoom": 18,
|
"minzoom": 18,
|
||||||
"name": null,
|
"name": null,
|
||||||
"filter": {
|
"filter": {
|
||||||
"sameAs": "bank_with_atm"
|
"sameAs": "banks_with_atm"
|
||||||
},
|
},
|
||||||
"doCount": false
|
"doCount": false
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,7 +151,7 @@
|
||||||
"override": {
|
"override": {
|
||||||
"name": null,
|
"name": null,
|
||||||
"filter": {
|
"filter": {
|
||||||
"sameAs": "charging_station_ebike"
|
"sameAs": "charging_station_ebikes"
|
||||||
},
|
},
|
||||||
"minzoom": 18
|
"minzoom": 18
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@
|
||||||
"=name": null,
|
"=name": null,
|
||||||
"doCount": false,
|
"doCount": false,
|
||||||
"=filter": {
|
"=filter": {
|
||||||
"sameAs": "erotic-shop"
|
"sameAs": "erotic_shop"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -83,7 +83,7 @@
|
||||||
"override": {
|
"override": {
|
||||||
"name": null,
|
"name": null,
|
||||||
"filter": {
|
"filter": {
|
||||||
"sameAs": "charging_station_ebike"
|
"sameAs": "charging_station_ebikes"
|
||||||
},
|
},
|
||||||
"minzoom": 18,
|
"minzoom": 18,
|
||||||
"=presets": []
|
"=presets": []
|
||||||
|
|
|
@ -600,6 +600,23 @@ class PostvalidateTheme extends DesugaringStep<LayoutConfigJson> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const layer of json.layers) {
|
||||||
|
if(typeof layer === "string"){
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
const config = <LayerConfigJson> layer;
|
||||||
|
const sameAs = config.filter?.["sameAs"]
|
||||||
|
if(!sameAs){
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
const matchingLayer = json.layers.find(l => l["id"] === sameAs)
|
||||||
|
if(!matchingLayer){
|
||||||
|
const closeLayers = Utils.sortedByLevenshteinDistance(sameAs, json.layers, l => l["id"]).map(l => l["id"])
|
||||||
|
context.enters("layers", config.id, "filter","sameAs").err("The layer "+config.id+" follows the filter state of layer "+sameAs+", but no layer with this name was found.\n\tDid you perhaps mean one of: "+closeLayers.slice(0, 3).join(", "))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return json
|
return json
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue