Skip to content
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

Bug: Request 'id = 1' failed: Status 400 when using Isoline #147

Closed
DimitriBrattle opened this issue Nov 10, 2021 · 3 comments
Closed

Bug: Request 'id = 1' failed: Status 400 when using Isoline #147

DimitriBrattle opened this issue Nov 10, 2021 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@DimitriBrattle
Copy link

When trying to use isoline(), I get the error

Warning message:
In .parse_response(i, out$responses()[[i]]) :
Request 'id = 1' failed: Status 400.

My code is as follows

poi = st_as_sf(GEO, coords = c("LON", "LAT"), crs = 4326)
isolines = isoline(poi = poi,
range = seq(10, 10, 1)*1000, range_type = "distance",
transport_mode = "truck", routing_mode = "short", traffic = FALSE,
url_only = FALSE)

where GEO is a single-row dataframe with geocordinates of LON and LAT.

@DimitriBrattle DimitriBrattle added the bug Something isn't working label Nov 10, 2021
@munterfi munterfi self-assigned this Nov 11, 2021
@munterfi
Copy link
Owner

Hi @DimitriBrattle, thanks for reporting!

I can reproduce the error:

library(hereR)
set_verbose(TRUE)
library(sf)
#> Linking to GEOS 3.8.1, GDAL 3.2.1, PROJ 7.2.1

# Dummy dataset
poi <- data.frame(
  id = 1,
  lng = 8,
  lat = 46
) %>% st_as_sf(coords = c("lng", "lat"), crs = 4326)

# Isoline
(iso <- isoline(
  poi = poi,
  range = seq(10, 10, 1) * 1000, range_type = "distance",
  transport_mode = "truck", routing_mode = "short", traffic = FALSE,
  url_only = FALSE
))
#> Sending 1 request(s) with 1 RPS to: 'https://isoline.router.hereapi.com/v8/isolines?...'
#> Warning in .parse_response(i, out$responses()[[i]]): Request 'id = 1' failed:
#> Status 400.
#> Received 1 response(s) with total size: 288 bytes
#> NULL

Checking the error message from the API:

(iso_url <- isoline(
  poi = poi,
  range = seq(10, 10, 1) * 1000, range_type = "distance",
  transport_mode = "truck", routing_mode = "short", traffic = FALSE,
  url_only = TRUE
))
#> [1] "https://isoline.router.hereapi.com/v8/isolines?apiKey=<API_KEY>&origin=46,8&arrivalTime=any&departureTime=any&transportMode=truck&range[values]=10000&range[type]=distance&optimizeFor=balanced&ev[freeFlowSpeedTable]=0,0.239,27,0.239,45,0.259,60,0.196,75,0.207,90,0.238,100,0.26,110,0.296,120,0.337,130,0.351,250,0.351&ev[trafficSpeedTable]=0,0.349,27,0.319,45,0.329,60,0.266,75,0.287,90,0.318,100,0.33,110,0.335,120,0.35,130,0.36,250,0.36&ev[ascent]=9&ev[descent]=4.3&ev[auxiliaryConsumption]=1.8&departure=2021-11-11T10:09:21%2B01:00"

The response:

{
   "title":"Malformed request",
   "status":400,
   "code":"E605001",
   "cause":"Error while parsing request: 'arrivalTime' is not supported for 'origin'\n",
   "action":"",
   "correlationId":"65793739-ea22-4b11-ad39-e357968b294e"
}

It seems that HERE has changed behaviour of the departureTime and arrivalTime query parameters. According of the
documentation in &arrivalTime=any&departureTime=any the value any is no longer supported and there seems not the be a possiblity to send time (and thereby traffic) independent requests.

Omitting the time parameter will cause HERE to set the departure or arrival time to the current time:

  • departureTime:

If neither departureTime or arrivalTime are specified, current time at
departure location will be used if origin is specified. It cannot be
used in combination with destination parameter.

  • arrivalTime:

If neither departureTime or arrivalTime are specified, current time at
arrival location will be used if destination is specified. It cannot
be used in combination with origin parameter.

Probably the traffic parameter of hereR::isoline() has to be deprecated.

As a quick fix, set the traffic parameter to TRUE:

(iso_url <- isoline(
  poi = poi,
  range = seq(10, 10, 1) * 1000, range_type = "distance",
  transport_mode = "truck", routing_mode = "short", traffic = TRUE,
  url_only = FALSE
))
#> Sending 1 request(s) with 1 RPS to: 'https://isoline.router.hereapi.com/v8/isolines?...'
#> Received 1 response(s) with total size: 2.3 Kb
#> Simple feature collection with 1 feature and 5 fields
#> Geometry type: POLYGON
#> Dimension:     XY
#> Bounding box:  xmin: 7.95204 ymin: 45.9565 xmax: 8.07495 ymax: 45.97435
#> Geodetic CRS:  WGS 84
#>   id rank           departure arrival range                       geometry
#> 1 NA    1 2021-11-11 10:09:21    <NA> 10000 POLYGON ((7.95238 45.97298,...
Session info
devtools::session_info()
#> ─ Session info  🍽️  👨🏿‍🚒  🖐🏾   ─────────────────────────────────────────────────
#>  hash: fork and knife with plate, man firefighter: dark skin tone, hand with fingers splayed: medium-dark skin tone
#> 
#>  setting  value
#>  version  R version 4.1.1 (2021-08-10)
#>  os       macOS Big Sur 10.16
#>  system   x86_64, darwin17.0
#>  ui       X11
#>  language (EN)
#>  collate  en_US.UTF-8
#>  ctype    en_US.UTF-8
#>  tz       Europe/Zurich
#>  date     2021-11-11
#>  pandoc   2.16.1 @ /usr/local/bin/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package      * version date (UTC) lib source
#>  cachem         1.0.6   2021-08-19 [1] CRAN (R 4.1.0)
#>  callr          3.7.0   2021-04-20 [1] CRAN (R 4.1.0)
#>  class          7.3-19  2021-05-03 [1] CRAN (R 4.1.1)
#>  classInt       0.4-3   2020-04-07 [1] CRAN (R 4.1.0)
#>  cli            3.1.0   2021-10-27 [1] CRAN (R 4.1.0)
#>  crayon         1.4.2   2021-10-29 [1] CRAN (R 4.1.0)
#>  crul           1.1.0   2021-02-15 [1] CRAN (R 4.1.0)
#>  curl           4.3.2   2021-06-23 [1] CRAN (R 4.1.0)
#>  data.table     1.14.2  2021-09-27 [1] CRAN (R 4.1.0)
#>  DBI            1.1.1   2021-01-15 [1] CRAN (R 4.1.0)
#>  desc           1.4.0   2021-09-28 [1] CRAN (R 4.1.0)
#>  devtools       2.4.2   2021-06-07 [1] CRAN (R 4.1.0)
#>  digest         0.6.28  2021-09-23 [1] CRAN (R 4.1.0)
#>  dplyr          1.0.7   2021-06-18 [1] CRAN (R 4.1.0)
#>  e1071          1.7-9   2021-09-16 [1] CRAN (R 4.1.0)
#>  ellipsis       0.3.2   2021-04-29 [1] CRAN (R 4.1.0)
#>  evaluate       0.14    2019-05-28 [1] CRAN (R 4.1.0)
#>  fansi          0.5.0   2021-05-25 [1] CRAN (R 4.1.0)
#>  fastmap        1.1.0   2021-01-25 [1] CRAN (R 4.1.0)
#>  flexpolyline   0.2.4   2021-10-02 [1] CRAN (R 4.1.0)
#>  fs             1.5.0   2020-07-31 [1] CRAN (R 4.1.0)
#>  generics       0.1.1   2021-10-25 [1] CRAN (R 4.1.0)
#>  glue           1.5.0   2021-11-07 [1] CRAN (R 4.1.0)
#>  hereR        * 0.8.1   2021-10-04 [1] CRAN (R 4.1.0)
#>  htmltools      0.5.2   2021-08-25 [1] CRAN (R 4.1.0)
#>  httpcode       0.3.0   2020-04-10 [1] CRAN (R 4.1.0)
#>  jsonlite       1.7.2   2020-12-09 [1] CRAN (R 4.1.0)
#>  KernSmooth     2.23-20 2021-05-03 [1] CRAN (R 4.1.1)
#>  knitr          1.36    2021-09-29 [1] CRAN (R 4.1.0)
#>  lifecycle      1.0.1   2021-09-24 [1] CRAN (R 4.1.1)
#>  magrittr       2.0.1   2020-11-17 [1] CRAN (R 4.1.0)
#>  memoise        2.0.0   2021-01-26 [1] CRAN (R 4.1.0)
#>  pillar         1.6.4   2021-10-18 [1] CRAN (R 4.1.0)
#>  pkgbuild       1.2.0   2020-12-15 [1] CRAN (R 4.1.0)
#>  pkgconfig      2.0.3   2019-09-22 [1] CRAN (R 4.1.0)
#>  pkgload        1.2.3   2021-10-13 [1] CRAN (R 4.1.0)
#>  prettyunits    1.1.1   2020-01-24 [1] CRAN (R 4.1.0)
#>  processx       3.5.2   2021-04-30 [1] CRAN (R 4.1.0)
#>  proxy          0.4-26  2021-06-07 [1] CRAN (R 4.1.0)
#>  ps             1.6.0   2021-02-28 [1] CRAN (R 4.1.0)
#>  purrr          0.3.4   2020-04-17 [1] CRAN (R 4.1.0)
#>  R6             2.5.1   2021-08-19 [1] CRAN (R 4.1.0)
#>  Rcpp           1.0.7   2021-07-07 [1] CRAN (R 4.1.0)
#>  remotes        2.4.1   2021-09-29 [1] CRAN (R 4.1.0)
#>  rlang          0.4.12  2021-10-18 [1] CRAN (R 4.1.0)
#>  rmarkdown      2.11    2021-09-14 [1] CRAN (R 4.1.0)
#>  rprojroot      2.0.2   2020-11-15 [1] CRAN (R 4.1.0)
#>  rstudioapi     0.13    2020-11-12 [1] CRAN (R 4.1.0)
#>  s2             1.0.7   2021-09-28 [1] CRAN (R 4.1.0)
#>  sessioninfo    1.2.1   2021-11-02 [1] CRAN (R 4.1.0)
#>  sf           * 1.0-3   2021-10-07 [1] CRAN (R 4.1.0)
#>  stringi        1.7.5   2021-10-04 [1] CRAN (R 4.1.0)
#>  stringr        1.4.0   2019-02-10 [1] CRAN (R 4.1.0)
#>  testthat       3.1.0   2021-10-04 [1] CRAN (R 4.1.0)
#>  tibble         3.1.6   2021-11-07 [1] CRAN (R 4.1.0)
#>  tidyselect     1.1.1   2021-04-30 [1] CRAN (R 4.1.0)
#>  units          0.7-2   2021-06-08 [1] CRAN (R 4.1.0)
#>  usethis        2.1.3   2021-10-27 [1] CRAN (R 4.1.0)
#>  utf8           1.2.2   2021-07-24 [1] CRAN (R 4.1.0)
#>  vctrs          0.3.8   2021-04-29 [1] CRAN (R 4.1.0)
#>  withr          2.4.2   2021-04-18 [1] CRAN (R 4.1.0)
#>  wk             0.5.0   2021-07-13 [1] CRAN (R 4.1.0)
#>  xfun           0.28    2021-11-04 [1] CRAN (R 4.1.0)
#>  yaml           2.2.1   2020-02-01 [1] CRAN (R 4.1.0)
#> 
#>  [1] /Library/Frameworks/R.framework/Versions/4.1/Resources/library
#> 
#> ──────────────────────────────────────────────────────────────────────────────

