Project-OSRM / osrm-backend

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

OSRM routes through private service road #6397

Open wolfgang-8 opened 2 years ago

wolfgang-8 commented 2 years ago

In this example OSRM routes cars through a private service road ( https://www.openstreetmap.org/way/278772454 ):

http://map.project-osrm.org/?z=17&center=48.415665%2C15.640283&loc=48.415719%2C15.639762&loc=48.416976%2C15.639607&hl=en&alt=0&srv=0

image

Pedestrians and bicycles are routed as expected:

http://map.project-osrm.org/?z=17&center=48.415665%2C15.640283&loc=48.415719%2C15.639762&loc=48.416976%2C15.639607&hl=en&alt=0&srv=1

http://map.project-osrm.org/?z=17&center=48.415665%2C15.640283&loc=48.415719%2C15.639762&loc=48.416976%2C15.639607&hl=en&alt=0&srv=2

mjjbell commented 2 years ago

The source road is tagged as vehicle=destination.

https://www.openstreetmap.org/way/29736602

image

So the issue is we're turning from a restricted way into another restricted way. According to the current car profile, we only incur a penalty when we turn from a non-restricted way into a restricted way.

https://github.com/Project-OSRM/osrm-backend/blob/4026ed54c0f22a056a849c09edeec977616f1441/profiles/car.lua#L496-L502

I'd need to have a think about the implications, but we probably need to extend this function to understand if the turn between two restricted ways represents a continuation of the same restriction, or an application of a new restriction. This case seems quite clear as we are changing the restriction type from vehicle=destination to access=private, but there might be more subtle cases to consider.

mjjbell commented 2 years ago

Similarly, the reverse route has the same problem.

http://map.project-osrm.org/?z=18&center=48.416220%2C15.639200&loc=48.416976%2C15.639607&loc=48.415719%2C15.639762&hl=en&alt=0&srv=0

Screenshot 2022-10-11 at 12 30 33

Any route to the destination will have to pay the penalty of turning into the restricted destination road. The route via the private service road should have to pay the penalty twice (once for each turn), but it's only paying once (turn onto private road).

wolfgang-8 commented 2 years ago

Interesting that only car routing is affected. It seems that this logic is implemented multiple times.

mjjbell commented 2 years ago

The foot profile has the same logic, but it simply prevents access to the private road, as it doesn't support restricted access.

The bicycle profile has removed the logic (#4072), but in any case it also prevents access to the private road too.

So yes, it does seem inconsistent.

The intention of the car profile allowing heavily penalized turns into private roads is that this allows routes where your destination is on the private road, and bypasses the road otherwise (which is the bug here).

It's not clear to me why this logic should only apply to cars. E.g. if you live on a private road, you might also want the walking and cycling modes to route to/from your house.

wolfgang-8 commented 2 years ago

The intention of the car profile allowing heavily penalized turns into private roads is that this allows routes where your destination is on the private road

This doesn't work either. Perhaps it's part of the initial issue.

image

mjjbell commented 2 years ago

The only case where it doesn't work is when the private road is also a service road 😄

https://github.com/Project-OSRM/osrm-backend/blob/4026ed54c0f22a056a849c09edeec977616f1441/profiles/lib/way_handlers.lua#L74-L91

Here's an example of where it does work: http://map.project-osrm.org/?z=18&center=48.360853%2C11.447153&loc=48.360505%2C11.446826&loc=48.360341%2C11.446890&hl=en&alt=0&srv=0

Screenshot 2022-10-12 at 11 53 57 Screenshot 2022-10-12 at 11 54 15

I think this discussion is making it clear that OSRM should document the intended behaviours more clearly. Digging through the profiles isn't feasible for the end user. In addition, we could write tests against the doc, which would help identify bugs such as the above case.

wolfgang-8 commented 2 years ago

The only case where it doesn't work is when the private road is also a service road 😄

Yes, the little things...!

I think this discussion is making it clear that OSRM should document the intended behaviours more clearly. Digging through the profiles isn't feasible for the end user.

:thumbsup:

Thank's a lot!

iaroslavzif commented 1 year ago

Hi @mjjbell just wanted to add one more exemple that I just encountered. The bug is replicable. OSRM https://map.project-osrm.org/?z=17&center=48.253527%2C16.466301&loc=48.251952%2C16.464525&loc=48.255027%2C16.466542&hl=en&alt=0&srv=0 OSM https://www.openstreetmap.org/way/218429281 Thank you!