GIScience / openrouteservice-r

:globe_with_meridians: query openrouteservice API from R
https://giscience.github.io/openrouteservice-r/
Apache License 2.0
98 stars 23 forks source link

Unit-aware arguments to `ors_isochrones()` #51

Open aoles opened 5 years ago

aoles commented 5 years ago

Leverage the units package for assigning units to variables provided to arguments such as ranges or intervals to e.g. ors_isochrones() and for doing the conversion from hours/minutes to the internal representation in seconds. Based on unit type (time vs. distance) appropriate range_type could be chosen, see also measurements.

library(units)
#> udunits system database from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/units/share/udunits

x <- set_units(20, "min")
x
#> 20 [min]

units(x) <- "secs"
x
#> 1200 [s]

library(measurements)
conv_unit_options$duration
#>  [1] "nsec" "usec" "msec" "sec"  "min"  "hr"   "day"  "wk"   "mon"  "yr"  
#> [11] "dec"  "cen"  "mil"  "Ma"

Created on 2019-05-09 by the reprex package (v0.2.1)