@munterfi
Copy link
Owner

I was wrong: Time independent routing is still possible and any as value is still accepted.

https://isoline.router.hereapi.com/v8/isolines?apiKey=<API-KEY>&origin=46,8&departureTime=any&transportMode=truck&range[values]=10000&range[type]=distance&optimizeFor=balanced&ev[freeFlowSpeedTable]=0,0.239,27,0.239,45,0.259,60,0.196,75,0.207,90,0.238,100,0.26,110,0.296,120,0.337,130,0.351,250,0.351&ev[trafficSpeedTable]=0,0.349,27,0.319,45,0.329,60,0.266,75,0.287,90,0.318,100,0.33,110,0.335,120,0.35,130,0.36,250,0.36&ev[ascent]=9&ev[descent]=4.3&ev[auxiliaryConsumption]=1.8
  • departureTime can not be combined with destination.
  • arrivalTime can not be combined with origin.

The traffic parameter of hereR::isoline() has not to be deprecated.

@munterfi
Copy link
Owner

munterfi commented Nov 11, 2021

With the development version of the package remotes::install_github("munterfi/hereR") it should work now
as expected:

library(hereR)
set_verbose(TRUE)
library(sf)
#> Linking to GEOS 3.8.1, GDAL 3.2.1, PROJ 7.2.1

