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: hereR::isoline fails: "Error in decode(encoded[[x]]): Invalid format version" #132

Closed
nbanion opened this issue May 12, 2021 · 2 comments
Assignees
Labels
bug Something isn't working duplicate This issue or pull request already exists

Comments

@nbanion
Copy link

nbanion commented May 12, 2021

For specific parameter combinations, hereR::isoline fails. In these cases, I would expect the function to either (1) return a polygon or (2) throw an error that makes my mistake more obvious.

This bug was the motivation to propose workaround #118 . As noted there, it probably makes sense to close that issue and just address the bug directly here.

Below I induce an error by playing with range.

library(hereR)
library(sf)
#> Linking to GEOS 3.8.0, GDAL 3.0.4, PROJ 6.3.1

# A test point.
point <- 
  c(-73.51263, 44.20958) %>% 
  st_point() %>% st_sfc() %>% st_sf(crs = "WGS84")

# Range 1800 (30 min) succeeds.
isoline(point, range = 1800)
#> Simple feature collection with 1 feature and 5 fields
#> geometry type:  POLYGON
#> dimension:      XY
#> bbox:           xmin: -73.88306 ymin: 43.82996 xmax: -73.31863 ymax: 44.64157
#> geographic CRS: WGS 84
#>   id rank           departure             arrival range
#> 1 NA    1 2021-05-12 16:07:03 2021-05-12 16:37:03  1800
#>                         geometry
#> 1 POLYGON ((-73.87688 44.2309...

# Range 3600 (60 min) fails.
isoline(point, range = 3600)
#> Error in decode(encoded[[x]]): Invalid format version

Created on 2021-05-12 by the reprex package (v2.0.0)

@nbanion nbanion added the bug Something isn't working label May 12, 2021
@munterfi munterfi self-assigned this May 14, 2021
@munterfi munterfi added the duplicate This issue or pull request already exists label May 14, 2021
@munterfi
Copy link
Owner

munterfi commented May 14, 2021

Hi, thanks for reporting!

This issue is already fixed in #121:

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

point <- 
  c(-73.51263, 44.20958) %>% 
  st_point() %>% st_sfc() %>% st_sf(crs = "WGS84")

isoline(point, range = 1800)
#> Sending 1 request(s) with 1 RPS to: 'https://isoline.router.hereapi.com/v8/isolines?...'
#> Received 1 response(s) with total size: 5 Kb
#> Simple feature collection with 1 feature and 5 fields
#> Geometry type: POLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -73.90503 ymin: 43.84094 xmax: -73.31863 ymax: 44.64157
#> Geodetic CRS:  WGS 84
#>   id rank           departure             arrival range
#> 1 NA    1 2021-05-14 13:34:00 2021-05-14 14:04:00  1800
#>                         geometry
#> 1 POLYGON ((-73.89885 44.2254...

isoline(point, range = 3600)
#> Sending 1 request(s) with 1 RPS to: 'https://isoline.router.hereapi.com/v8/isolines?...'
#> Received 1 response(s) with total size: 5.9 Kb
#> Simple feature collection with 1 feature and 5 fields
#> Geometry type: MULTIPOLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -74.28955 ymin: 43.42896 xmax: -73.11676 ymax: 45.04395
#> Geodetic CRS:  WGS 84
#>   id rank           departure             arrival range
#> 1 NA    1 2021-05-14 13:34:01 2021-05-14 14:34:01  3600
#>                         geometry
#> 1 MULTIPOLYGON (((-74.27719 4...

Are you using the latest version of the hereR and flexpolyline packages on CRAN?

packageVersion("flexpolyline")
#> [1] '0.2.3'
packageVersion("hereR")
#> [1] '0.7.0'
Session info
devtools::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value                       
#>  version  R version 4.0.5 (2021-03-31)
#>  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-05-14                  
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package      * version date       lib source        
#>  assertthat     0.2.1   2019-03-21 [1] CRAN (R 4.0.0)
#>  cachem         1.0.4   2021-02-13 [1] CRAN (R 4.0.2)
#>  callr          3.7.0   2021-04-20 [1] CRAN (R 4.0.2)
#>  class          7.3-18  2021-01-24 [1] CRAN (R 4.0.5)
#>  classInt       0.4-3   2020-04-07 [1] CRAN (R 4.0.0)
#>  cli            2.5.0   2021-04-26 [1] CRAN (R 4.0.2)
#>  crayon         1.4.1   2021-02-08 [1] CRAN (R 4.0.2)
#>  crul           1.1.0   2021-02-15 [1] CRAN (R 4.0.2)
#>  curl           4.3.1   2021-04-30 [1] CRAN (R 4.0.5)
#>  data.table     1.14.0  2021-02-21 [1] CRAN (R 4.0.2)
#>  DBI            1.1.1   2021-01-15 [1] CRAN (R 4.0.2)
#>  desc           1.3.0   2021-03-05 [1] CRAN (R 4.0.2)
#>  devtools       2.4.0   2021-04-07 [1] CRAN (R 4.0.2)
#>  digest         0.6.27  2020-10-24 [1] CRAN (R 4.0.2)
#>  dplyr          1.0.5   2021-03-05 [1] CRAN (R 4.0.2)
#>  e1071          1.7-6   2021-03-18 [1] CRAN (R 4.0.2)
#>  ellipsis       0.3.2   2021-04-29 [1] CRAN (R 4.0.2)
#>  evaluate       0.14    2019-05-28 [1] CRAN (R 4.0.0)
#>  fansi          0.4.2   2021-01-15 [1] CRAN (R 4.0.2)
#>  fastmap        1.1.0   2021-01-25 [1] CRAN (R 4.0.2)
#>  flexpolyline   0.2.3   2021-04-30 [1] CRAN (R 4.0.2)
#>  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.7.0   2021-04-16 [1] CRAN (R 4.0.2)
#>  htmltools      0.5.1.1 2021-01-22 [1] CRAN (R 4.0.2)
#>  httpcode       0.3.0   2020-04-10 [1] CRAN (R 4.0.2)
#>  jsonlite       1.7.2   2020-12-09 [1] CRAN (R 4.0.2)
#>  KernSmooth     2.23-18 2020-10-29 [1] CRAN (R 4.0.5)
#>  knitr          1.33    2021-04-24 [1] CRAN (R 4.0.2)
#>  lifecycle      1.0.0   2021-02-15 [1] CRAN (R 4.0.2)
#>  magrittr       2.0.1   2020-11-17 [1] CRAN (R 4.0.2)
#>  memoise        2.0.0   2021-01-26 [1] CRAN (R 4.0.2)
#>  pillar         1.6.0   2021-04-13 [1] CRAN (R 4.0.2)
#>  pkgbuild       1.2.0   2020-12-15 [1] CRAN (R 4.0.2)
#>  pkgconfig      2.0.3   2019-09-22 [1] CRAN (R 4.0.0)
#>  pkgload        1.2.1   2021-04-06 [1] CRAN (R 4.0.2)
#>  prettyunits    1.1.1   2020-01-24 [1] CRAN (R 4.0.0)
#>  processx       3.5.2   2021-04-30 [1] CRAN (R 4.0.5)
#>  proxy          0.4-25  2021-03-05 [1] CRAN (R 4.0.2)
#>  ps             1.6.0   2021-02-28 [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.6   2021-01-15 [1] CRAN (R 4.0.2)
#>  remotes        2.3.0   2021-04-01 [1] CRAN (R 4.0.2)
#>  rlang          0.4.11  2021-04-30 [1] CRAN (R 4.0.5)
#>  rmarkdown      2.7     2021-02-19 [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-8   2021-03-17 [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.2   2021-02-14 [1] CRAN (R 4.0.2)
#>  tibble         3.1.1   2021-04-18 [1] CRAN (R 4.0.2)
#>  tidyselect     1.1.1   2021-04-30 [1] CRAN (R 4.0.5)
#>  units          0.7-1   2021-03-16 [1] CRAN (R 4.0.2)
#>  usethis        2.0.1   2021-02-10 [1] CRAN (R 4.0.2)
#>  utf8           1.2.1   2021-03-12 [1] CRAN (R 4.0.2)
#>  vctrs          0.3.8   2021-04-29 [1] CRAN (R 4.0.2)
#>  withr          2.4.2   2021-04-18 [1] CRAN (R 4.0.2)
#>  xfun           0.22    2021-03-11 [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

@nbanion
Copy link
Author

nbanion commented May 14, 2021

I was out of date. After updating, the example works for me. Thanks for the fix!

@nbanion nbanion closed this as completed May 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants