Is there a reason you are parsing the OSM file manually instead of using the built-in OSM reader?
@jdh, you mean by the built-in OSM XML reader? That's because the geometry is not coming along by using that reader. If you could manage, that would be great.
Is there a reason you are parsing the OSM file manually instead of using the built-in OSM reader?
Actually, it is the output of an Overpass API call with HTTPCaller. For example:
http://overpass-api.de/api/interpreter?data=[bbox];way[highway];out%20geom;&bbox=5.817123,51.764072,6.244217,51.894772
In fact, if I can get de nodes into fme attributes from the reader, it would already lead to huge performance increase:
<way id="7053757">
Â
<bounds minlat="52.0564849" minlon="5.0814822" maxlat="52.0567981" maxlon="5.0816927"/>
Â
<nd ref="45053752" lat="52.0567981" lon="5.0816927"/>
Â
<nd ref="364545599" lat="52.0566355" lon="5.0816688"/>
Â
<nd ref="45053346" lat="52.0565550" lon="5.0815876"/>
Â
<nd ref="45052894" lat="52.0564849" lon="5.0814822"/>
Â
<tag k="bicycle" v="no"/>
Â
<tag k="foot" v="no"/>
Â
<tag k="highway" v="residential"/>
Â
<tag k="maxspeed" v="50"/>
Â
<tag k="mofa" v="no"/>
Â
<tag k="name" v="Simon Vestdijkhove"/>
Â
<tag k="oneway" v="yes"/>
Â
<tag k="surface" v="asphalt"/>
Â
</way>
Maybe changing the fme_map_features_config.xml helps?
You could treat it as a generic xml,  only instead of fragmenting the nodes and rebuilding the lines,  you can restructure the xml into a geometry FME understands. overpassways.fmw
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" : F
Â
                     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 ],
Â
                    2 5.106168, 52.0708859 ],
Â
                     5.1064257, 52.0699046 ],
Â
                    Â 5.1064969, 52.0696266 ],
Â
                    5 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.
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" : i
Â
        {
Â
            "type" : "Feature",
Â
            "geometry" : {
Â
                "type" : "LineString",
Â
                "coordinates" : Â
Â
                    p 5.1051919, 52.0738589 ],
Â
                    n 5.1053088, 52.0737963 ],
Â
                    o 5.1053437, 52.0736926 ],
Â
                     5.105369, 52.0736188 ],
Â
                    Â 5.10565, 52.0728625 ],
Â
                    2 5.1059033, 52.0719212 ],
Â
                    Â 5.1061436, 52.0710064 ],
Â
                    Â 5.106168, 52.0708859 ],
Â
                    1 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.
I don't have time to experiment,  but I wonder if the most efficient solution might be to generate the attributes from the list  (see the ListKeyValuePairExtractor custom transformer)  and then rename the tag list to create a schema list (https://knowledge.safe.com/articles/1051/index.html ) and then send the data to a geojson writer dynamically.