forked from MapComplete/MapComplete
WIP
This commit is contained in:
parent
32e0c18b09
commit
181c5583d2
5 changed files with 51 additions and 19 deletions
|
@ -1,5 +1,6 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Metatags
|
Metatags
|
||||||
==========
|
==========
|
||||||
|
|
||||||
|
|
|
@ -187,7 +187,7 @@ class DistanceToFunc implements ExtraFunction {
|
||||||
|
|
||||||
class ClosestObjectFunc implements ExtraFunction {
|
class ClosestObjectFunc implements ExtraFunction {
|
||||||
_name = "closest"
|
_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"]
|
_args = ["list of features or a layer name or '*' to get all features"]
|
||||||
|
|
||||||
|
|
|
@ -469,6 +469,8 @@ export class RewriteSpecial extends DesugaringStep<TagRenderingConfigJson> {
|
||||||
.replace(/\{/g, "&LBRACE")
|
.replace(/\{/g, "&LBRACE")
|
||||||
.replace(/}/g, "&RBRACE")
|
.replace(/}/g, "&RBRACE")
|
||||||
args.push(txt)
|
args.push(txt)
|
||||||
|
} else if(typeof v === "object"){
|
||||||
|
args.push(JSON.stringify(v))
|
||||||
} else {
|
} else {
|
||||||
args.push(v)
|
args.push(v)
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 <a href='#{id}'>door</a> 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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -366,8 +366,10 @@
|
||||||
],
|
],
|
||||||
"overrideAll": {
|
"overrideAll": {
|
||||||
"+calculatedTags": [
|
"+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_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_entrance:id=JSON.parce(feat.properties._poi_walls_and_buildings_entrance_properteis)?.id",
|
"_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"
|
"_poi_entrance:width=JSON.parse(feat.properties._poi_walls_and_buildings_entrance_properties)?.width"
|
||||||
],
|
],
|
||||||
"+tagRenderings": [
|
"+tagRenderings": [
|
||||||
|
@ -381,25 +383,23 @@
|
||||||
"door="
|
"door="
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"mappings": [{
|
||||||
|
"if": "_poi_walls_and_buildings_entrance_properties_with_width=[]",
|
||||||
|
"then": {
|
||||||
|
"en": "The containing building has {}"
|
||||||
|
}
|
||||||
|
}],
|
||||||
"render": {
|
"render": {
|
||||||
"en": "The containing building can be entered via <a href='#{_poi_entrance:id}'>a door of {canonical(_poi_entrance:width)}</a>",
|
"special": {
|
||||||
"fr": "On peut entrer dans ce batiment via <a href='#{_poi_entrance:id}'>une porte de {canonical(_poi_entrance:width)}</a>",
|
"type": "multi",
|
||||||
"de": "Das Gebäude kann über <a href='#{_poi_entrance:id}'>durch eine Tür von {canonical(_poi_entrance:width)} betreten werden.</a>"
|
"key": "_poi_walls_and_buildings_entrance_properties",
|
||||||
},
|
"tagrendering": {
|
||||||
"freeform": {
|
"en": "The containing building can be entered via <a href='#{_poi_entrance:id}'>a door of {canonical(_poi_entrance:width)}</a>",
|
||||||
"key": "_poi_entrance:width",
|
"fr": "On peut entrer dans ce batiment via <a href='#{_poi_entrance:id}'>une porte de {canonical(_poi_entrance:width)}</a>",
|
||||||
"type": "distance"
|
"de": "Das Gebäude kann über <a href='#{_poi_entrance:id}'>durch eine Tür von {canonical(_poi_entrance:width)} betreten werden.</a>"
|
||||||
},
|
}
|
||||||
"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"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue