diff --git a/Docs/CalculatedTags.md b/Docs/CalculatedTags.md index c671b9a733..b50322b13c 100644 --- a/Docs/CalculatedTags.md +++ b/Docs/CalculatedTags.md @@ -1,5 +1,6 @@ + Metatags ========== diff --git a/Logic/ExtraFunctions.ts b/Logic/ExtraFunctions.ts index 1a2d4da2b9..450c01cc81 100644 --- a/Logic/ExtraFunctions.ts +++ b/Logic/ExtraFunctions.ts @@ -187,7 +187,7 @@ class DistanceToFunc implements ExtraFunction { class ClosestObjectFunc implements ExtraFunction { _name = "closest" - _doc = "Given either a list of geojson features or a single layer name, gives the single object which is nearest to the feature. In the case of ways/polygons, only the centerpoint is considered. Returns a single geojson feature or undefined if nothing is found (or not yet laoded)" + _doc = "Given either a list of geojson features or a single layer name, gives the single object which is nearest to the feature. In the case of ways/polygons, only the centerpoint is considered. Returns a single geojson feature or undefined if nothing is found (or not yet loaded)" _args = ["list of features or a layer name or '*' to get all features"] diff --git a/Models/ThemeConfig/Conversion/PrepareLayer.ts b/Models/ThemeConfig/Conversion/PrepareLayer.ts index e6c05b5583..e436b31b09 100644 --- a/Models/ThemeConfig/Conversion/PrepareLayer.ts +++ b/Models/ThemeConfig/Conversion/PrepareLayer.ts @@ -469,6 +469,8 @@ export class RewriteSpecial extends DesugaringStep { .replace(/\{/g, "&LBRACE") .replace(/}/g, "&RBRACE") args.push(txt) + } else if(typeof v === "object"){ + args.push(JSON.stringify(v)) } else { args.push(v) } diff --git a/UI/SpecialVisualizations.ts b/UI/SpecialVisualizations.ts index 05cd974546..d10485f4a4 100644 --- a/UI/SpecialVisualizations.ts +++ b/UI/SpecialVisualizations.ts @@ -1202,6 +1202,35 @@ export default class SpecialVisualizations { })) } + }, + { + funcName: "multi", + docs: "Given an embedded tagRendering (read only) and a key, will read the keyname as a JSON-list. Every element of this list will be considered as tags and rendered with the tagRendering", + example: "```json\n"+JSON.stringify({ + render: { + special: { + type: "multi", + key: "_doors_from_building_properties", + tagRendering: { + render: "The building containing this feature has a door of width {entrance:width}" + } + } + } + }, null, " ")+"```", + args: [ + {name: "key", + doc: "The property to read and to interpret as a list of properties"}, + { + name:"tagrendering", + doc: "An entire tagRenderingConfig" + } + ] +, + constr(state, featureTags, args) { + const [key, tr] = args + console.log("MULTI: ", key, tr) + return undefined + } } ] diff --git a/assets/themes/onwheels/onwheels.json b/assets/themes/onwheels/onwheels.json index 9c90f58db6..4301c2823e 100644 --- a/assets/themes/onwheels/onwheels.json +++ b/assets/themes/onwheels/onwheels.json @@ -366,8 +366,10 @@ ], "overrideAll": { "+calculatedTags": [ - "_poi_walls_and_buildings_entrance_properties=feat.closestn('walls_and_buildings', 1, undefined, 1000).map(w => ({id: w.feat.properties.id, width: w.feat.properties['_entrance:width']}))[0]", - "_poi_entrance:id=JSON.parce(feat.properties._poi_walls_and_buildings_entrance_properteis)?.id", + "_poi_walls_and_buildings_entrance_properties=[].concat(...feat.closestn('walls_and_buildings',1, undefined, 500).map(w => ({id: w.feat.properties.id, width: w.feat.properties['_entrance_properties']})))", + "_poi_walls_and_buildings_entrance_count=[].concat(...feat.overlapWith('walls_and_buildings').map(w => ({id: w.feat.properties.id, width: w.feat.properties['_entrance_properties']})))", + "_poi_walls_and_buildings_entrance_properties_with_width=feat.get('_poi_walls_and_buildings_entrance_properties').filter(p => p['width'] !== undefined)", + "_poi_entrance:id=JSON.parse(feat.properties._poi_walls_and_buildings_entrance_properteis)?.id", "_poi_entrance:width=JSON.parse(feat.properties._poi_walls_and_buildings_entrance_properties)?.width" ], "+tagRenderings": [ @@ -381,25 +383,23 @@ "door=" ] }, + "mappings": [{ + "if": "_poi_walls_and_buildings_entrance_properties_with_width=[]", + "then": { + "en": "The containing building has {}" + } + }], "render": { - "en": "The containing building can be entered via a door of {canonical(_poi_entrance:width)}", - "fr": "On peut entrer dans ce batiment via une porte de {canonical(_poi_entrance:width)}", - "de": "Das Gebäude kann über durch eine Tür von {canonical(_poi_entrance:width)} betreten werden." - }, - "freeform": { - "key": "_poi_entrance:width", - "type": "distance" - }, - "mappings": [ - { - "if": "_poi_entrance:width=", - "then": { - "en": "The containing building has no information on door widths. Add a door and measure the width to get information", - "fr": "Ce bâtiment n'a aucune information sur les largeurs de portes. Ajoutez une porte et mesurez la largeur pour obtenir des informations", - "de": "Das Gebäude hat keine Informationen über Türbreiten. Fügen Sie eine Tür hinzu und messen Sie die Breite, um Informationen zu erhalten" + "special": { + "type": "multi", + "key": "_poi_walls_and_buildings_entrance_properties", + "tagrendering": { + "en": "The containing building can be entered via a door of {canonical(_poi_entrance:width)}", + "fr": "On peut entrer dans ce batiment via une porte de {canonical(_poi_entrance:width)}", + "de": "Das Gebäude kann über durch eine Tür von {canonical(_poi_entrance:width)} betreten werden." + } } } - ] } ] }