Project-OSRM / osrm-backend

Open Source Routing Machine - C++ backend
http://map.project-osrm.org
BSD 2-Clause "Simplified" License
6.3k stars 3.33k forks source link

Trunk road ignored for foot or bike routing - best way to solve #6008

Open boothym opened 3 years ago

boothym commented 3 years ago

Came across this tweet: https://twitter.com/thomasforth/status/1381702567126835201

And this example in the replies of how OSRM was seemingly ignoring the A75 trunk road for foot and bike routing from one side of town to the other: https://www.openstreetmap.org/directions?engine=fossgis_osrm_foot&route=54.90570%2C-5.01110%3B54.90420%2C-5.02350#map=16/54.9016/-5.0153 (GraphHopper routes along trunk roads)

I looked at the debug view and found that was indeed the case: http://map.project-osrm.org/debug/foot.html#17.26/54.90434/-5.01646

In case you are wondering what this road looks like: https://www.geograph.org.uk/photo/4929194 (perfectly suitable for foot/bike routing)

So my question is - what is the best way to solve this in OSM? Just add foot/bicycle=yes, sidewalk=both, separately mapped sidewalks or a combination of all three?

danpat commented 3 years ago

TBH, OSRM is wrong here. There are some default access rules defined at:

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

which shows that in the UK, highway=trunk should be accessible to foot traffic by default.

frodrigo commented 3 years ago

A way to to it is using polygons, like driving_side or maxheight.

https://github.com/Project-OSRM/osrm-backend/tree/master/data

boothym commented 3 years ago

Sorry @frodrigo, I'm not sure what you mean?

danpat commented 3 years ago

What @frodrigo means is that we should probably build up a GeoJSON that captures all these regional access restriction defaults, and make the .lua files use them so that defaults can be modified regionally.

tombay commented 12 months ago

I logged #6701. I looked at https://wiki.openstreetmap.org/wiki/Key:motorroad -- and https://wiki.openstreetmap.org/wiki/OSM_tags_for_routing/Access_restrictions. Most of the countries that allow trunk access to bike and foot can be covered by two cases. - 1/ trunk and trunk_link is allowed & 2/ trunk and trunk_link allowed if motorroad is no or not defined. I think GBR falls into this category. I put my attempt to cover these cases in the final note to that issue. It relies on geolocation data and covers 30 countries that meet the criteria. e.g. osrm-extract -p /usr/local/share/osrm/profiles/foot.lua --location-dependent-data=.countries.geojson ... A real solution would of course cover all the other scenarios but for me at least it allowed bike (and foot) trails for NZ without having to add tags to the osm data. Ciao Tombay

frodrigo commented 12 months ago

@tombay maybe you wan to contribute a PR to add this features and polygons to OSRM itself ?

tombay commented 12 months ago

I will look into it (PR thing). I thought someone else might check into if the idea works. By polygons I assume it would be providing the geojson as a file osrm-extract could read. (I.e. the data that comes from the geoson output). I am not sure what impact it does to the extraction process. What I did (I thought) was just add trunk to the potential result set.

⁣Get BlueMail for Android ​

On 18 Sept 2023, 5:56 pm, at 5:56 pm, "Frédéric Rodrigo" @.***> wrote:

@tombay maybe you wan to contribute a PR to add this features and polygons to OSRM itself ?

-- Reply to this email directly or view it on GitHub: https://github.com/Project-OSRM/osrm-backend/issues/6008#issuecomment-1722914071 You are receiving this because you were mentioned.

Message ID: @.***>

github-actions[bot] commented 2 months ago

This issue seems to be stale. It will be closed in 30 days if no further activity occurs.

frodrigo commented 2 months ago

This issue seems to be stale. It will be closed in 30 days if no further activity occurs.

The idea is still interesting.

tombay commented 2 months ago

I created a PR #6703 (Sep 2023) which addressed this issue. A subsequent PR (#6708) seemed to cause an issue with my PR and it is languishing. It does include a 3.6 mb geojson file which outlines the countries affected. I thought having to traverse this file for each way (and node ?) would be a no no so approached it via --location-dependent-data data/trunk_allowed.geojson. (and the associated country list in lua file). Maybe there is another approach. %-?

tombay commented 1 month ago

I have written (hacked??) a script to parse the tables in "https://wiki.openstreetmap.org/wiki/OSM_tags_for_routing/Access_restrictions" (Still a work in progress). It generates a .lua script - Set of countries, and a Sequence of Sequences for Country->Profile->Highway Tag. This could be used to cover all country specific highway types (not just trunk). The parsing resulted in around 5500 "cells" of which ~4800 are "yes" or "no". 126 are empty. The empty ones are cases like Belarus->motorcycle->goods=(5). Comment 5 says that servicing, local access and moving of vehicles are o.k.

There are 31 countries and using data from The Natural Earth ne_10m_admin_0_countries data, the resulting geojson file is about 7.7meg. According to "https://wiki.openstreetmap.org/wiki/Precision_of_coordinates#Conversion_to_decimal" 10 metre accuracy is covered by dd.dddd. By reducing the ne data to dd.ddddd, and trimming feature data, the size can be reduced to ~4meg.

General assumptions for the script was if there is an access type (yes,no,designated...) then drop any notes. To address the 126 empties is it better to say "no" or "yes" - or "maybe". I think that is a question for a routing type or Chat Gpt %-)

"Cells within cells within cells" (Dekard in Blade Runner_2049).

tombay commented 1 month ago

I can see no association with access nodes and countries and so have been looking at ways - speed handling. In the foot.lua profile the setup has a component speeds = Sequence { ... If you separate this into say hwyspeeds and other speeds (e.g. from railway down) then you can have a unique hwyspeed set for each country. I have parsed the Access Restrictions and generated lua code to handle it. It includes a 'Worldwide' set to cover all the other countries not mentioned in the Restrictions page. To do this one needs to run the extract with location-dependent-data. Using "https://osm-boundaries.com/map" as the source of the country geometry data results in a data file of around a 41M. Trying other poly data (eg naturalearth or geofabrik poly maps) did not accurately reflect country borders. The complete file is not needs if you are only building a subset of the world. I have only looked at the foot profile as the bicycle one is more convoluted. I will create a new PR to add the code.