You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Correct me if I'm wrong, but I noticed yesterday while working with mb_directions() that the function is inaccurately returning values for distance + duration. Here's an example that demonstrates this by mapping the walking distance between Zilker Park + UT Austin:
# Extract and display durationtotal_duration<- sum(new_route()$duration, na.rm=TRUE) /60# Convert seconds to minutesoutput$duration<- renderText({
paste("Total travel time:", round(total_duration, 4), "minutes")
})
Looking at the underlying code of this function and a few others, I've noticed that distance is divided by 1000 and duration is divided by 60. This, from what I understand in the Mapbox API Docs that say distance is returned in meters or seconds. Dividing the returned duration output by 60 and the distance by 1000 (as seen in the sample snippet below from mb_directions()) is creating an inaccurate representation of both metrics in that these functions are returning distance in kilometers and duration in minutes.
If this was intentional, I think the documentation should be updated which I can happily make a PR for or the code needs to be modified to omit those divisions by 1000 and 60 so that the returned values are in meters + seconds, as the Mapbox API docs states. Can also do a PR for this as well!
Correct me if I'm wrong, but I noticed yesterday while working with
mb_directions()
that the function is inaccurately returning values for distance + duration. Here's an example that demonstrates this by mapping the walking distance between Zilker Park + UT Austin:Screenshot from Mapbox Directions API Demo
Screenshot from mb_directions() in your Demo Shiny App (with duration added in printout)
Added Code To Print Duration
Looking at the underlying code of this function and a few others, I've noticed that distance is divided by 1000 and duration is divided by 60. This, from what I understand in the Mapbox API Docs that say distance is returned in meters or seconds. Dividing the returned duration output by 60 and the distance by 1000 (as seen in the sample snippet below from
mb_directions()
) is creating an inaccurate representation of both metrics in that these functions are returning distance in kilometers and duration in minutes.If this was intentional, I think the documentation should be updated which I can happily make a PR for or the code needs to be modified to omit those divisions by 1000 and 60 so that the returned values are in meters + seconds, as the Mapbox API docs states. Can also do a PR for this as well!
Let me know what you think!
The text was updated successfully, but these errors were encountered: