1
votes

I am working on a project where I have been asked to provide the least amount of distance, and its duration as an estimate based up a journey between two or more postcodes in the uk.

e.g. http://maps.googleapis.com/maps/api/distancematrix/xml?mode=driving&TrafficModel=optimistic&sensor=false&language=en-EN&units=imperial&origins=mk109hs, uk&destinations=WC1N 1LE, uk

As part of the google distance api call I am choosing mode=driving.

In terms of the Traffic Model I am choosing optimistic.

Google developer documentation says; "optimistic indicates that the returned duration_in_traffic should be shorter than the actual travel time on most days, though occasional days with particularly good traffic conditions may be faster than this value." https://developers.google.com/maps/documentation/distance-matrix/intro

Does this mean; a.) I should receive the least distance to the destination? b.) I should receive the least duration to the destination?

The reason I ask is that there could be more miles to travel but does not take as long due to the speed you able to travel at.

1

1 Answers

1
votes

For Google Distance Matrix API, the distance it returns is not the shortest distance but it is shortest time. These responses are not calculated taking the traffic into consideration. If there is a path with only 2 miles distance and takes 10 minutes to get there and another path with 3 miles and 8 minutes, distance matrix will return the second path as it gets you to the destination sooner. There is no exact documentation which specifies this in the documentation they have but I use Distance Matrix on a regular basis for a very big application and this is the behavior from the beginning. Hope this helps.

Note: Having the traffic model set to optimal will only return time shorter than the expected but has no impact on the distance.