itinero/routing

Use OSM's Surface tag in routing & return with GeoJSON Properites

Bairdo opened this issue · 1 comments

Hi,
I am trying to use the 'surface' tag of OSM for a couple of things:

  • returning it as part of the GeoJSON from route.ToGeoJSON(shapemeta=true...)
  • And in a custom Vehicle profile. I assume it should be part of the IAttributeCollection attributes however that only seems to have 'highway'.

Is there something I need to do to enable it (e.g. An Extension) or is it unsupported? I haven't been able to figure it out yet.
Thanks

Snapshot of what my route.GeoJSON(...)

    "type": "FeatureCollection",
    "features": [
        {
            "type": "Feature",
            "geometry": {
                "type": "LineString",
                "coordinates": [ ...
                ]
            },
            "properties": {
                "highway": "primary",
                "profile": "bicycle",
                "distance": "175.51111",
                "time": "42.12266"
            }

I think I've answered my own question for the most part. And Lua profiles seem to be the answer.

Basically add the tag you want to the appropriate whitelist (explanation of each is on the above link). Then it can be accessed as a member of the attributes in factor_and_speed - In my case add it to the result.

In particular

...
-- whitelists for profile and meta
profile_whitelist = {
    "highway",
    "surface"
}
meta_whitelist = {
    "name",
    "surface"
}
...
-- the main function turning attributes into a factor_and_speed and a tag whitelist
function factor_and_speed (attributes, result)
...
     result.attributes_to_keep = {}
     result.attributes_to_keep.surface = attributes.surface
...
end

Although the minimal example didn't work (the database kept being empty) so used the default car as the base.