Different distance, driving_time then routing API

We do a precheck for new appointments using the routing API (because it is less expensive then route optimization API) to make sure that a driver could get there from the previous appointment in time and also to the next appointment.

However, when we go to optimize the route with GH sometimes appointments fail. The reason is because the distance and driving_time metrics can vary - sometimes significantly. Also neither API is consistenly shorter then the other

Anyway around this other then using a “buffer” from the routing API result?

An example:

source:                   43.7252454,     -79.3321048
destination:             43.6699782,     -79.2862945 

Routing API                     1084 drive time     13.0 distance
Optimization API              919 drive time       9.4  distance


The Route Optimization API uses the same road network under the hood like the Routing API, so there shouldn’t be a difference (except maybe when we update the road network while the requests, which should be unlikely).

If I’m using GraphHopper Maps that uses the Routing API under the hood I get the same results like you write that you get with the Route Optimization API: 9.45km will take 15min (=900 seconds)


So there must be something else. Can you write the exact queries that you use? (You can also send them to me via PM)

Thanks for the reply. I made the mistake of switching the point order. In general then, routing API and optimization API should return identical results for time/distance?

 curl "https://graphhopper.com/api/1/route?key=xxxx&instructions=0&calc_points=0&point=43.669978%2C-79.286294&point=43.725245%2C-79.332105" 

         "time" : 1083423,
         "distance" : 13048.12

How does your Route Opt API request look like?

btw: you should consider using point hints to avoid snapping to the wrong ways like so https://graphhopper.com/maps/?point_hint=%2C&point_hint=wynford%20drive&point=43.669978%2C-79.286294&point=43.725245%2C-79.332105 (called street_hint for the Route Opt API)

routing API and optimization API should return identical results for time/distance


Thanks. Results are lining up now.

Had a bug in my request formation where point order was not guaranteed.

1 Like