forked from MapComplete/MapComplete
Themes: fix validation errors due to #1779
This commit is contained in:
parent
7dc43f933e
commit
707d99619d
4 changed files with 18 additions and 7 deletions
|
@ -38,7 +38,6 @@
|
||||||
"builtin": "bank",
|
"builtin": "bank",
|
||||||
"override": {
|
"override": {
|
||||||
"id": "banks_with_atm",
|
"id": "banks_with_atm",
|
||||||
"name": null,
|
|
||||||
"minzoom": 14,
|
"minzoom": 14,
|
||||||
"source": {
|
"source": {
|
||||||
"osmTags": {
|
"osmTags": {
|
||||||
|
@ -56,6 +55,7 @@
|
||||||
"builtin": "bank",
|
"builtin": "bank",
|
||||||
"override": {
|
"override": {
|
||||||
"minzoom": 18,
|
"minzoom": 18,
|
||||||
|
"name": null,
|
||||||
"filter": {
|
"filter": {
|
||||||
"sameAs": "bank_with_atm"
|
"sameAs": "bank_with_atm"
|
||||||
}
|
}
|
||||||
|
@ -167,6 +167,7 @@
|
||||||
"builtin": "postoffices",
|
"builtin": "postoffices",
|
||||||
"override": {
|
"override": {
|
||||||
"minzoom": 18,
|
"minzoom": 18,
|
||||||
|
"name": null,
|
||||||
"filter": {
|
"filter": {
|
||||||
"sameAs": "post_offices_with_atm"
|
"sameAs": "post_offices_with_atm"
|
||||||
}
|
}
|
||||||
|
|
|
@ -393,6 +393,7 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"minzoom": 16,
|
"minzoom": 16,
|
||||||
|
"name": null,
|
||||||
"+tagRenderings": [
|
"+tagRenderings": [
|
||||||
{
|
{
|
||||||
"id": "repairs_climbing_shoes",
|
"id": "repairs_climbing_shoes",
|
||||||
|
|
|
@ -110,9 +110,9 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"builtin": "shops",
|
"builtin": "shops",
|
||||||
"=presets": [],
|
|
||||||
"=name": null,
|
|
||||||
"override": {
|
"override": {
|
||||||
|
"=presets": [],
|
||||||
|
"name": null,
|
||||||
"minzoom": 18
|
"minzoom": 18
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -557,24 +557,33 @@ class WarnForUnsubstitutedLayersInTheme extends DesugaringStep<LayoutConfigJson>
|
||||||
}
|
}
|
||||||
|
|
||||||
class PostvalidateTheme extends DesugaringStep<LayoutConfigJson> {
|
class PostvalidateTheme extends DesugaringStep<LayoutConfigJson> {
|
||||||
constructor() {
|
private readonly _state: DesugaringContext
|
||||||
|
constructor(state: DesugaringContext) {
|
||||||
super("Various validation steps when everything is done", [], "PostvalidateTheme")
|
super("Various validation steps when everything is done", [], "PostvalidateTheme")
|
||||||
|
this._state = state
|
||||||
}
|
}
|
||||||
|
|
||||||
convert(json: LayoutConfigJson, context: ConversionContext): LayoutConfigJson {
|
convert(json: LayoutConfigJson, context: ConversionContext): LayoutConfigJson {
|
||||||
for (const l of json.layers) {
|
for (const l of json.layers) {
|
||||||
const layer = <LayerConfigJson> l
|
const layer = <LayerConfigJson> l
|
||||||
const basedOn = <string> layer["_basedOn"]
|
const basedOn = <string> layer["_basedOn"]
|
||||||
|
const basedOnDef = this._state.sharedLayers.get(basedOn)
|
||||||
if(!basedOn){
|
if(!basedOn){
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if(layer["name"] === null){
|
if(layer["name"] === null){
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
const sameBasedOn = <LayerConfigJson[]> json.layers.filter(l => l["_basedOn"] === layer["_basedOn"])
|
const sameBasedOn = <LayerConfigJson[]> json.layers.filter(l => l["_basedOn"] === layer["_basedOn"] && l["id"] !== layer.id)
|
||||||
const minZoomAll = Math.min(...sameBasedOn.map(sbo => sbo.minzoom))
|
const minZoomAll = Math.min(...sameBasedOn.map(sbo => sbo.minzoom))
|
||||||
|
|
||||||
|
const sameNameDetected = sameBasedOn.some( same => JSON.stringify(layer["name"]) === JSON.stringify(same["name"]))
|
||||||
|
if(!sameNameDetected){
|
||||||
|
// The name is unique, so it'll won't be confusing
|
||||||
|
continue
|
||||||
|
}
|
||||||
if(minZoomAll < layer.minzoom){
|
if(minZoomAll < layer.minzoom){
|
||||||
context.err("There are multiple layers based on "+basedOn+". The layer with id "+layer.id+" has a minzoom of "+layer.minzoom+", but has no name set. Another similar layer has a lower minzoom. As such, the layer selection might show 'zoom in to see features' even though some of the features are already visible. Set `\"name\": null` for this layer and eventually remove the 'name':null for the other layer.")
|
context.err("There are multiple layers based on "+basedOn+". The layer with id "+layer.id+" has a minzoom of "+layer.minzoom+", and has a name set. Another similar layer has a lower minzoom. As such, the layer selection might show 'zoom in to see features' even though some of the features are already visible. Set `\"name\": null` for this layer and eventually remove the 'name':null for the other layer.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -610,7 +619,7 @@ export class PrepareTheme extends Fuse<LayoutConfigJson> {
|
||||||
: new AddDefaultLayers(state),
|
: new AddDefaultLayers(state),
|
||||||
new AddDependencyLayersToTheme(state),
|
new AddDependencyLayersToTheme(state),
|
||||||
new AddImportLayers(),
|
new AddImportLayers(),
|
||||||
new PostvalidateTheme()
|
new PostvalidateTheme(state)
|
||||||
)
|
)
|
||||||
this.state = state
|
this.state = state
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue