A route calculated with timeWithTraffic
will use real time traffic data for the first part of the route (~15 min) and then use predictive traffic data for the second part of the route. Traffic data is updated every minute globally in Bing and Azure Maps, so making a second call to the service could easily result in different numbers. The travelDuration
property should be fairly constant as it's based on historical traffic data, while travelDurationTraffic
will change relative to real time traffic changes. When you set optimize
to anything other than timeWithTraffic
the travelDurationTraffic
value should be ignored. When you provide a future date, only predictive traffic data is used. Calculations on predictive data can vary every time a calculation is done due to how the calculations are done and the nature of the data. The calculations for routing use a genetic heuristic algorithm. These algorithms are fast and return reasonable results but might not be the 100% best result (maybe 99% best). Every time one of these calculations are done you can get a slightly different calculation. The main reason for doing the routing calculations this way is that the alternative is to brute force the calculations to determine the optimal result, and on a global scale, that could take years to calculate.
The travelDuration
number is able to stay consistent as Bing/Azure Maps has an optimization that precalculated the brute force optimized solution that works with static data (e.g. no traffic data). As such, that absolute optimized path is calculated without any genetic heuristic algorithms. When traffic data is used, this optimization can't be used as we can't pre-calculate every possible combination of routes taking into consideration a metric on each road section that updates every minute. Even doing this on future predicted data would take a long time and require massive amounts of storage (Note that predictive traffic data is unique to each day and time, and not a constant value).