From 417dc1633e05b1b4776449eb245739232dea975e Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Mon, 12 Feb 2024 14:14:25 +0100 Subject: [PATCH] Fix: fix #1779, add check to prevent similar errors --- assets/themes/cyclofix/cyclofix.json | 4 +-- src/Logic/ExtraFunctions.ts | 7 +---- .../ThemeConfig/Conversion/PrepareLayer.ts | 2 +- .../ThemeConfig/Conversion/PrepareTheme.ts | 29 ++++++++++++++++++- .../ThemeConfig/Json/LayoutConfigJson.ts | 2 +- 5 files changed, 33 insertions(+), 11 deletions(-) diff --git a/assets/themes/cyclofix/cyclofix.json b/assets/themes/cyclofix/cyclofix.json index a52093c2e9..e1361596fd 100644 --- a/assets/themes/cyclofix/cyclofix.json +++ b/assets/themes/cyclofix/cyclofix.json @@ -87,8 +87,7 @@ "bicycle_rental!=docking_station" ] } - }, - "name": null + } } }, { @@ -99,6 +98,7 @@ "sameAs": "bicycle_rental_non_docking" }, "minzoom": 18, + "name": null, "=pointRendering": [ { "marker": [ diff --git a/src/Logic/ExtraFunctions.ts b/src/Logic/ExtraFunctions.ts index bcdd2c901c..6b034ae983 100644 --- a/src/Logic/ExtraFunctions.ts +++ b/src/Logic/ExtraFunctions.ts @@ -275,12 +275,7 @@ class ClosestNObjectFunc implements ExtraFunction { allFeatures.push([spec]) } } - console.log( - "Determining features which are close to", - features, - "other features:", - allFeatures - ) + if (features === undefined) { return } diff --git a/src/Models/ThemeConfig/Conversion/PrepareLayer.ts b/src/Models/ThemeConfig/Conversion/PrepareLayer.ts index 409d502bf0..b2150de990 100644 --- a/src/Models/ThemeConfig/Conversion/PrepareLayer.ts +++ b/src/Models/ThemeConfig/Conversion/PrepareLayer.ts @@ -1039,7 +1039,7 @@ class SetFullNodeDatabase extends DesugaringStep { if (!needsSpecial) { return json } - context.info("Layer " + json.id + " needs the fullNodeDatabase") + context.debug("Layer " + json.id + " needs the fullNodeDatabase") return { ...json, fullNodeDatabase: true } } } diff --git a/src/Models/ThemeConfig/Conversion/PrepareTheme.ts b/src/Models/ThemeConfig/Conversion/PrepareTheme.ts index bcff31ad9e..6fd08631fa 100644 --- a/src/Models/ThemeConfig/Conversion/PrepareTheme.ts +++ b/src/Models/ThemeConfig/Conversion/PrepareTheme.ts @@ -71,6 +71,7 @@ class SubstituteLayer extends Conversion } } +class PostvalidateTheme extends DesugaringStep { + constructor() { + super("Various validation steps when everything is done", [], "PostvalidateTheme") + } + + convert(json: LayoutConfigJson, context: ConversionContext): LayoutConfigJson { + for (const l of json.layers) { + const layer = l + const basedOn = layer["_basedOn"] + if(!basedOn){ + continue + } + if(layer["name"] === null){ + continue + } + const sameBasedOn = json.layers.filter(l => l["_basedOn"] === layer["_basedOn"]) + const minZoomAll = Math.min(...sameBasedOn.map(sbo => sbo.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.") + } + } + + return json + } +} export class PrepareTheme extends Fuse { private state: DesugaringContext @@ -583,7 +609,8 @@ export class PrepareTheme extends Fuse { ? new Pass("AddDefaultLayers is disabled due to the set flag") : new AddDefaultLayers(state), new AddDependencyLayersToTheme(state), - new AddImportLayers() + new AddImportLayers(), + new PostvalidateTheme() ) this.state = state } diff --git a/src/Models/ThemeConfig/Json/LayoutConfigJson.ts b/src/Models/ThemeConfig/Json/LayoutConfigJson.ts index ad9764bced..0cec5d3841 100644 --- a/src/Models/ThemeConfig/Json/LayoutConfigJson.ts +++ b/src/Models/ThemeConfig/Json/LayoutConfigJson.ts @@ -393,7 +393,7 @@ export interface LayoutConfigJson { * * This is especially useful for hiking maps, skiing maps etc... * - * funset: MapComplete default: don't use terrain + * ifunset: MapComplete default: don't use terrain * iftrue: Use elevation and render 3D * iffalse: Do not use terrain * group: advanced