Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

routing profile foot.lua results in spurious trails for New Zealand (suspect SH 6) #6701

Closed
tombay opened this issue Sep 13, 2023 · 6 comments

Comments

@tombay
Copy link

tombay commented Sep 13, 2023

Issue

I have created a dataset using foot.lua as the profile
This is described in the community forum
https://community.openstreetmap.org/t/issues-with-foot-lua-profile/103765

The profile is from git source.
Downloaded new-zealand-latest.osm.pbf. And set up two osrm data trees
new-zealand/car
new-zealand/foot
cd car
osrm-extract -p /opt/osrm/car.opt new-zealand-latest.osm.pbf
osrm-partition new-zealand-latest.osrm
osrm-customize new-zealand-latest.osrm
cd …/foot
osrm-extract -p /opt/osrm/foot.opt new-zealand-latest.osm.pbf
osrm-partition new-zealand-latest.osrm
osrm-customize new-zealand-latest.osrm
If i run osrm-routed -a MLD car/new-zealand-latest - the trail draws correctly
If i run osrm-routed -a MLD foot/new-zealand-latest - the trail draws garbage

This can be seen here :
https://map.project-osrm.org/?z=14&center=-41.230508%2C173.377562&loc=-41.212480%2C173.382840&loc=-41.210172%2C173.395951&hl=en&alt=0&srv=2

@danpat
Copy link
Member

danpat commented Sep 13, 2023

The issue is probably related to default access restrictions. OSM has a wiki page on it here:

https://wiki.openstreetmap.org/wiki/OSM_tags_for_routing/Access_restrictions

If you look at the tables there, you'll see that different counties have different defaults for different road classes. The OSRM foot profile was written for one set of rules, and it doesn't do country-by-country differences.

This is absolutely a bug in OSRM, and patches to fix it would be quite welcome. Honestly, most of the work is probably just in the .lua files, enabling/disabling various road classes depending on the country. You would need to build the routing files with country-level polygon file so that the Lua scripts can know which country the edges are in to change the access rules for the profile you're generating.

#6008 is a similar bug report from a couple of years ago. Obviously, nobody has submitted a patch to fix this yet. You could be the one!

@tombay
Copy link
Author

tombay commented Sep 13, 2023

I added trunk into the allowed highway list and now tracks are ok. However I think the solution may not be solvable just through lua files. Looking at the osrm names file (after osrm-extract with the original foot.lua) the trunk entries have been removed. To support multiple polygon areas the data would have to still be there. If polygon areas can be fed Into .lua then it would work, otherwise you need separate extracts per country. Osrm-routed could choose an extract based on polygon. I do have separate extracts for AUS and NZ and choose between them (not in software). As it is now osrm-routed (and the api library) should report no route.

@danpat
Copy link
Member

danpat commented Sep 13, 2023

You misunderstand how the feature works. The trunk roads are removed because OSRM flags them as inaccessible for walking.

Check the wiki page here: https://github.com/Project-OSRM/osrm-backend/wiki/Using-location-dependent-data-in-profiles

It includes an example showing how to obtain country borders in a GeoJSON format, then how to check the current country code (ISO3166-1:alpha3) for each OSM way as it is processed by osrm-extract. It is perfectly feasible to do it all in one extract operation.

For some countries, you would enable trunk roads, for other countries, you would disable them. The emitted routing file would have trunk edges enabled in some places, and disabled in others.

The things that are really missing from OSRM are:

  1. We should probably ship a country border file that's easy for people to use (in the data/ folder, like we have the driving-side polygons).
  2. Update the lua scripts to honor the correct per-country rules outlined at https://wiki.openstreetmap.org/wiki/OSM_tags_for_routing/Access_restrictions
  3. Update our processing instructions encouraging people to actually pass in the country borders and driving side polygons when you call osrm-extract so that the Lua scripts know the proper properties for each way as it's processed.

@tombay
Copy link
Author

tombay commented Sep 14, 2023

Thanks for that Danpat. I did not realize all that functionality was there.
I downloaded the countries.geojson file as suggested. I created a local_motorways.lua file that supports localized settings for motorways and speeds. I modified way_handlers.lua and guidance.lua to check for the existence of localized settings.
My assumption was just (based on the country locale) just remove trunk, trunk_link from the motorway list.
with the speed if we failed the test just try again with trunk or trunk_link.
I tested successfully but have not gone throughj any test suite. (I retired from SD over 10 years ago %-?).
I can attach the files if you wish - but have only tried on NZL.
Ciao

@tombay
Copy link
Author

tombay commented Sep 14, 2023

Actually just need the speed
foot.lua.patch.txt
way_handlers.lua.patch.txt
local_motorways.lua.txt

@tombay
Copy link
Author

tombay commented Sep 16, 2023

I think this is probably not the right forum for me to teach myself OSRM programming.
My previous test didn't even check if the highway was a trunk.
I have included my last version which has taken input from the openstreetmap wiki.
I will attach these and close this defect .
foot.lua.patch.txt
foot.lua.patch.txt
foot.lua.patch.txt

way_handlers.lua.patch.txt
bicycle.lua.patch.txt

local_trunks.lua.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants