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

change default url #369

Closed
wants to merge 1 commit into from
Closed

change default url #369

wants to merge 1 commit into from

Conversation

hxd1011
Copy link
Contributor

@hxd1011 hxd1011 commented Nov 26, 2019

the reason to make such change is we can easily build the graphhopper and run it on local. In local, we may not have such path.

For example the default one is localhost:8989/route

without /api/1, making this change will make using local graphhopper much easier

(in fact may people use it on local, otherwise google or osm is better, one big the reason to run graphhopper is it can be deployed in local)

the reason to make such change is we can easily build the graphhopper and run it on local. In local, we may not have such path.

For example the default one is localhost:8989/route

without /api/1, making this change will make using local graphhopper much easier

(in fact may people use it on local, otherwise google or osm is better, one big the reason to run graphhopper is it can be deployed in local)
@Robinlovelace
Copy link
Member

Hi @hxd1011 many thanks for the PR! I aim to test this and merge/feedback later today.

@Robinlovelace
Copy link
Member

Thanks for the change, I can confirm that this works! I've made a slight change to the function based on tests (your version still had issues). See here: #370

@Robinlovelace
Copy link
Member

@hxd1011 can you please test on the latest version? This is the output I get (it works):

remotes::install_github("ropensci/stplanr", "hxd1011-patch-1")
library(stplanr)
example(route_graphhopper, run.dontrun = TRUE)


remotes::install_github("ropensci/stplanr", "hxd1011-patch-1")
#> Skipping install of 'stplanr' from a github remote, the SHA1 (655ec38c) has not changed since last install.
#>   Use `force = TRUE` to force installation
library(stplanr)
example(route_graphhopper, run.dontrun = TRUE)
#> 
#> rt_grp> from <- c(-0.12, 51.5)
#> 
#> rt_grp> to <- c(-0.14, 51.5)
#> 
#> rt_grp> r1 <- route_graphhopper(from = from, to = to, silent = FALSE)
#> [1] "The request sent was: https://graphhopper.com/api/1/route?point=51.5%2C-0.12&point=51.5%2C-0.14&vehicle=bike&locale=en-US&debug=true&points_encoded=false&key=your-api-key"
#> 
#> rt_grp> r2 <- route_graphhopper(from = from, to = to, silent = FALSE, vehicle = "foot")
#> [1] "The request sent was: https://graphhopper.com/api/1/route?point=51.5%2C-0.12&point=51.5%2C-0.14&vehicle=foot&locale=en-US&debug=true&points_encoded=false&key=your-api-key"
#> 
#> rt_grp> r3 <- route_graphhopper(from = from, to = to, silent = FALSE, vehicle = "car")
#> [1] "The request sent was: https://graphhopper.com/api/1/route?point=51.5%2C-0.12&point=51.5%2C-0.14&vehicle=car&locale=en-US&debug=true&points_encoded=false&key=your-api-key"
#> 
#> rt_grp> plot(r1)

#>
#> rt_grp> plot(r2, add = TRUE, col = "blue") # compare routes
#>
#> rt_grp> plot(r3, add = TRUE, col = "red")

Created on 2019-11-28 by the reprex package (v0.3.0)

Session info
devtools::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value                       
#>  version  R version 3.6.1 (2019-07-05)
#>  os       Ubuntu 18.04.3 LTS          
#>  system   x86_64, linux-gnu           
#>  ui       X11                         
#>  language en_GB:en                    
#>  collate  en_GB.UTF-8                 
#>  ctype    en_GB.UTF-8                 
#>  tz       Europe/London               
#>  date     2019-11-28                  
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version    date       lib source                           
#>  assertthat    0.2.1      2019-03-21 [2] CRAN (R 3.6.0)                   
#>  backports     1.1.5      2019-10-02 [1] CRAN (R 3.6.1)                   
#>  callr         3.3.2      2019-09-22 [1] CRAN (R 3.6.1)                   
#>  cli           1.1.0      2019-03-19 [2] CRAN (R 3.5.3)                   
#>  codetools     0.2-16     2018-12-24 [4] CRAN (R 3.5.2)                   
#>  crayon        1.3.4      2017-09-16 [2] standard (@1.3.4)                
#>  curl          4.2        2019-09-24 [1] CRAN (R 3.6.1)                   
#>  desc          1.2.0      2018-05-01 [2] standard (@1.2.0)                
#>  devtools      2.2.1      2019-09-24 [1] CRAN (R 3.6.1)                   
#>  digest        0.6.23     2019-11-23 [1] CRAN (R 3.6.1)                   
#>  dplyr         0.8.3      2019-07-04 [2] CRAN (R 3.6.1)                   
#>  ellipsis      0.3.0      2019-09-20 [1] CRAN (R 3.6.1)                   
#>  evaluate      0.14       2019-05-28 [2] CRAN (R 3.6.0)                   
#>  foreign       0.8-72     2019-08-02 [2] CRAN (R 3.6.1)                   
#>  fs            1.3.1      2019-05-06 [2] CRAN (R 3.6.0)                   
#>  geosphere     1.5-10     2019-05-26 [2] CRAN (R 3.6.0)                   
#>  glue          1.3.1      2019-03-12 [2] CRAN (R 3.5.3)                   
#>  highr         0.8        2019-03-20 [3] CRAN (R 3.5.3)                   
#>  htmltools     0.4.0      2019-10-04 [3] CRAN (R 3.6.1)                   
#>  httr          1.4.1      2019-08-05 [2] CRAN (R 3.6.1)                   
#>  igraph        1.2.4.2    2019-11-27 [1] CRAN (R 3.6.1)                   
#>  jsonlite      1.6        2018-12-07 [2] standard (@1.6)                  
#>  knitr         1.26       2019-11-12 [1] CRAN (R 3.6.1)                   
#>  lattice       0.20-38    2018-11-04 [2] standard (@0.20-38)              
#>  magrittr      1.5        2014-11-22 [2] CRAN (R 3.5.2)                   
#>  maptools      0.9-8      2019-10-05 [1] CRAN (R 3.6.1)                   
#>  memoise       1.1.0      2017-04-21 [3] CRAN (R 3.5.0)                   
#>  mime          0.7        2019-06-11 [1] CRAN (R 3.6.0)                   
#>  openxlsx      4.1.3      2019-11-07 [1] CRAN (R 3.6.1)                   
#>  pillar        1.4.2      2019-06-29 [2] CRAN (R 3.6.0)                   
#>  pkgbuild      1.0.6      2019-10-09 [2] CRAN (R 3.6.1)                   
#>  pkgconfig     2.0.3      2019-09-22 [1] CRAN (R 3.6.1)                   
#>  pkgload       1.0.2      2018-10-29 [3] CRAN (R 3.5.1)                   
#>  prettyunits   1.0.2      2015-07-13 [2] CRAN (R 3.5.3)                   
#>  processx      3.4.1      2019-07-18 [2] CRAN (R 3.6.1)                   
#>  ps            1.3.0      2018-12-21 [2] CRAN (R 3.5.3)                   
#>  purrr         0.3.3      2019-10-18 [1] CRAN (R 3.6.1)                   
#>  R6            2.4.1      2019-11-12 [1] CRAN (R 3.6.1)                   
#>  raster        3.0-7      2019-09-24 [1] CRAN (R 3.6.1)                   
#>  Rcpp          1.0.3      2019-11-08 [1] CRAN (R 3.6.1)                   
#>  remotes       2.1.0      2019-06-24 [1] CRAN (R 3.6.1)                   
#>  rgdal         1.4-8      2019-11-27 [1] CRAN (R 3.6.1)                   
#>  rgeos         0.5-2      2019-10-03 [1] CRAN (R 3.6.1)                   
#>  rlang         0.4.2      2019-11-23 [1] CRAN (R 3.6.1)                   
#>  rmarkdown     1.18       2019-11-27 [1] CRAN (R 3.6.1)                   
#>  rprojroot     1.3-2      2018-01-03 [2] CRAN (R 3.5.3)                   
#>  sessioninfo   1.1.1      2018-11-05 [3] CRAN (R 3.5.1)                   
#>  sp            1.3-2      2019-11-07 [1] CRAN (R 3.6.1)                   
#>  stplanr     * 0.4.1.9000 2019-11-28 [1] Github (ropensci/stplanr@655ec38)
#>  stringi       1.4.3      2019-03-12 [2] CRAN (R 3.5.3)                   
#>  stringr       1.4.0      2019-02-10 [2] standard (@1.4.0)                
#>  testthat      2.3.0      2019-11-05 [2] CRAN (R 3.6.1)                   
#>  tibble        2.1.3      2019-06-06 [2] CRAN (R 3.6.0)                   
#>  tidyselect    0.2.5      2018-10-11 [2] CRAN (R 3.5.3)                   
#>  usethis       1.5.1      2019-07-04 [1] CRAN (R 3.6.1)                   
#>  withr         2.1.2      2018-03-15 [2] CRAN (R 3.5.3)                   
#>  xfun          0.11       2019-11-12 [1] CRAN (R 3.6.1)                   
#>  xml2          1.2.2      2019-08-09 [3] CRAN (R 3.6.1)                   
#>  yaml          2.2.0      2018-07-25 [3] CRAN (R 3.5.1)                   
#>  zip           2.0.4      2019-09-01 [2] CRAN (R 3.6.1)                   
#> 
#> [1] /home/robin/R/x86_64-pc-linux-gnu-library/3.6
#> [2] /usr/local/lib/R/site-library
#> [3] /usr/lib/R/site-library
#> [4] /usr/lib/R/library

@Robinlovelace
Copy link
Member

Confirmed: I got an error on previous version

#> Error in route_graphhopper("London Eye", "Westminster", vehicle = "foot"): Bad Request (HTTP 400).

@Robinlovelace
Copy link
Member

Closing as superceded by #370 which includes this commit. Please test the latest version and report back @hxd1011 .

@hxd1011
Copy link
Contributor Author

hxd1011 commented Nov 28, 2019

Hi, @Robinlovelace

Thank you very much for the work!. I really liked your book Geocomputation with R.

When I wrote this PR, I was in middle of some work and when I go back to my comment, it is really repetitive and has little value. Thanks for the merge and doing all of the work.

@Robinlovelace
Copy link
Member

Many thanks for the contribution @hxd1011. Any further feedback (especially in the form of reproducible issues or PR ; ) will be greatly appreciated. Please confirm that the new implementation works, and let me know of further thoughts (there are other things we could do, including splitting out the route_graphhopper() function into a dedicated small R package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants