-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Update Routing API to v8 #87
Labels
Comments
munterfi
added
enhancement
New feature or request
dependencies
Pull requests that update a dependency file
labels
Nov 23, 2020
munterfi
added a commit
that referenced
this issue
Dec 17, 2020
munterfi
added a commit
that referenced
this issue
Dec 19, 2020
munterfi
added a commit
that referenced
this issue
Dec 23, 2020
Check correctness of timezones with new APIs (see #94): library(hereR)
# Timestamp with different timezone as my local CET
(datetime = as.POSIXct("2020-12-17 08:00:00", tz = "Europe/Moscow"))
#> [1] "2020-12-17 08:00:00 MSK"
connection(poi[1, ], poi[2, ], datetime = datetime)$departure[1]
#> [1] "2020-12-17 08:53:00 MSK"
intermodal_route(poi[1, ], poi[2, ], datetime = datetime)$departure[1]
#> [1] "2020-12-17 08:53:00 MSK"
route(poi[1, ], poi[2, ], datetime = datetime)$departure[1]
#> [1] "2020-12-17 08:00:00 MSK"
route_matrix(poi[1, ], poi[2, ], datetime = datetime)$departure[1]
#> [1] "2020-12-17 08:00:00 MSK"
isoline(poi[1, ], datetime = datetime)$departure[1]
#> [1] "2020-12-17 08:00:00 MSK"
# Timestamp with my local timezone (CET)
(datetime = as.POSIXct("2020-12-17 08:00:00", tz = "Europe/Zurich"))
#> [1] "2020-12-17 08:00:00 CET"
connection(poi[1, ], poi[2, ], datetime = datetime)$departure[1]
#> [1] "2020-12-17 08:49:00 CET"
intermodal_route(poi[1, ], poi[2, ], datetime = datetime)$departure[1]
#> [1] "2020-12-17 08:49:00 CET"
route(poi[1, ], poi[2, ], datetime = datetime)$departure[1]
#> [1] "2020-12-17 08:00:00 CET"
route_matrix(poi[1, ], poi[2, ], datetime = datetime)$departure[1]
#> [1] "2020-12-17 08:00:00 CET"
isoline(poi[1, ], datetime = datetime)$departure[1]
#> [1] "2020-12-17 08:00:00 CET" Session infodevtools::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#> setting value
#> version R version 4.0.3 (2020-10-10)
#> os macOS Catalina 10.15.7
#> system x86_64, darwin17.0
#> ui X11
#> language (EN)
#> collate en_US.UTF-8
#> ctype en_US.UTF-8
#> tz Europe/Zurich
#> date 2020-12-23
#>
#> ─ Packages ───────────────────────────────────────────────────────────────────
#> package * version date lib source
#> assertthat 0.2.1 2019-03-21 [1] CRAN (R 4.0.0)
#> callr 3.5.1 2020-10-13 [1] CRAN (R 4.0.2)
#> class 7.3-17 2020-04-26 [1] CRAN (R 4.0.3)
#> classInt 0.4-3 2020-04-07 [1] CRAN (R 4.0.0)
#> cli 2.2.0 2020-11-20 [1] CRAN (R 4.0.2)
#> crayon 1.3.4 2017-09-16 [1] CRAN (R 4.0.0)
#> curl 4.3 2019-12-02 [1] CRAN (R 4.0.1)
#> data.table 1.13.2 2020-10-19 [1] CRAN (R 4.0.3)
#> DBI 1.1.0 2019-12-15 [1] CRAN (R 4.0.2)
#> desc 1.2.0 2018-05-01 [1] CRAN (R 4.0.0)
#> devtools 2.3.2 2020-09-18 [1] CRAN (R 4.0.2)
#> digest 0.6.27 2020-10-24 [1] CRAN (R 4.0.2)
#> dplyr 1.0.2 2020-08-18 [1] CRAN (R 4.0.2)
#> e1071 1.7-4 2020-10-14 [1] CRAN (R 4.0.2)
#> ellipsis 0.3.1 2020-05-15 [1] CRAN (R 4.0.0)
#> evaluate 0.14 2019-05-28 [1] CRAN (R 4.0.0)
#> fansi 0.4.1 2020-01-08 [1] CRAN (R 4.0.0)
#> flexpolyline 0.2.1 2020-12-21 [1] local
#> fs 1.5.0 2020-07-31 [1] CRAN (R 4.0.2)
#> generics 0.1.0 2020-10-31 [1] CRAN (R 4.0.2)
#> glue 1.4.2 2020-08-27 [1] CRAN (R 4.0.2)
#> hereR * 0.5.2.9000 2020-12-23 [1] local
#> htmltools 0.5.0 2020-06-16 [1] CRAN (R 4.0.2)
#> jsonlite 1.7.1 2020-09-07 [1] CRAN (R 4.0.2)
#> KernSmooth 2.23-18 2020-10-29 [1] CRAN (R 4.0.2)
#> knitr 1.30 2020-09-22 [1] CRAN (R 4.0.2)
#> lifecycle 0.2.0 2020-03-06 [1] CRAN (R 4.0.0)
#> magrittr 2.0.1 2020-11-17 [1] CRAN (R 4.0.2)
#> memoise 1.1.0 2017-04-21 [1] CRAN (R 4.0.0)
#> pillar 1.4.7 2020-11-20 [1] CRAN (R 4.0.2)
#> pkgbuild 1.1.0 2020-07-13 [1] CRAN (R 4.0.2)
#> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.0.0)
#> pkgload 1.1.0 2020-05-29 [1] CRAN (R 4.0.2)
#> prettyunits 1.1.1 2020-01-24 [1] CRAN (R 4.0.0)
#> processx 3.4.4 2020-09-03 [1] CRAN (R 4.0.2)
#> ps 1.4.0 2020-10-07 [1] CRAN (R 4.0.2)
#> purrr 0.3.4 2020-04-17 [1] CRAN (R 4.0.0)
#> R6 2.5.0 2020-10-28 [1] CRAN (R 4.0.2)
#> Rcpp 1.0.5 2020-07-06 [1] CRAN (R 4.0.2)
#> remotes 2.2.0 2020-07-21 [1] CRAN (R 4.0.2)
#> rlang 0.4.9 2020-11-26 [1] CRAN (R 4.0.3)
#> rmarkdown 2.5 2020-10-21 [1] CRAN (R 4.0.2)
#> rprojroot 2.0.2 2020-11-15 [1] CRAN (R 4.0.2)
#> sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 4.0.0)
#> sf 0.9-6 2020-09-13 [1] CRAN (R 4.0.2)
#> stringi 1.5.3 2020-09-09 [1] CRAN (R 4.0.2)
#> stringr 1.4.0 2019-02-10 [1] CRAN (R 4.0.2)
#> testthat 3.0.0 2020-10-31 [1] CRAN (R 4.0.2)
#> tibble 3.0.4 2020-10-12 [1] CRAN (R 4.0.2)
#> tidyselect 1.1.0 2020-05-11 [1] CRAN (R 4.0.0)
#> units 0.6-7 2020-06-13 [1] CRAN (R 4.0.2)
#> usethis 1.6.3 2020-09-17 [1] CRAN (R 4.0.2)
#> vctrs 0.3.5 2020-11-17 [1] CRAN (R 4.0.2)
#> withr 2.3.0 2020-09-22 [1] CRAN (R 4.0.2)
#> xfun 0.19 2020-10-30 [1] CRAN (R 4.0.2)
#> yaml 2.2.1 2020-02-01 [1] CRAN (R 4.0.0)
#>
#> [1] /Library/Frameworks/R.framework/Versions/4.0/Resources/library |
Check for completeness of route combinations in Construct a dummy data set: library(sf)
#> Linking to GEOS 3.8.1, GDAL 3.1.4, PROJ 6.3.1
n <- 200
l <- n*n
(sf <-
data.frame(
idx = seq(1, n),
lng = runif(n, 7.5, 8.5),
lat = runif(n, 47.25, 47.75)
) %>%
st_as_sf(coords = c("lng", "lat")) %>%
st_set_crs(4326))
#> Simple feature collection with 200 features and 1 field
#> geometry type: POINT
#> dimension: XY
#> bbox: xmin: 7.506527 ymin: 47.25083 xmax: 8.497812 ymax: 47.74371
#> geographic CRS: WGS 84
#> First 10 features:
#> idx geometry
#> 1 1 POINT (7.751984 47.64646)
#> 2 2 POINT (7.668101 47.32461)
#> 3 3 POINT (7.559412 47.61516)
#> 4 4 POINT (8.148569 47.45528)
#> 5 5 POINT (8.331784 47.47819)
#> 6 6 POINT (8.272505 47.41565)
#> 7 7 POINT (8.418097 47.70016)
#> 8 8 POINT (8.19467 47.67536)
#> 9 9 POINT (7.658258 47.42345)
#> 10 10 POINT (8.273231 47.62908) Functions for testing inputs, requests and return values: n_request <- function(x, y = NULL) {
message(
sprintf(
"Number of requests: %s",
ifelse(
is.null(y),
length(route_matrix(x, url_only = TRUE)),
length(route_matrix(x, y, url_only = TRUE))
)
)
)
}
test_one_input <- function(x) {
message("* Only origin *")
n_request(x)
el <- route_matrix(x)
message(sprintf(
"Orig rows: %s, edgelist rows: %s \nInput combinations: %s, output combinations: %s",
nrow(x), nrow(x)*nrow(x), nrow(el),
length(unique(paste0(el$orig_id, "_", el$dest_id)))))
return(el)
}
test_two_inputs <- function(x, y) {
message("* Origin and destination*")
n_request(x, y)
el <- route_matrix(x, y)
message(sprintf(
"Orig rows: %s, dest rows: %s, edgelist rows: %s \nInput combinations: %s, output combinations: %s",
nrow(x), nrow(y), nrow(el), nrow(x)*nrow(y),
length(unique(paste0(el$orig_id, "_", el$dest_id)))))
return(el)
} Calculate all input variants in
el1 <- test_one_input(sf)
#> * Only origin *
#> Number of requests: 28
#> Orig rows: 200, edgelist rows: 40000
#> Input combinations: 40000, output combinations: 40000
el2 <- test_two_inputs(sf[1:(n/2), ], sf[(n/2 + 1):n, ])
#> * Origin and destination*
#> Number of requests: 7
#> Orig rows: 100, dest rows: 100, edgelist rows: 10000
#> Input combinations: 10000, output combinations: 10000
el3 <- test_two_inputs(sf[(n/3 + 1):n, ], sf[1:(n/2), ])
#> * Origin and destination*
#> Number of requests: 14
#> Orig rows: 133, dest rows: 100, edgelist rows: 13300
#> Input combinations: 13300, output combinations: 13300
el4 <- test_two_inputs(sf[1:(n/2), ], sf[(n/3 + 1):n, ])
#> * Origin and destination*
#> Number of requests: 14
#> Orig rows: 100, dest rows: 133, edgelist rows: 13300
#> Input combinations: 13300, output combinations: 13300
el6 <- test_two_inputs(sf[1:(n - 1), ], sf[n, ])
#> * Origin and destination*
#> Number of requests: 2
#> Orig rows: 199, dest rows: 1, edgelist rows: 199
#> Input combinations: 199, output combinations: 199
el5 <- test_two_inputs(sf[1, ], sf[2:n, ])
#> * Origin and destination*
#> Number of requests: 2
#> Orig rows: 1, dest rows: 199, edgelist rows: 199
#> Input combinations: 199, output combinations: 199 Session infodevtools::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#> setting value
#> version R version 4.0.3 (2020-10-10)
#> os macOS Catalina 10.15.7
#> system x86_64, darwin17.0
#> ui X11
#> language (EN)
#> collate en_US.UTF-8
#> ctype en_US.UTF-8
#> tz Europe/Zurich
#> date 2020-12-23
#>
#> ─ Packages ───────────────────────────────────────────────────────────────────
#> package * version date lib source
#> assertthat 0.2.1 2019-03-21 [1] CRAN (R 4.0.0)
#> callr 3.5.1 2020-10-13 [1] CRAN (R 4.0.2)
#> class 7.3-17 2020-04-26 [1] CRAN (R 4.0.3)
#> classInt 0.4-3 2020-04-07 [1] CRAN (R 4.0.0)
#> cli 2.2.0 2020-11-20 [1] CRAN (R 4.0.2)
#> crayon 1.3.4 2017-09-16 [1] CRAN (R 4.0.0)
#> curl 4.3 2019-12-02 [1] CRAN (R 4.0.1)
#> data.table 1.13.2 2020-10-19 [1] CRAN (R 4.0.3)
#> DBI 1.1.0 2019-12-15 [1] CRAN (R 4.0.2)
#> desc 1.2.0 2018-05-01 [1] CRAN (R 4.0.0)
#> devtools 2.3.2 2020-09-18 [1] CRAN (R 4.0.2)
#> digest 0.6.27 2020-10-24 [1] CRAN (R 4.0.2)
#> dplyr 1.0.2 2020-08-18 [1] CRAN (R 4.0.2)
#> e1071 1.7-4 2020-10-14 [1] CRAN (R 4.0.2)
#> ellipsis 0.3.1 2020-05-15 [1] CRAN (R 4.0.0)
#> evaluate 0.14 2019-05-28 [1] CRAN (R 4.0.0)
#> fansi 0.4.1 2020-01-08 [1] CRAN (R 4.0.0)
#> fs 1.5.0 2020-07-31 [1] CRAN (R 4.0.2)
#> generics 0.1.0 2020-10-31 [1] CRAN (R 4.0.2)
#> glue 1.4.2 2020-08-27 [1] CRAN (R 4.0.2)
#> hereR * 0.5.2.9000 2020-12-23 [1] local
#> htmltools 0.5.0 2020-06-16 [1] CRAN (R 4.0.2)
#> jsonlite 1.7.1 2020-09-07 [1] CRAN (R 4.0.2)
#> KernSmooth 2.23-18 2020-10-29 [1] CRAN (R 4.0.2)
#> knitr 1.30 2020-09-22 [1] CRAN (R 4.0.2)
#> lifecycle 0.2.0 2020-03-06 [1] CRAN (R 4.0.0)
#> magrittr 2.0.1 2020-11-17 [1] CRAN (R 4.0.2)
#> memoise 1.1.0 2017-04-21 [1] CRAN (R 4.0.0)
#> pillar 1.4.7 2020-11-20 [1] CRAN (R 4.0.2)
#> pkgbuild 1.1.0 2020-07-13 [1] CRAN (R 4.0.2)
#> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.0.0)
#> pkgload 1.1.0 2020-05-29 [1] CRAN (R 4.0.2)
#> prettyunits 1.1.1 2020-01-24 [1] CRAN (R 4.0.0)
#> processx 3.4.4 2020-09-03 [1] CRAN (R 4.0.2)
#> ps 1.4.0 2020-10-07 [1] CRAN (R 4.0.2)
#> purrr 0.3.4 2020-04-17 [1] CRAN (R 4.0.0)
#> R6 2.5.0 2020-10-28 [1] CRAN (R 4.0.2)
#> Rcpp 1.0.5 2020-07-06 [1] CRAN (R 4.0.2)
#> remotes 2.2.0 2020-07-21 [1] CRAN (R 4.0.2)
#> rlang 0.4.9 2020-11-26 [1] CRAN (R 4.0.3)
#> rmarkdown 2.5 2020-10-21 [1] CRAN (R 4.0.2)
#> rprojroot 2.0.2 2020-11-15 [1] CRAN (R 4.0.2)
#> sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 4.0.0)
#> sf * 0.9-6 2020-09-13 [1] CRAN (R 4.0.2)
#> stringi 1.5.3 2020-09-09 [1] CRAN (R 4.0.2)
#> stringr 1.4.0 2019-02-10 [1] CRAN (R 4.0.2)
#> testthat 3.0.0 2020-10-31 [1] CRAN (R 4.0.2)
#> tibble 3.0.4 2020-10-12 [1] CRAN (R 4.0.2)
#> tidyselect 1.1.0 2020-05-11 [1] CRAN (R 4.0.0)
#> units 0.6-7 2020-06-13 [1] CRAN (R 4.0.2)
#> usethis 1.6.3 2020-09-17 [1] CRAN (R 4.0.2)
#> vctrs 0.3.5 2020-11-17 [1] CRAN (R 4.0.2)
#> withr 2.3.0 2020-09-22 [1] CRAN (R 4.0.2)
#> xfun 0.19 2020-10-30 [1] CRAN (R 4.0.2)
#> yaml 2.2.1 2020-02-01 [1] CRAN (R 4.0.0)
#>
#> [1] /Library/Frameworks/R.framework/Versions/4.0/Resources/library |
Merged
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
The Routing API v7 used in the {hereR} package is no longer actively developed. Newer versions of the APIs are available and the package should be updated to the:
New endpoints to use:
route()
: https://router.hereapi.com/v8/routesroute_matrix()
: https://matrix.router.hereapi.com/v8/matrixisoline()
: https://isoline.router.hereapi.com/v8/isolinesNote: The shapes are encoded in the flexible polyline encoding format and have to be decoded using the {flexpolyline} package. The pacakge is not yet supporting the geometry type "POLYGON", which has to be implemented first (see munterfi/flexpolyline#31).
The text was updated successfully, but these errors were encountered: