Closed qbunt closed 7 years ago
You shouldn't expect identical queries run at different times to produce the same values. The Go and JS clients only differ in that the Go client converts the returned value to a time.Duration
, whereas the JS client returns the raw JSON from the directions API.
Here's output from my shell using both clients. You'll see responses vary from request to request within the JS client, and also vary from request to request with the Go client:
~ googlemaps directions --origin Sydney --destination Melbourne --departure_time now --units imperial --mode driving --traffic_model best_guess | grep -A 3 duration_in_traffic
"duration_in_traffic": {
"text": "9 hours 8 mins",
"value": 32870
},
~ googlemaps directions --origin Sydney --destination Melbourne --departure_time now --units imperial --mode driving --traffic_model best_guess | grep -A 3 duration_in_traffic
"duration_in_traffic": {
"text": "9 hours 8 mins",
"value": 32884
},
~ googlemaps directions --origin Sydney --destination Melbourne --departure_time now --units imperial --mode driving --traffic_model best_guess | grep -A 3 duration_in_traffic
"duration_in_traffic": {
"text": "9 hours 8 mins",
"value": 32881
},
~ googlemaps directions --origin Sydney --destination Melbourne --departure_time now --units imperial --mode driving --traffic_model best_guess | grep -A 3 duration_in_traffic
"duration_in_traffic": {
"text": "9 hours 8 mins",
"value": 32880
},
~ go run directions/cmdline/main.go -key API_KEY -origin Sydney -destination Melbourne -departure_time now -units imperial -mode driving -traffic_model best_guess | grep DurationInTraffic
DurationInTraffic: 32873000000000,
~ go run directions/cmdline/main.go -key API_KEY -origin Sydney -destination Melbourne -departure_time now -units imperial -mode driving -traffic_model best_guess | grep DurationInTraffic
DurationInTraffic: 32891000000000,
~ go run directions/cmdline/main.go -key API_KEY -origin Sydney -destination Melbourne -departure_time now -units imperial -mode driving -traffic_model best_guess | grep DurationInTraffic
DurationInTraffic: 32871000000000,
If you're truly convinced the different clients are performing different requests, I would attempt to add some logging to the source for both clients, showing the URLs they're both using - I suspect they'll be identical.
Using the following code, the durations returning back from the Distance Matrix API have incorrect
duration
andduration_in_traffic
values with the sameorigin
anddestination
values:returns a value of
50 mins
on the relevant element row.Running the exact same parameters in the Go client for the same API returns a much more accurate result (identical to http://maps.google.com). Using the same basic implementation, I get a value for
duration_in_traffic
of1h3m22s
.Happy to send the Go implementation of the same thing, I was simply surprised that this library appeared to be returning the wrong value. Let me know if you'd like additional info.