# Dummy dataset
poi <- data.frame(
  id = 1,
  lng = 8,
  lat = 46
) %>% st_as_sf(coords = c("lng", "lat"), crs = 4326)

# Isoline
(iso <- isoline(
  poi = poi,
  range = seq(10, 10, 1) * 1000, range_type = "distance",
  transport_mode = "truck", routing_mode = "short", traffic = FALSE,
  url_only = FALSE
))
#> Sending 1 request(s) with 1 RPS to: 'https://isoline.router.hereapi.com/v8/isolines?...'
#> Received 1 response(s) with total size: 2.2 Kb
#> Simple feature collection with 1 feature and 5 fields
#> Geometry type: POLYGON
#> Dimension:     XY
#> Bounding box:  xmin: 7.95204 ymin: 45.9565 xmax: 8.07495 ymax: 45.97435
#> Geodetic CRS:  WGS 84
#>   id rank departure arrival range                       geometry
#> 1 NA    1      <NA>    <NA> 10000 POLYGON ((7.95238 45.97298,...
Session info
devtools::session_info()
#> ─ Session info  🦹🏼  🇻🇬  👨‍🏫   ─────────────────────────────────────────────────
#>  hash: supervillain: medium-light skin tone, flag: British Virgin Islands, man teacher
#> 
#>  setting  value
#>  version  R version 4.1.1 (2021-08-10)
#>  os       macOS Big Sur 10.16
#>  system   x86_64, darwin17.0
#>  ui       X11
#>  language (EN)
#>  collate  en_US.UTF-8
#>  ctype    en_US.UTF-8
#>  tz       Europe/Zurich
#>  date     2021-11-11
#>  pandoc   2.16.1 @ /usr/local/bin/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package      * version    date (UTC) lib source
#>  cachem         1.0.6      2021-08-19 [1] CRAN (R 4.1.0)
#>  callr          3.7.0      2021-04-20 [1] CRAN (R 4.1.0)
#>  class          7.3-19     2021-05-03 [1] CRAN (R 4.1.1)
#>  classInt       0.4-3      2020-04-07 [1] CRAN (R 4.1.0)
#>  cli            3.1.0      2021-10-27 [1] CRAN (R 4.1.0)
#>  crayon         1.4.2      2021-10-29 [1] CRAN (R 4.1.0)
#>  crul           1.1.0      2021-02-15 [1] CRAN (R 4.1.0)
#>  curl           4.3.2      2021-06-23 [1] CRAN (R 4.1.0)
#>  data.table     1.14.2     2021-09-27 [1] CRAN (R 4.1.0)
#>  DBI            1.1.1      2021-01-15 [1] CRAN (R 4.1.0)
#>  desc           1.4.0      2021-09-28 [1] CRAN (R 4.1.0)
#>  devtools       2.4.2      2021-06-07 [1] CRAN (R 4.1.0)
#>  digest         0.6.28     2021-09-23 [1] CRAN (R 4.1.0)
#>  dplyr          1.0.7      2021-06-18 [1] CRAN (R 4.1.0)
#>  e1071          1.7-9      2021-09-16 [1] CRAN (R 4.1.0)
#>  ellipsis       0.3.2      2021-04-29 [1] CRAN (R 4.1.0)
#>  evaluate       0.14       2019-05-28 [1] CRAN (R 4.1.0)
#>  fansi          0.5.0      2021-05-25 [1] CRAN (R 4.1.0)
#>  fastmap        1.1.0      2021-01-25 [1] CRAN (R 4.1.0)
#>  flexpolyline   0.2.4      2021-10-02 [1] CRAN (R 4.1.0)
#>  fs             1.5.0      2020-07-31 [1] CRAN (R 4.1.0)
#>  generics       0.1.1      2021-10-25 [1] CRAN (R 4.1.0)
#>  glue           1.5.0      2021-11-07 [1] CRAN (R 4.1.0)
#>  hereR        * 0.8.1.9000 2021-11-11 [1] Github (munterfi/hereR@8e0b45f)
#>  htmltools      0.5.2      2021-08-25 [1] CRAN (R 4.1.0)
#>  httpcode       0.3.0      2020-04-10 [1] CRAN (R 4.1.0)
#>  jsonlite       1.7.2      2020-12-09 [1] CRAN (R 4.1.0)
#>  KernSmooth     2.23-20    2021-05-03 [1] CRAN (R 4.1.1)
#>  knitr          1.36       2021-09-29 [1] CRAN (R 4.1.0)
#>  lifecycle      1.0.1      2021-09-24 [1] CRAN (R 4.1.1)
#>  magrittr       2.0.1      2020-11-17 [1] CRAN (R 4.1.0)
#>  memoise        2.0.0      2021-01-26 [1] CRAN (R 4.1.0)
#>  pillar         1.6.4      2021-10-18 [1] CRAN (R 4.1.0)
#>  pkgbuild       1.2.0      2020-12-15 [1] CRAN (R 4.1.0)
#>  pkgconfig      2.0.3      2019-09-22 [1] CRAN (R 4.1.0)
#>  pkgload        1.2.3      2021-10-13 [1] CRAN (R 4.1.0)
#>  prettyunits    1.1.1      2020-01-24 [1] CRAN (R 4.1.0)
#>  processx       3.5.2      2021-04-30 [1] CRAN (R 4.1.0)
#>  proxy          0.4-26     2021-06-07 [1] CRAN (R 4.1.0)
#>  ps             1.6.0      2021-02-28 [1] CRAN (R 4.1.0)
#>  purrr          0.3.4      2020-04-17 [1] CRAN (R 4.1.0)
#>  R6             2.5.1      2021-08-19 [1] CRAN (R 4.1.0)
#>  Rcpp           1.0.7      2021-07-07 [1] CRAN (R 4.1.0)
#>  remotes        2.4.1      2021-09-29 [1] CRAN (R 4.1.0)
#>  rlang          0.4.12     2021-10-18 [1] CRAN (R 4.1.0)
#>  rmarkdown      2.11       2021-09-14 [1] CRAN (R 4.1.0)
#>  rprojroot      2.0.2      2020-11-15 [1] CRAN (R 4.1.0)
#>  rstudioapi     0.13       2020-11-12 [1] CRAN (R 4.1.0)
#>  s2             1.0.7      2021-09-28 [1] CRAN (R 4.1.0)
#>  sessioninfo    1.2.1      2021-11-02 [1] CRAN (R 4.1.0)
#>  sf           * 1.0-3      2021-10-07 [1] CRAN (R 4.1.0)
#>  stringi        1.7.5      2021-10-04 [1] CRAN (R 4.1.0)
#>  stringr        1.4.0      2019-02-10 [1] CRAN (R 4.1.0)
#>  testthat       3.1.0      2021-10-04 [1] CRAN (R 4.1.0)
#>  tibble         3.1.6      2021-11-07 [1] CRAN (R 4.1.0)
#>  tidyselect     1.1.1      2021-04-30 [1] CRAN (R 4.1.0)
#>  units          0.7-2      2021-06-08 [1] CRAN (R 4.1.0)
#>  usethis        2.1.3      2021-10-27 [1] CRAN (R 4.1.0)
#>  utf8           1.2.2      2021-07-24 [1] CRAN (R 4.1.0)
#>  vctrs          0.3.8      2021-04-29 [1] CRAN (R 4.1.0)
#>  withr          2.4.2      2021-04-18 [1] CRAN (R 4.1.0)
#>  wk             0.5.0      2021-07-13 [1] CRAN (R 4.1.0)
#>  xfun           0.28       2021-11-04 [1] CRAN (R 4.1.0)
#>  yaml           2.2.1      2020-02-01 [1] CRAN (R 4.1.0)
#> 
#>  [1] /Library/Frameworks/R.framework/Versions/4.1/Resources/library
#> 
#> ──────────────────────────────────────────────────────────────────────────────

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants