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: Return ISO country and state code in geocode() #98

Closed
munterfi opened this issue Dec 21, 2020 · 5 comments · Fixed by #105 or #107
Closed

Bug: Return ISO country and state code in geocode() #98

munterfi opened this issue Dec 21, 2020 · 5 comments · Fixed by #105 or #107
Assignees
Labels
bug Something isn't working

Comments

@munterfi
Copy link
Owner

As mentioned by @kaijagahm in #58, geocode() should return ISO country and state codes in the current version as it did with the previous API v6 (see #52).

@munterfi munterfi added the bug Something isn't working label Dec 21, 2020
@munterfi munterfi self-assigned this Dec 21, 2020
@kaijagahm
Copy link

kaijagahm commented Dec 21, 2020

I think I know how to fix this--take a look at line 143 of geocode.R https://github.com/munterfinger/hereR/blob/master/R/geocode.R.

If you change df$items$address$countryName to df$items$address$countryCode, it works.

Alternatively, you could just have this be an option instead of making the change by default.

I've never made a PR before and frankly don't know how, otherwise I'd suggest this more formally. I figured it out by downloading the code and fiddling around on my own machine.

@munterfi
Copy link
Owner Author

Hi, thanks for the hint.

The country and state codes are now added as separate columns to geocode():

library(hereR)
geocode("São Paulo")
#> Simple feature collection with 1 feature and 15 fields
#> geometry type:  POINT
#> dimension:      XY
#> bbox:           xmin: -46.65468 ymin: -23.56287 xmax: -46.65468 ymax: -23.56287
#> geographic CRS: WGS 84
#>   id rank               address     type street house_number postal_code
#> 1  1    1 São Paulo, SP, Brasil locality   <NA>         <NA>   01310-100
#>   state_code country_code district      city county     state country
#> 1         SP          BRA     <NA> São Paulo   <NA> São Paulo  Brasil
#>        access                    geometry
#> 1 POINT EMPTY POINT (-46.65468 -23.56287)

Please test and let me know if this solves the issue:
remotes::install_github("munterfinger/hereR@develop")

Note: The dev version of hereR needs flexpolyline >= v0.2.0 and updates the ‘Routing’ and ‘Isoline Routing’ APIs to newer versions which will lead to slightly different return values of isoline() and route().

Session info
devtools::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-21                  
#> 
#> ─ 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-21 [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

@kaijagahm
Copy link

Wow, thank you for such a quick response! Yes, that fixes it nicely.

@munterfi
Copy link
Owner Author

Regarding your question about contributing. This repository is missing contribution guidelines (e.g. CONTRIBUTING.md), which I should certainly add in the future.

An example workflow:

  1. Fork the repository to your GitHub account and clone the forked repository locally.
  2. Create a feature or bugfix branch as appropriate: git checkout -b feature/my-new-feature develop
  3. Commit and push changes to this new branch.
  4. Once you are done with the new feature or bugfix, create a pull request on GitHub of your feature/... or bugfix/... branch into the develop (or master/main depending on the repository guidelines) branch of the original repository (not your fork).

@kaijagahm
Copy link

Thanks! I'll try that next time I come across something like this.

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

Successfully merging a pull request may close this issue.

2 participants