Search code examples
osrm

OSRM: -different distance/duration for same (sub)route in /route/v1/driving


I'm retrieving durations/distances for millions of short routes using OSRM. In order to do so efficiently, I batch the rides in the form 'http://localhost:5000/route/v1/driving/longitude_departure1,latitude_departure1;longitude_arrival1,latitude_arrival1;longitude_departure2,latitude_departure2;longitude_arrival2,latitude_arrival2; etc. etc.?overview=false'

I batch the requests to speed things up and then I seperate the Json results, every odd response leg is a result I need. We found out that this will go wrong if more than 500 points are queried (so for me 250 rides) so I cap the query to 250 rides. This was supposed to be okay, untill I discovered that calling an individual ride does not result in the same duration/distance as the batch request.

The examples I used (using localhost:5000):

single ride: http://router.project-osrm.org/route/v1/driving/5.437881482356651,52.129306402910395;5.43154421722558,52.13201994238261?overview=false

3 batched rides: http://router.project-osrm.org/route/v1/driving/5.43084097657677,52.14466625721029;5.4286627903353,52.1431390952977;5.437881482356651,52.129306402910395;5.43154421722558,52.13201994238261;5.43154421722558,52.13201994238261;5.4208318605057295,52.1339190601066?overview=false

The results in my local OSRM engine:

  • Single ride

Distance: 1583.5

Duration: 228.7

  • Batched ride

Distance: 1651.6

Duration: 268.3

The weird thing is, online the result is the same, but different from my offline results. the latter is probably because of settings (which I did not alter at all) but I do not understand why the batch and single call are different.

  • Online results

Distance: 1137.1

Duration:350.7

Is there a valid explanation for this behaviour or is this a bug? I can imagine OSRM does not evaluate all options in the batched call to optimize the speed of the request.

I'm not sure which versions I'm running, but I've installed my routing enginge on the 14th of May this year. and I've downloaded Dutch map material from geofrabrik


Solution

  • If someone has the same question, I've found the answer. It turned out it is not a bug, but a setting in de lua profile:

    continue_straight_at_waypoint  = true,
    

    This line makes sure a car will not make a u-turn in 2 subsequent rides, in a single ride, OSRM always assumes the car is facing in the optimal direction to start, in a batched ride, this is not necessarily the case.

    My fix is thus to alter the paramter to false.