From 441d8467fe09f0ee4842c40965cd36cf676521f8 Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Tue, 12 Jul 2022 10:23:45 +0200 Subject: [PATCH] Fix rainbox theme and add improvements --- Customizations/AllKnownLayouts.ts | 2 +- Models/ThemeConfig/LayerConfig.ts | 3 + Models/ThemeConfig/TagRenderingConfig.ts | 6 +- .../rainbow_crossings/rainbow_crossings.json | 39 +++++++---- .../mapcomplete-changes.json | 4 ++ assets/themes/rainbow_crossings/crossing.svg | 66 +++++++++++++++++++ .../rainbow_crossings/license_info.json | 10 ++- .../rainbow_crossings/rainbow_crossings.json | 23 ++++++- 8 files changed, 135 insertions(+), 18 deletions(-) create mode 100644 assets/themes/rainbow_crossings/crossing.svg diff --git a/Customizations/AllKnownLayouts.ts b/Customizations/AllKnownLayouts.ts index 82e969564..3bfa56f93 100644 --- a/Customizations/AllKnownLayouts.ts +++ b/Customizations/AllKnownLayouts.ts @@ -19,7 +19,7 @@ export class AllKnownLayouts { public static AllPublicLayers(options?: { includeInlineLayers:true | boolean - }) { + }) : LayerConfig[] { const allLayers: LayerConfig[] = [] const seendIds = new Set() AllKnownLayouts.sharedLayers.forEach((layer, key) => { diff --git a/Models/ThemeConfig/LayerConfig.ts b/Models/ThemeConfig/LayerConfig.ts index 4779f5ebc..0582c57ac 100644 --- a/Models/ThemeConfig/LayerConfig.ts +++ b/Models/ThemeConfig/LayerConfig.ts @@ -191,6 +191,9 @@ export default class LayerConfig extends WithContextLoader { this.doNotDownload = json.doNotDownload ?? false; this.passAllFeatures = json.passAllFeatures ?? false; this.minzoom = json.minzoom ?? 0; + if(json["minZoom"] !== undefined){ + throw "At "+context+": minzoom is written all lowercase" + } this.minzoomVisible = json.minzoomVisible ?? this.minzoom; this.shownByDefault = json.shownByDefault ?? true; this.forceLoad = json.forceLoad ?? false; diff --git a/Models/ThemeConfig/TagRenderingConfig.ts b/Models/ThemeConfig/TagRenderingConfig.ts index 67141780b..656d880de 100644 --- a/Models/ThemeConfig/TagRenderingConfig.ts +++ b/Models/ThemeConfig/TagRenderingConfig.ts @@ -364,7 +364,7 @@ export default class TagRenderingConfig { * Returns true if it is known or not shown, false if the question should be asked * @constructor */ - public IsKnown(tags: any): boolean { + public IsKnown(tags: Record): boolean { if (this.condition && !this.condition.matchesProperties(tags)) { // Filtered away by the condition, so it is kindof known @@ -400,7 +400,7 @@ export default class TagRenderingConfig { * @param tags * @constructor */ - public GetRenderValues(tags: any): { then: Translation, icon?: string, iconClass?: string }[] { + public GetRenderValues(tags: Record): { then: Translation, icon?: string, iconClass?: string }[] { if (!this.multiAnswer) { return [this.GetRenderValueWithImage(tags)] } @@ -410,7 +410,7 @@ export default class TagRenderingConfig { let freeformKeyDefined = this.freeform?.key !== undefined; let usedFreeformValues = new Set() // We run over all the mappings first, to check if the mapping matches - const applicableMappings: { then: TypedTranslation, img?: string }[] = Utils.NoNull((this.mappings ?? [])?.map(mapping => { + const applicableMappings: { then: TypedTranslation>, img?: string }[] = Utils.NoNull((this.mappings ?? [])?.map(mapping => { if (mapping.if === undefined) { return mapping; } diff --git a/assets/layers/rainbow_crossings/rainbow_crossings.json b/assets/layers/rainbow_crossings/rainbow_crossings.json index 9e8179c20..35c99d8d9 100644 --- a/assets/layers/rainbow_crossings/rainbow_crossings.json +++ b/assets/layers/rainbow_crossings/rainbow_crossings.json @@ -4,12 +4,11 @@ "en": "Crossings with rainbow paintings" }, "description": { - "en": "Crossings with decorative rainbow paintings" + "en": "A layer showing pedestrian crossings with rainbow paintings" }, "source": { - "osmTags": { + "osmTags": "highway=crossing" - } }, "minzoom": 17, "title": { @@ -35,9 +34,11 @@ "snapToLayer": "cycleways_and_roads", "maxSnapDistance": 25 } - }, + } + ], "tagRenderings": [ - { + "images", + { "id": "crossing-with-rainbow", "question": { "en": "Does this crossing has rainbow paintings?" @@ -48,13 +49,26 @@ "if": "crossing:marking=rainbow", "then": { "en": "This crossing has rainbow paintings" + }, + "icon": { + "path": "./assets/themes/rainbow_crossings/logo.svg", + "class": "medium" } }, + { + "if": "not:crossing:marking=rainbow", + "then": { + "en": "No rainbow paintings here" + }, + "icon": "./assets/themes/rainbow_crossings/crossing.svg" + }, { "if": "crossing:marking!=rainbow", "then": { "en": "No rainbow paintings here" - } + }, + "icon": "./assets/themes/rainbow_crossings/crossing.svg", + "hideInAnswer": true } ] } @@ -62,16 +76,17 @@ "mapRendering": [ { "icon": { - "render": "./assets/themes/rainbow_crossings/logo.svg" + "render": "./assets/themes/rainbow_crossings/crossing.svg", + "mappings": [{ + "if": "crossing:marking=rainbow", + "then": "./assets/themes/rainbow_crossings/logo.svg" + }] }, - "iconSize": "40,40,bottom", + "iconSize": "40,40,center", "location": [ "point", "centroid" ] } - ], - "description": { - "en": "A layer showing pedestrian crossings with rainbow paintings" - } + ] } diff --git a/assets/themes/mapcomplete-changes/mapcomplete-changes.json b/assets/themes/mapcomplete-changes/mapcomplete-changes.json index db1b9bd23..60452cb5b 100644 --- a/assets/themes/mapcomplete-changes/mapcomplete-changes.json +++ b/assets/themes/mapcomplete-changes/mapcomplete-changes.json @@ -279,6 +279,10 @@ "if": "theme=postboxes", "then": "./assets/themes/postboxes/postbox.svg" }, + { + "if": "theme=rainbow_crossings", + "then": "./assets/themes/rainbow_crossings/logo.svg" + }, { "if": "theme=shops", "then": "./assets/themes/shops/shop.svg" diff --git a/assets/themes/rainbow_crossings/crossing.svg b/assets/themes/rainbow_crossings/crossing.svg new file mode 100644 index 000000000..37304af0f --- /dev/null +++ b/assets/themes/rainbow_crossings/crossing.svg @@ -0,0 +1,66 @@ + + + + + + + + + diff --git a/assets/themes/rainbow_crossings/license_info.json b/assets/themes/rainbow_crossings/license_info.json index 1e701de22..ff2acdfd7 100644 --- a/assets/themes/rainbow_crossings/license_info.json +++ b/assets/themes/rainbow_crossings/license_info.json @@ -1,4 +1,12 @@ [ + { + "path": "crossing.svg", + "license": "CC0", + "authors": [ + "bxl-forever" + ], + "sources": [] + }, { "path": "logo.svg", "license": "CC0", @@ -7,4 +15,4 @@ ], "sources": [] } -] +] \ No newline at end of file diff --git a/assets/themes/rainbow_crossings/rainbow_crossings.json b/assets/themes/rainbow_crossings/rainbow_crossings.json index 84602a67f..d05e6c5f6 100644 --- a/assets/themes/rainbow_crossings/rainbow_crossings.json +++ b/assets/themes/rainbow_crossings/rainbow_crossings.json @@ -15,7 +15,28 @@ "startZoom": 16, "widenFactor": 2, "layers": [ - "rainbow_crossings" + "rainbow_crossings", + { + "builtin": "rainbow_crossings", + "override": { + "minzoom": 10, + "id": "rainbow_crossing_high_zoom", + "name": null, + "=presets": [], + "source": { + "osmTags": { + "and+": ["crossing:marking=rainbow"] + } + } + } + }, + { + "builtin": "cycleways_and_roads", + "override": { + "minzoom": 18, + "name": null + } + } ] }