流量中的 Google Maps Distance Matrix API 持續時間添加返回錯誤結果的所有段 (Google Maps Distance Matrix API duration in traffic adding all segments returning wrong result)


問題描述

流量中的 Google Maps Distance Matrix API 持續時間添加返回錯誤結果的所有段 (Google Maps Distance Matrix API duration in traffic adding all segments returning wrong result)

我在 Google 地圖上的一條道路上連續設置了 11 個點當我計算在相鄰點之間行駛所需的時間並將它們相加時,總結果與從第一個點和最後一個點之間行駛所需的時間不同點

ie

A ‑> B
B ‑> C
C ‑> D

is not equal to 

A ‑> D 

誰能舉例說明為什麼會這樣。


參考解法

方法 1:

Here is the example: I have some coordinates

`
p1=(49.338202, ‑123.142030)
p2=(49.335271, ‑123.125171)
p3=(49.332503, ‑123.116240)
p4=(49.332447, ‑123.104249)
p5=(49.331949, ‑123.092218)
p6=(49.331996, ‑123.077877)
p7=(49.329556, ‑123.054275)
p8=(49.326069, ‑123.048102)
p9=(49.312711, ‑123.030485)
p10=(49.306328, ‑123.028022)
p11=(49.291653, ‑123.026348)



directions_results1 = gmaps.distance_matrix(p1,p2,mode="driving",units="metric",departure_time=now,traffic_model= "best_guess")
directions_results2 = gmaps.distance_matrix(p2,p3,mode="driving",units="metric",departure_time=now,traffic_model= "best_guess")
directions_results3 = gmaps.distance_matrix(p3,p4,mode="driving",units="metric",departure_time=now,traffic_model= "best_guess")
directions_results4 = gmaps.distance_matrix(p4,p5,mode="driving",units="metric",departure_time=now,traffic_model= "best_guess")
directions_results5 = gmaps.distance_matrix(p5,p6,mode="driving",units="metric",departure_time=now,traffic_model= "best_guess")
directions_results6 = gmaps.distance_matrix(p6,p7,mode="driving",units="metric",departure_time=now,traffic_model= "best_guess")
directions_results7 = gmaps.distance_matrix(p7,p8,mode="driving",units="metric",departure_time=now,traffic_model= "best_guess")
directions_results8 = gmaps.distance_matrix(p8,p9,mode="driving",units="metric",departure_time=now,traffic_model= "best_guess")
directions_results9 = gmaps.distance_matrix(p9,p10,mode="driving",units="metric",departure_time=now,traffic_model= "best_guess")
directions_results10 = gmaps.distance_matrix(p10,p11,mode="driving",units="metric",departure_time=now,traffic_model= "best_guess")

directions_resultst = gmaps.distance_matrix(p1,p11,mode="driving",units="metric",departure_time=now,traffic_model= "best_guess")



the number is in second

Output
Segment 1 Time: 149
Segment 2 Time: 37
Segment 3 Time: 63
Segment 4 Time: 49
Segment 5 Time: 49
Segment 6 Time: 96
Segment 7 Time: 35
Segment 8 Time: 141
Segment 9 Time: 134
Segment 10 Time: 134
Sum of Time required for all Segments: 887
Time required from First point to Last point: 1084
`

(by Atif KhanAtif Khan)

參考文件

  1. Google Maps Distance Matrix API duration in traffic adding all segments returning wrong result (CC BY‑SA 2.5/3.0/4.0)

#distance #google-api #distance-matrix






相關問題

矩陣,距離,javascript (matrix,distance, javascript)

兩點之間的距離以拋出負值 (Distance between two points to throw negative values)

如何在表格視圖中設置與註釋的距離? (How do I set distance to annotation in tableview?)

用於計算距離和速度的 iPhone 應用程序 (iPhone app for calculating distance and speed)

計算第一行經緯度與第二行經緯度之間的距離 (Calculate the distance between 1st row lat long with 2nd row lat long)

在 Android 中計算總行駛距離 Google Maps API V3 (Calculate the total travelled distance Google Maps API V3 in Android)

線段中的等距點 (Equidistant points in a line segment)

兩部安卓手機之間的距離 (Distance between two android phones)

Android:從 SQLite 獲取數據並按與手機的距離以列表視圖順序顯示的最佳實踐 (Android: Best practice to get data from SQLite and show in a listview order by distance from phone)

流量中的 Google Maps Distance Matrix API 持續時間添加返回錯誤結果的所有段 (Google Maps Distance Matrix API duration in traffic adding all segments returning wrong result)

numpy python:向量化距離函數以計算維度為(m,3)的2個矩陣的成對距離 (numpy python: vectorize distance function to calculate pairwise distance of 2 matrix with a dimension of (m, 3))

解決 sqrt 函數 Python 中的 TypeError 錯誤 (Solving TypeError bug in sqrt function Python)







留言討論