perliedman / leaflet-routing-machine

Control for routing in Leaflet
https://www.liedman.net/leaflet-routing-machine/
Other
1.06k stars 347 forks source link

Support for routes including ferries? #703

Open FriedCurmudgeon opened 3 months ago

FriedCurmudgeon commented 3 months ago

Hi, thanks for a great addition to Leaflet! I have stumbled into a wierd issue, the routing machine seems to avoid ferries when calculating routes. How can I fix this?

image

curtisy1 commented 3 months ago

This is... interesting. I'm guessing you're using the L.Routing.OSRM instance? From a quick test, OSRM itself does not seem to consider this ferry as an option for some reason (it should support ferries from what I know).

What I can say is that GraphHopper and Valhalla both find a ferry but they take different ones (you can play around with it here)

I'll do some digging in overpass and see if I can find out what exactly causes each of those routing engines to consider a different ferry or in OSRM's case, no ferry at all.

My suggestion at the moment would be to use either lrm-graphhopper or lrm-valhalla as a fallback solution.

Also, it would be amazing if you could give me some more information about the ferries, as it's possible that the data OSM has on them is slightly wrong (pedestrian only ferry, limited to vehicles < 1t, etc.) and that could impact the routing engines to the point where they make such drastic changes

FriedCurmudgeon commented 3 months ago

Thank you @curtisy1 for replying. I am using the default OSRM instance. I will take a look at one of the other engines.

The ferry is a mixed pedestrian/car ferry betwen Norway and Denmark operated by Colorline. The transfer is about three hours.

curtisy1 commented 3 months ago

The data at Overpass seems to be correct (see here for a simple query). I have no idea what's going on with OSRM or Valhalla there. It might just be an issue on their end with how they calculate the best route.

I know Valhalla internally works with penalties/costs, so maybe there is something that makes the ferry in Larvik better for their algorithm (wild guess: it thinks taking the highway is faster than the ferry). As for OSRM, I don't know how they work internally but not taking the ferry into account is almost certainly a bug.

I'll open up a discussion about it in their respective repos, for now, the only solution seems to be using either Valhalla or GraphHopper

curtisy1 commented 3 months ago

I think this might be what's happening with OSRM and possibly with Valhalla as well, depending on how the nodes/ways are tagged in OSM itself. It looks correct to me but something might be off.

RoutingAPI commented 2 months ago

This is not a problem of OSRM in general but the public OSRM demo instance you are using. That one has - due to hardware constraints - a reduced functionality in calculating routes via ferries resulting in a lot of ferry routes not being used.

E.g. if you test a route from Kristiansand in Norway to Aalborg in Denmark here: https://fast-routing-api.demo.routingapi.net/ you'll see the ferry being used (and that one is OSRM under the hood as well). But if you use the OSRM demo instance at https://router.project-osrm.org, the ferry line won't be used.

FriedCurmudgeon commented 1 month ago

Can confirm that this works after switching to Graphhopper.