Nice, thanks! In this way the parsing of the geometry is more efficient than I had before. Final step is to write the tags as attributes, so I want to get the list of tags (k and v) dynamically as fme attribute and field value. Desired output format is GeoJSON and would look like:
{
"type" : "FeatureCollection",
"name" : "highway",
"features" : [
{
"type" : "Feature",
"geometry" : {
"type" : "LineString",
"coordinates" : [
[ 5.1051919, 52.0738589 ],
[ 5.1053088, 52.0737963 ],
[ 5.1053437, 52.0736926 ],
[ 5.105369, 52.0736188 ],
[ 5.10565, 52.0728625 ],
[ 5.1059033, 52.0719212 ],
[ 5.1061436, 52.0710064 ],
[ 5.106168, 52.0708859 ],
[ 5.1064257, 52.0699046 ],
[ 5.1064969, 52.0696266 ],
[ 5.106523, 52.069536 ]
]
},
"properties" : {
"id" : "4342251",
"timestamp" : "",
"user" : "",
"visible" : "",
"uid" : "",
"version" : "",
"changeset" : "",
"lat" : "52.0738589",
"lon" : "5.1051919",
"ref" : "250150107",
"source" : "survey",
"highway" : "cycleway"
}
}
]
}
For this last part I used the OSM XML reader and dynamically write to GeoJSON. However, this is too slow.
XMLXQueryUpdater expression:
- let $x := fme:get-xml-attribute("xml_fragment")
- let $members := {
- for $a in $x//attribuut
- return '"'||string($a/@naam)||'":"'||$a/text()||'"'
- }
- return '{'||fn:string-join($members, ',')||'}'
After that I use a JSONflattener to flatten attributes. However I don't fully get how the attributes I created return in the GeoJSON output.