Routing with traffic

3 posts / 0 new
Last post
fuzzymallard
Routing with traffic

I'm using mqgl.Service to try to calculate the time for a morning commute using the directions.route API using the following options.

options: {
useTraffic: true,
timeType: 2, //startAt
dateType: 3, //Tuesday
localTime: '08:15'
}

The route I get back is reasonable, but the time estimate isn't.  Documentation here states:

If set to true, will use historical and realtime traffic speeds (depending on route time and availability of data) to influence the route.

Does that mean historical traffic will only influence the choice of route, but not the amount of time to traverse that route?  The response has the same exact formattedTime whether the request's localTime is during rush hour or midnight.  Is there a way to model the route with realistic rush hour traffic?


MQBrianCoakley
Can you send a sample request

Can you send a sample request that is not returning the expected results? Or the locations you're using to test?


fuzzymallard
Samples

Here is my request source:

services.directions.route({
locations: [home, work],
options: {
useTraffic: true,
timeType: 2, //startAt
dateType: 3, //Tuesday
localTime: '08:15'
}
}).then(response => parseMorningCommute(response));

 

And here is one sample for home and work parameters.

1 N Bridge St, Bridgewater NJ
100 Town Square Pl, Jersey City, NJ

With these parameters, I get back a realTime of 10000000, and formattedTime is consistent with the time field (~50 minutes).  Same response if I change localTime to '00:15'.  In real life, this route would take about 50 minutes with no traffic, but no less than 90 minutes with normal rush hour traffic.

 

The docs state this about this realTime magic number:

If any road along the route path is currently closed, the time will be greater than 10000000 (an absurdly long time for a route).

 

What does "currently" mean in the context of timeType 2?  Is there a way to fashion the request to avoid closed roads?  Note that route.legs[0].hasSeasonalClosure is false, which implies setting avoids: 'Approximate Seasonal Closure'  isn't going to help me.  I assume the closure relates to route.legs[0].maneuvers[9], but I haven't a clue how to avoid it.