From edf7dba9e304da65f801a748792b3499bff092f4 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Mon, 13 Nov 2023 13:45:22 +0100 Subject: [PATCH] Fix themes, fix tests --- assets/themes/grb/grb.json | 6 +- assets/themes/grb_fixme/grb_fixme.json | 253 ------------------ assets/themes/postal_codes/postal_codes.json | 43 ++- assets/themes/sidewalks/sidewalks.json | 82 +++++- assets/themes/speelplekken/speelplekken.json | 28 +- assets/themes/stations/stations.json | 43 ++- .../street_lighting/street_lighting.json | 20 +- .../street_lighting_assen.json | 27 +- assets/themes/uk_addresses/uk_addresses.json | 2 +- assets/themes/walkingnodes/walkingnodes.json | 1 + assets/themes/waste_assen/waste_assen.json | 56 +++- assets/themes/width/width.json | 71 ++++- .../ThemeConfig/Conversion/Conversion.ts | 3 +- .../ThemeConfig/Conversion/Validation.ts | 9 +- .../ThemeConfig/Json/LayerConfigJson.ts | 1 + src/Models/ThemeConfig/LayerConfig.ts | 2 +- 16 files changed, 350 insertions(+), 297 deletions(-) delete mode 100644 assets/themes/grb_fixme/grb_fixme.json diff --git a/assets/themes/grb/grb.json b/assets/themes/grb/grb.json index 8712d62dc..6d5ac7508 100644 --- a/assets/themes/grb/grb.json +++ b/assets/themes/grb/grb.json @@ -232,7 +232,7 @@ ] } ], - "pointRendering": [], + "pointRendering": null, "lineRendering": [ { "width": { @@ -549,7 +549,7 @@ }, "title": "Service road", "tagRenderings": [], - "pointRendering": [], + "pointRendering": null, "lineRendering": [ { "width": 4, "color": "#888888" @@ -594,7 +594,7 @@ "tagRenderings": [ "all_tags" ], - "pointRendering": [], + "pointRendering": null, "lineRendering": [ { "color": "#ccc", diff --git a/assets/themes/grb_fixme/grb_fixme.json b/assets/themes/grb_fixme/grb_fixme.json deleted file mode 100644 index 77a0b209b..000000000 --- a/assets/themes/grb_fixme/grb_fixme.json +++ /dev/null @@ -1,253 +0,0 @@ -{ - "id": "grb_fixme", - "title": { - "nl": "GRB Fixup" - }, - "description": { - "nl": "Gebouwen met een FIXME - wss GRB-import die gefixed moeten worden" - }, - "shortDescription": { - "nl": "Grb Fixup" - }, - "icon": "./assets/svg/bug.svg", - "startZoom": 14, - "startLat": 51.2132, - "startLon": 3.231, - "defaultBackgroundId": "AGIVFlandersGRB", - "hideFromOverview": true, - "layers": [ - { - "id": "osm-buildings-fixme", - "name": "OSM-buildings with a fixme", - "source": { - "osmTags": { - "and": [ - "building~*", - "fixme~*" - ] - }, - "maxCacheAge": 0 - }, - "calculatedTags": [ - "_grbNumber=(feat.properties.fixme?.match(/GRB thinks that this has number ([0-9a-zA-Z;]+)/) ?? ['','none']) [1]" - ], - "title": "OSM-gebouw", - "tagRenderings": [ - { - "id": "building type", - "freeform": { - "key": "building" - }, - "render": "The building type is {building}", - "question": { - "en": "What kind of building is this?", - "de": "Was ist das für ein Gebäude?", - "es": "¿Qué tipo de este edificio es este?", - "nl": "Wat voor soort gebouw is dit?", - "fr": "De quel type de bâtiment s’agit-il ?", - "nb_NO": "Hva slags bygning er dette?", - "da": "Hvad er det for en bygning?", - "cs": "Jaký druh budovy je toto?", - "ca": "Quin tipus d'edifici és aquest?", - "pl": "Jaki to rodzaj budynku?" - }, - "mappings": [ - { - "if": "building=house", - "then": "A normal house" - }, - { - "if": "building=detached", - "then": "A house detached from other building" - }, - { - "if": "building=semidetached_house", - "then": "A house sharing only one wall with another house" - }, - { - "if": "building=apartments", - "then": "An apartment building (a highrise building for living)" - }, - { - "if": "building=office", - "then": "An office building - highrise for work" - }, - { - "if": "building=shed", - "then": "A small shed, e.g. in a garden" - }, - { - "if": "building=garage", - "then": "A single garage to park a car" - }, - { - "if": "building=garages", - "then": "A building containing only garages; typically they are all identical" - }, - { - "if": "building=yes", - "then": "A building - no specification" - } - ] - }, - { - "id": "grb-housenumber", - "render": { - "nl": "Het huisnummer is {addr:housenumber}" - }, - "question": { - "nl": "Wat is het huisnummer?" - }, - "freeform": { - "key": "addr:housenumber" - }, - "mappings": [ - { - "if": { - "and": [ - "not:addr:housenumber=yes", - "addr:housenumber=" - ] - }, - "then": { - "nl": "Geen huisnummer" - } - }, - { - "if": { - "and": [ - "addr:housenumber:={_grbNumber}", - "fixme=" - ] - }, - "then": "Het huisnummer is {_grbNumber}, wat overeenkomt met het GRB", - "hideInAnswer": { - "or": [ - "_grbNumber=", - "_grbNumber=none", - "_grbNumber=no number" - ] - } - }, - { - "if": { - "and": [ - "addr:housenumber=", - "not:addr:housenumber=yes", - "fixme=" - ] - }, - "then": "Dit gebouw heeft geen nummer, net zoals in het GRB", - "hideInAnswer": "_grbNumber!=no number" - } - ] - }, - { - "id": "grb-unit", - "question": "Wat is de wooneenheid-aanduiding?", - "render": { - "nl": "De wooneenheid-aanduiding is {addr:unit} " - }, - "freeform": { - "key": "addr:unit" - }, - "mappings": [ - { - "if": "addr:unit=", - "then": "Geen wooneenheid-nummer" - } - ] - }, - { - "id": "grb-street", - "render": { - "nl": "De straat is {addr:street}" - }, - "freeform": { - "key": "addr:street" - }, - "question": { - "nl": "Wat is de straat?" - } - }, - { - "id": "grb-fixme", - "render": { - "nl": "De fixme is {fixme}" - }, - "question": { - "nl": "Wat zegt de fixme?" - }, - "freeform": { - "key": "fixme" - }, - "mappings": [ - { - "if": { - "and": [ - "fixme=" - ] - }, - "then": { - "nl": "Geen fixme" - } - } - ] - }, - { - "id": "grb-min-level", - "render": { - "nl": "Dit gebouw begint maar op de {building:min_level} verdieping" - }, - "question": { - "nl": "Hoeveel verdiepingen ontbreken?" - }, - "freeform": { - "key": "building:min_level", - "type": "pnat" - } - }, - { - "id": "fix_verdieping", - "render": "{tag_apply(fixme=;building:min_level=1,De eerste verdieping ontbreekt)}", - "condition": "fixme=verdieping, correct the building tag, add building:level and building:min_level before upload in JOSM!" - }, - "all_tags" - ], - "minzoom": 14, - "pointRendering": [], - "lineRendering": [ - {} - ] - }, - { - "builtin": "address", - "override": { - "minzoom": 18 - } - }, - { - "builtin": "crab_address", - "override": { - "minzoom": 18, - "+tagRenderings": [ - { - "id": "import-button", - "render": "{import_button(address, addr:street=$STRAATNM; addr:housenumber=$HUISNR,Import this address)}" - } - ] - } - } - ], - "overrideAll": { - "source": { - "maxCacheAge": 0 - } - }, - "widenFactor": 2, - "overpassMaxZoom": 15, - "osmApiTileSize": 17, - "clustering": { - "maxZoom": 15 - } -} \ No newline at end of file diff --git a/assets/themes/postal_codes/postal_codes.json b/assets/themes/postal_codes/postal_codes.json index 0ec523fa4..2ae872fe1 100644 --- a/assets/themes/postal_codes/postal_codes.json +++ b/assets/themes/postal_codes/postal_codes.json @@ -124,9 +124,22 @@ } }, "isShown": "_country=be", - "pointRendering": [], + "pointRendering": [ + { + "label": "
{postal_code}
", + "location": [ + "point", + "centroid" + ] + } + ], "lineRendering": [ - {} + { + "color": "#00f", + "width": "4", + "fill": "no", + "dashArray": "8 8" + } ] }, { @@ -140,9 +153,12 @@ } }, "title": "Boundary relation with addr:postcode={addr:postcode}", - "pointRendering": [], + "pointRendering": null, "lineRendering": [ - {} + { + "color": "#f00", + "width": 1 + } ] }, { @@ -197,13 +213,24 @@ } }, "isShown": "_country=be", - "pointRendering": [], - "lineRendering": [ - {} + "pointRendering": [ + { + "marker": [ + { + "icon": "./assets/themes/postal_codes/townhall.svg" + } + ], + "iconSize": "40,40", + "location": [ + "point", + "centroid" + ], + "anchor": "center" + } ] } ], "overpassTimeout": 180, "widenFactor": 0.05, "clustering": false -} \ No newline at end of file +} diff --git a/assets/themes/sidewalks/sidewalks.json b/assets/themes/sidewalks/sidewalks.json index 9737577b8..03b439468 100644 --- a/assets/themes/sidewalks/sidewalks.json +++ b/assets/themes/sidewalks/sidewalks.json @@ -247,11 +247,87 @@ } ], "allowSplit": true, - "pointRendering": [], + "pointRendering": [ + { + "location": [ + "start", + "end" + ], + "marker": [ + { + "icon": "circle:#ccc" + } + ], + "iconSize": "3,3", + "anchor": "center" + } + ], "lineRendering": [ - {} + { + "#": "The center line", + "color": "#ffffff55", + "width": 8, + "lineCap": "butt" + }, + { + "#": "left", + "color": "#888", + "dashArray": { + "render": "", + "mappings": [ + { + "if": "sidewalk:left=", + "then": "1,12" + } + ] + }, + "width": { + "render": 6, + "mappings": [ + { + "if": { + "or": [ + "sidewalk:left=no", + "sidewalk:left=separate" + ] + }, + "then": 0 + } + ] + }, + "offset": -6, + "lineCap": "butt" + }, + { + "color": "#888", + "dashArray": { + "render": "", + "mappings": [ + { + "if": "sidewalk:right=", + "then": "1,12" + } + ] + }, + "width": { + "render": 6, + "mappings": [ + { + "if": { + "or": [ + "sidewalk:right=no", + "sidewalk:right=separate" + ] + }, + "then": 0 + } + ] + }, + "lineCap": "butt", + "offset": 6 + } ] } ], "widenFactor": 0.05 -} \ No newline at end of file +} diff --git a/assets/themes/speelplekken/speelplekken.json b/assets/themes/speelplekken/speelplekken.json index 58681c9c3..7955d434a 100644 --- a/assets/themes/speelplekken/speelplekken.json +++ b/assets/themes/speelplekken/speelplekken.json @@ -26,9 +26,12 @@ "osmTags": "shadow=yes", "isOsmCache": false }, - "pointRendering": [], + "pointRendering": null, "lineRendering": [ - {} + { + "color": "#444444", + "width": "1" + } ] }, { @@ -208,9 +211,24 @@ "questions", "reviews" ], - "pointRendering": [], + "pointRendering": null, "lineRendering": [ - {} + { + "color": { + "render": "#6d6", + "mappings": [ + { + "if": "color~*", + "then": "{color}" + }, + { + "if": "colour~*", + "then": "{colour}" + } + ] + }, + "width": "9" + } ] } ], @@ -247,4 +265,4 @@ "maxZoom": 6, "minNeededElements": 100 } -} \ No newline at end of file +} diff --git a/assets/themes/stations/stations.json b/assets/themes/stations/stations.json index 8a219926c..c2ad5612c 100644 --- a/assets/themes/stations/stations.json +++ b/assets/themes/stations/stations.json @@ -31,8 +31,7 @@ "override": { "minzoom": 18, "passAllFeatures": true, - "=pointRendering": [ - ] + "=pointRendering": null } }, { @@ -86,9 +85,31 @@ "zh_Hant": "顯示火車站的圖層", "pl": "Warstwa pokazująca stacje kolejowe" }, - "pointRendering": [], + "pointRendering": [ + { + "marker": [ + { + "icon": "./assets/themes/stations/rail-light.svg" + } + ], + "location": [ + "point", + "centroid" + ], + "label": { + "mappings": [ + { + "if": "name~*", + "then": "
{name}
" + } + ] + } + } + ], "lineRendering": [ - {} + { + "color": "green" + } ] }, { @@ -408,7 +429,19 @@ } } ], - "pointRendering": [], + "pointRendering": [ + { + "marker": [ + { + "icon": "./assets/themes/stations/departures_board.svg" + } + ], + "location": [ + "point", + "centroid" + ] + } + ], "lineRendering": [ {} ] diff --git a/assets/themes/street_lighting/street_lighting.json b/assets/themes/street_lighting/street_lighting.json index e2428ac36..98ff87cc2 100644 --- a/assets/themes/street_lighting/street_lighting.json +++ b/assets/themes/street_lighting/street_lighting.json @@ -190,9 +190,11 @@ } ], "allowSplit": true, - "pointRendering": [], + "pointRendering": null, "lineRendering": [ - {} + { + "color": "#ff0" + } ] }, { @@ -347,9 +349,19 @@ } ], "allowSplit": true, - "pointRendering": [], + "pointRendering": null, "lineRendering": [ - {} + { + "color": { + "render": "#a9a9a9", + "mappings": [ + { + "if": "lit=no", + "then": "#303030" + } + ] + } + } ] } ] diff --git a/assets/themes/street_lighting_assen/street_lighting_assen.json b/assets/themes/street_lighting_assen/street_lighting_assen.json index 31f2f733c..ba2f8ed18 100644 --- a/assets/themes/street_lighting_assen/street_lighting_assen.json +++ b/assets/themes/street_lighting_assen/street_lighting_assen.json @@ -35,9 +35,30 @@ "tagRenderings": [ "all_tags" ], - "pointRendering": [], + "pointRendering": [ + { + "location": [ + "point", + "centroid" + ], + "marker": [ + { + "icon": { + "render": "circle:red", + "mappings": [ + { + "if": "_has_closeby_feature=yes", + "then": "circle:#008000aa" + } + ] + } + } + ], + "iconSize": "20,20", + "anchor": "center" + } + ], "lineRendering": [ - {} ] }, { @@ -57,4 +78,4 @@ } } ] -} \ No newline at end of file +} diff --git a/assets/themes/uk_addresses/uk_addresses.json b/assets/themes/uk_addresses/uk_addresses.json index eb7b21daa..ced25c6d2 100644 --- a/assets/themes/uk_addresses/uk_addresses.json +++ b/assets/themes/uk_addresses/uk_addresses.json @@ -43,7 +43,7 @@ "name": { "en": "Inspire polygons" }, - "pointRendering": [], + "pointRendering": null, "lineRendering": [ { "width": 2, diff --git a/assets/themes/walkingnodes/walkingnodes.json b/assets/themes/walkingnodes/walkingnodes.json index b709cdfc8..c5a21e783 100644 --- a/assets/themes/walkingnodes/walkingnodes.json +++ b/assets/themes/walkingnodes/walkingnodes.json @@ -72,6 +72,7 @@ "color": "#452b29" } ], + "pointRendering":null, "tagRenderings": [ { "builtin": "survey_date", diff --git a/assets/themes/waste_assen/waste_assen.json b/assets/themes/waste_assen/waste_assen.json index 57e627bb6..9d7fdd68d 100644 --- a/assets/themes/waste_assen/waste_assen.json +++ b/assets/themes/waste_assen/waste_assen.json @@ -39,9 +39,30 @@ "tagRenderings": [ "all_tags" ], - "pointRendering": [], + "pointRendering": [ + { + "location": [ + "point", + "centroid" + ], + "marker": [ + { + "icon": { + "render": "circle:red", + "mappings": [ + { + "if": "_has_closeby_feature=yes", + "then": "circle:#008000aa" + } + ] + } + } + ], + "iconSize": "20,20", + "anchor": "center" + } + ], "lineRendering": [ - {} ] }, "recycling", @@ -66,11 +87,36 @@ "tagRenderings": [ "all_tags" ], - "pointRendering": [], + "pointRendering": [ + { + "location": [ + "point", + "centroid" + ], + "marker": [ + { + "icon": { + "render": "circle:red", + "mappings": [ + { + "if": "_has_closeby_recycling=yes", + "then": "circle:#008000aa" + }, + { + "if": "_has_closeby_waste_disposal=yes", + "then": "circle:#008000aa" + } + ] + } + } + ], + "iconSize": "20,20", + "anchor": "center" + } + ], "lineRendering": [ - {} ] }, "waste_disposal" ] -} \ No newline at end of file +} diff --git a/assets/themes/width/width.json b/assets/themes/width/width.json index 43163a44e..0e0f29a70 100644 --- a/assets/themes/width/width.json +++ b/assets/themes/width/width.json @@ -186,9 +186,76 @@ ] } ], - "pointRendering": [], + "pointRendering": [ + { + "location": [ + "point" + ], + "marker": [ + { + "icon": "./assets/themes/width/icon.svg" + } + ], + "iconSize": "40,40", + "anchor": "center" + } + ], "lineRendering": [ - {} + { + "width": "4", + "color": { + "render": "#00f", + "mappings": [ + { + "if": { + "or": [ + "access=destination", + "highway=pedestrian", + "motor_vehicle=no", + "motor_vehicle=destination" + ] + }, + "then": "lightgrey" + }, + { + "if": { + "and": [ + "_width:difference!~-.*", + "_width:difference:no_pedestrians~-.*" + ] + }, + "then": "orange" + }, + { + "if": "_width:difference~-.*", + "then": "#0f0" + }, + { + "if": "_width:difference!~-.*", + "then": "#f00" + } + ] + }, + "dashArray": { + "render": "", + "mappings": [ + { + "if": { + "and": [ + "oneway=yes", + { + "or": [ + "oneway:bicycle=yes", + "oneway:bicycle=" + ] + } + ] + }, + "then": "5 6" + } + ] + } + } ] } ], diff --git a/src/Models/ThemeConfig/Conversion/Conversion.ts b/src/Models/ThemeConfig/Conversion/Conversion.ts index 745ce2ce7..b6422bd55 100644 --- a/src/Models/ThemeConfig/Conversion/Conversion.ts +++ b/src/Models/ThemeConfig/Conversion/Conversion.ts @@ -110,8 +110,7 @@ export class Each extends Conversion { values[i]?.["id"] !== undefined ? values[i]?.["id"] : "" ) } - const context_ = c.enter(i) - const r = step.convert(values[i], context_) + const r = step.convert(values[i], c.enter(i)) result.push(r) } return result diff --git a/src/Models/ThemeConfig/Conversion/Validation.ts b/src/Models/ThemeConfig/Conversion/Validation.ts index 5997da11d..25fca25c1 100644 --- a/src/Models/ThemeConfig/Conversion/Validation.ts +++ b/src/Models/ThemeConfig/Conversion/Validation.ts @@ -552,7 +552,7 @@ export class DetectShadowedMappings extends DesugaringStep 1 - * context.getAll("error")[0].message.indexOf("The mapping key=value &x=y is fully matched by a previous mapping (namely 0)") >= 0 // => true + * context.getAll("error")[0].message.indexOf("The mapping key=value & x=y is fully matched by a previous mapping (namely 0)") >= 0 // => true */ convert(json: TagRenderingConfigJson, context: ConversionContext): TagRenderingConfigJson { if (json.mappings === undefined || json.mappings.length === 0) { @@ -1067,7 +1067,12 @@ export class PrevalidateLayer extends DesugaringStep { .err("Detected a 'pointRenderingS', it is written singular") } - if (!(json.pointRendering?.length > 0)) { + if ( + !(json.pointRendering?.length > 0) && + json.pointRendering !== null && + json.source !== "special" && + json.source !== "special:library" + ) { context.enter("pointRendering").err("There are no pointRenderings at all...") } diff --git a/src/Models/ThemeConfig/Json/LayerConfigJson.ts b/src/Models/ThemeConfig/Json/LayerConfigJson.ts index a80752a9b..951996ce7 100644 --- a/src/Models/ThemeConfig/Json/LayerConfigJson.ts +++ b/src/Models/ThemeConfig/Json/LayerConfigJson.ts @@ -248,6 +248,7 @@ export interface LayerConfigJson { /** * Creates points to render on the map. * This can render points for point-objects, lineobjects or areaobjects; use 'location' to indicate where it should be rendered + * * group: pointrendering */ pointRendering: PointRenderingConfigJson[] diff --git a/src/Models/ThemeConfig/LayerConfig.ts b/src/Models/ThemeConfig/LayerConfig.ts index 57c6bac55..4d8384c60 100644 --- a/src/Models/ThemeConfig/LayerConfig.ts +++ b/src/Models/ThemeConfig/LayerConfig.ts @@ -219,7 +219,7 @@ export default class LayerConfig extends WithContextLoader { if (json.pointRendering) { this.mapRendering = Utils.NoNull(json.pointRendering).map( - (r, i) => new PointRenderingConfig(r, `${context}[${i}]`) + (r, i) => new PointRenderingConfig(r, `${context}[${i}](${this.id})`) ) } else { this.mapRendering = []