-
Notifications
You must be signed in to change notification settings - Fork 0
Speed and Stop Time Calculation from Google Maps Data
jloh02 edited this page Jun 11, 2021
·
3 revisions
Let the 2 known points be A and B. To solve for a and b for point A:
Substitution of b
into original eqn for point B:
To find b
, substitute a
back into the equation for b
Using the following input as sample:
{stops=32, distance=39.081000 km, time=66.000000 min}
{stops=31, distance=36.573000 km, time=62.000000 min}
Answer should be:
a = speed = 0.66411...
b = stopTime = 0.2235337...
If any of the 2 data points return "null", only one data point can be used. To handle this, the stopTime (b) is assumed to be a default value.
To optimize calculations, number of divisions should be decreased. This is because based on Intel's arithmetic latencies. The following equations and corresponding pseudocode is proposed.
In the pseudocode, speed
refers to the mathematical constant a
while stopTime
refers to the constant b
. a
and b
refer to the 2 data points.
sRatio = b.stops / a.stops
speed = (b.distance - sRatio*a.distance)/(b.time - sRatio*a.time)
stopTime = (a.time*speed - a.distance)/(a.stops * speed)