perliedman / leaflet-routing-machine

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

(OSRM) Routing has a maximum number of waypoints (around 500) #609

Closed Patabugen closed 3 years ago

Patabugen commented 3 years ago

I'm drawing routes with huge numbers of waypoints and am coming up against an issue whereby my OSRM server caps out at about 500 waypoints (it's actually the URL Length that's the limiting factor).

I currently work around this by managing multiple RoutingControls - but I'd love for LRM to be able to do the work internally. I'm happy to submit a PR if it's wanted?

It would detect when there's more than 400 waypoints and if there is make multiple requests and stitch the responses together.

Is that a feature/PR which would be desirable? If not I'll just keep my own implementation.

perliedman commented 3 years ago

Hi, what is the use case for this extreme number of waypoints? In my experience, when you have that number of waypoints, it's usually a case of map matching (matching an already recorded GPS track to the map's road network) - something OSRM has a builtin function for, which is separate from the routing function.

While I appreciate the offer, my gut feeling is that this is not a function that should go into LRM, this number of waypoints is just not what the plugin is built for. Having said that, it sounds like it should be possible to do as a separate routing plugin, which does not need to live the LRM repo.

Patabugen commented 3 years ago

Ah, that'ss handy - I'll have a look into that feature. Any advice on the best way to do this is appreciated!

We've got drivers driving around, and log their latlng every 2 seconds (about every 30 meters) and I need to display their route on the map. We have about 9,000 waypoints per drive.

(I also need to slowly draw the map so the route can be replayed, hence my other post).

Patabugen commented 3 years ago

@perliedman I've looked into the Map Matching function and realised that the reason I don't think it's suitable for my case that (unless you have any other ideas) is because I need to represent the roads travelled between tracked points - which are tracked every 2 seconds in a vehicle driving about 30mph (so about every 20m) - and if they take a sharp turn (for example) the Match method will draw a line cutting the corner - whereas OSRM will always route between the locations and show the road that the driver (most likely) drove down.

It's been a long while since I looked at the Match method and it's possible I'm mistaken. You have got me thinking that I could do this server side, and just stream the final result to the browser - which would certainly simplify my JavaScript.

perliedman commented 3 years ago

The idea to use match is exactly to avoid things like route cutting through a corner. It snaps the recorded positions to the road network, making educated guesses on how the vehicle travelled. Having said that, no solution is perfect, so you will always encounter some cases where it will not be perfect. But match will be better than routing with hundreds of waypoints.

Anyway, all of this is outside the scope of Leaflet Routing Machine, this is backend functionality in OSRM, it's probably better if you discuss your use case with someone who works on that project.

Patabugen commented 3 years ago

Thanks for your advice @perliedman !