Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Duration_in_traffic less than duration in google Distance Matrix API

I am using both the "duration_in_traffic" and "duration" feature using the DistanceMatrix API.

For a given coordinate pair, I see the following results:

{
  "destination_addresses": [
    "Hamburg, Germany"
  ],
  "origin_addresses": [
    "85748 Garching, Germany"
  ],
  "rows": [
    {
      "elements": [
        {
          "distance": {
            "text": "761 km",
            "value": 760831
          },
          "duration": {
            "text": "7 hours 1 min",
            "value": 25242
          },
          "duration_in_traffic": {
            "text": "6 hours 42 mins",
            "value": 24145
          },
          "status": "OK"
        }
      ]
    }
  ],
  "status": "OK"
}

Here is my question:

How is it that the duration_in_traffic is less than duration?

From what i understood:

Duration: Duration of travel on a route... Not sure if it is without traffic

Duration_in_traffic: Duration of travel on a route under traffic conditions.

Any explanation on this will be greatly appreciated.

like image 200
Neeraj Saxena Avatar asked Aug 10 '16 03:08

Neeraj Saxena


1 Answers

Note: The durationInTraffic field is now deprecated. It was previously the recommended way for Google Maps API for Work customers to specify whether the result should include a duration that takes into account current traffic conditions. You should now use the drivingOptions field instead.

Duration seems to take an average of durations at different times/from historic data, while duration_in_traffic takes the given departure time (and live traffic) into account. So the route takes 7 hours 1 min in average, but with your given time it only takes you 6 hours 42 mins from Hamburg to Garching.

I don't know if Google has that detailed data, but it could be that during the day a part of the highway is most of the times limited to 60 km/h because of dense traffic, while your travel time is around 23:00 and due to that you are allowed to drive 120 km/h.

There are also the three values for traffic_model: best_guess, pessimistic and optimistic which can influence the duration_in_traffic value.

like image 156
mxlse Avatar answered Sep 24 '22 23:09

mxlse