diff --git a/.Rbuildignore b/.Rbuildignore index 93589e0..571e6cd 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -2,6 +2,7 @@ ^\.Rproj\.user$ ^man-roxygen$ ^README\.Rmd$ +^references.*$ ^Makefile$ ^pkgdown$ ^docs$ diff --git a/.github/workflows/rhub.yaml b/.github/workflows/rhub.yaml new file mode 100644 index 0000000..693aaaf --- /dev/null +++ b/.github/workflows/rhub.yaml @@ -0,0 +1,98 @@ +# R-hub's generic GitHub Actions workflow file. It's canonical location is at +# https://github.com/r-hub/actions/blob/v1/workflows/rhub.yaml +# You can update this file to a newer version using the rhub2 package: +# +# rhub::rhub_setup() +# +# It is unlikely that you need to modify this file manually. + +name: R-hub +run-name: "${{ github.event.inputs.id }}: ${{ github.event.inputs.name || format('Manually run by {0}', github.triggering_actor) }}" + +on: + workflow_dispatch: + inputs: + config: + description: 'A comma separated list of R-hub platforms to use.' + type: string + default: 'linux,windows,macos' + name: + description: 'Run name. You can leave this empty now.' + type: string + id: + description: 'Unique ID. You can leave this empty now.' + type: string + +jobs: + + setup: + runs-on: ubuntu-latest + outputs: + containers: ${{ steps.rhub-setup.outputs.containers }} + platforms: ${{ steps.rhub-setup.outputs.platforms }} + + steps: + # NO NEED TO CHECKOUT HERE + - uses: r-hub/actions/setup@v1 + with: + config: ${{ github.event.inputs.config }} + id: rhub-setup + + linux-containers: + needs: setup + if: ${{ needs.setup.outputs.containers != '[]' }} + runs-on: ubuntu-latest + name: ${{ matrix.config.label }} + strategy: + fail-fast: false + matrix: + config: ${{ fromJson(needs.setup.outputs.containers) }} + container: + image: ${{ matrix.config.container }} + + steps: + - uses: r-hub/actions/checkout@v1 + - uses: r-hub/actions/platform-info@v1 + with: + token: ${{ secrets.RHUB_TOKEN }} + job-config: ${{ matrix.config.job-config }} + - uses: r-hub/actions/setup-deps@v1 + with: + token: ${{ secrets.RHUB_TOKEN }} + job-config: ${{ matrix.config.job-config }} + - uses: r-hub/actions/run-check@v1 + with: + token: ${{ secrets.RHUB_TOKEN }} + job-config: ${{ matrix.config.job-config }} + + other-platforms: + needs: setup + if: ${{ needs.setup.outputs.platforms != '[]' }} + runs-on: ${{ matrix.config.os }} + name: ${{ matrix.config.label }} + strategy: + fail-fast: false + matrix: + config: ${{ fromJson(needs.setup.outputs.platforms) }} + + env: + ORS_API_KEY: ${{ secrets.ORS_API_KEY }} + + steps: + - uses: r-hub/actions/checkout@v1 + - uses: r-hub/actions/setup-r@v1 + with: + job-config: ${{ matrix.config.job-config }} + token: ${{ secrets.RHUB_TOKEN }} + - uses: r-hub/actions/platform-info@v1 + with: + token: ${{ secrets.RHUB_TOKEN }} + job-config: ${{ matrix.config.job-config }} + - uses: r-hub/actions/setup-deps@v1 + with: + job-config: ${{ matrix.config.job-config }} + token: ${{ secrets.RHUB_TOKEN }} + - uses: r-hub/actions/run-check@v1 + with: + job-config: ${{ matrix.config.job-config }} + token: ${{ secrets.RHUB_TOKEN }} diff --git a/DESCRIPTION b/DESCRIPTION index 64f3f35..83a7548 100755 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,16 +1,18 @@ Package: openrouteservice -Title: Openrouteservice API Client -Version: 0.6.0 -Authors@R: person("Andrzej", "Oleś", email = "andrzej.oles@gmail.com", comment = c(ORCID = "0000-0003-0285-2787"), role = c("aut", "cre")) -Description: The package streamlines access to the services provided by openrouteservice.org. - It allows you to painlessly query for directions, geocoding, isochrones, time-distance matrices, and POIs. +Title: An 'openrouteservice' API Client +Version: 0.5.3 +Authors@R: c( + person("Heidelberg Institute for Geoinformation Technology (HeiGIT) gGmbH", role = "cph"), + person(c("Andrzej", "K."), "Oleś", email = "andrzej.oles@gmail.com", role = c("aut", "cre"), comment = c(ORCID = "0000-0003-0285-2787")) + ) +Description: The client streamlines access to the services provided by . + It allows you to painlessly query for directions, isochrones, time-distance matrices, geocoding, elevation, points of interest, and more. URL: https://github.com/GIScience/openrouteservice-r BugReports: https://github.com/GIScience/openrouteservice-r/issues Imports: geojsonsf, httr, jsonlite, jsonvalidate, keyring, leaflet, utils, V8, xml2 Suggests: covr, ggplot2, googlePolylines, lwgeom, knitr, mapview, pkgdown, RColorBrewer, rmarkdown, roxygen2, sf, testthat, units -License: Apache License 2.0 | file LICENSE +License: Apache License 2.0 Encoding: UTF-8 -LazyData: true VignetteBuilder: knitr Roxygen: list(markdown = TRUE) RoxygenNote: 7.3.2 diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 261eeb9..0000000 --- a/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/Makefile b/Makefile index 235e5db..67cc9d2 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,9 @@ RSCRIPT = Rscript --vanilla %.md: %.Rmd ${RSCRIPT} -e 'rmarkdown::render("$<")' -README.md: vignettes/${PKGNAME}.Rmd NEWS.md +README.md: vignettes/${PKGNAME}.Rmd NEWS.md references.md + +references.md: references.bib readme: README.md diff --git a/R/api_call.R b/R/api_call.R index 603a13f..f75e1a4 100755 --- a/R/api_call.R +++ b/R/api_call.R @@ -293,6 +293,10 @@ print.ors_api <- function(x, give.attr = FALSE, list.len = 6L, ...) { invisible(x) } +validator <- new.env() + #' @importFrom jsonvalidate json_validator #' @importFrom V8 v8 -validate_geojson <- NULL +validate_geojson <- function(...) { + validator$instance(...) +} diff --git a/R/directions.R b/R/directions.R index 8ce13e0..d6c596d 100755 --- a/R/directions.R +++ b/R/directions.R @@ -16,7 +16,7 @@ #' @template return-parsed #' @template return-sf #' @examples -#' coordinates <- list(c(8.34234, 48.23424), c(8.34423, 48.26424)) +#' \donttest{coordinates <- list(c(8.34234, 48.23424), c(8.34423, 48.26424)) #' #' # simple call #' ors_directions(coordinates, preference="fastest") @@ -27,7 +27,7 @@ #' # list of locations as `data.frame` output as simple features `sf` object #' locations <- data.frame(lng = c(8.34234, 8.327807, 8.34423), #' lat = c(48.23424, 48.239368, 48.26424)) -#' ors_directions(locations, output = "sf") +#' ors_directions(locations, output = "sf")} #' @template author #' @export ors_directions <- function(coordinates, diff --git a/R/elevation.R b/R/elevation.R index 4b69621..45e49c6 100644 --- a/R/elevation.R +++ b/R/elevation.R @@ -17,7 +17,7 @@ #' @template return-parsed #' @template return-sf #' @examples -#' # point coordinates +#' \donttest{# point coordinates #' coordinates <- c(13.349762, 38.11295) #' ors_elevation("point", coordinates) #' @@ -30,7 +30,7 @@ #' c(13.349762, 38.11295), #' c(12.638397, 37.645772) #' ) -#' ors_elevation("polyline", coordinates, format_out = "encodedpolyline") +#' ors_elevation("polyline", coordinates, format_out = "encodedpolyline")} #' @template author #' @importFrom httr add_headers #' @export diff --git a/R/geocode.R b/R/geocode.R index 2116cdf..c3f8749 100755 --- a/R/geocode.R +++ b/R/geocode.R @@ -19,7 +19,7 @@ #' tag which surrounds the given coordinate. #' @template author #' @examples -#' ## locations of Heidelberg around the globe +#' \donttest{## locations of Heidelberg around the globe #' x <- ors_geocode("Heidelberg") #' #' ## set the number of results returned @@ -33,7 +33,7 @@ #' #' ## reverse geocoding #' location <- x$features[[1L]]$geometry$coordinates -#' y <- ors_geocode(location = location, layers = "locality", size = 1) +#' y <- ors_geocode(location = location, layers = "locality", size = 1)} #' @export ors_geocode <- function(query, location, diff --git a/R/isochrones.R b/R/isochrones.R index 74d18e2..0ffa136 100755 --- a/R/isochrones.R +++ b/R/isochrones.R @@ -22,10 +22,10 @@ #' @template return-parsed #' @template return-sf #' @examples -#' ors_isochrones(c(8.34234, 48.23424), interval=20) +#' \donttest{ors_isochrones(c(8.34234, 48.23424), interval=20) #' #' locations <- list(c(8.681495, 49.41461), c(8.686507,49.41943)) -#' ors_isochrones(locations, range=c(300, 200)) +#' ors_isochrones(locations, range=c(300, 200))} #' @template author #' @export ors_isochrones <- function(locations, diff --git a/R/matrix.R b/R/matrix.R index d42df90..c4b5cd0 100755 --- a/R/matrix.R +++ b/R/matrix.R @@ -15,7 +15,7 @@ #' @template return-text #' @template return-parsed #' @examples -#' coordinates <- list( +#' \donttest{coordinates <- list( #' c(9.970093, 48.477473), #' c(9.207916, 49.153868), #' c(37.573242, 55.801281), @@ -29,7 +29,7 @@ #' res$durations / 3600 #' #' # distance in km -#' res$distances +#' res$distances} #' @template author #' @export ors_matrix <- function(locations, diff --git a/R/optimization.R b/R/optimization.R index 9011b6f..6c9a015 100644 --- a/R/optimization.R +++ b/R/optimization.R @@ -16,7 +16,7 @@ #' @template return-text #' @template return-parsed #' @examples -#' home_base <- c(2.35044, 48.71764) +#' \donttest{home_base <- c(2.35044, 48.71764) #' #' vehicles <- vehicles( #' id = 1:2, @@ -45,7 +45,7 @@ #' skills = list(1, 1, 2, 2, 14, 14) #' ) #' -#' ors_optimization(jobs, vehicles) +#' ors_optimization(jobs, vehicles)} #' @template author #' @export ors_optimization <- function(jobs, diff --git a/R/pois.R b/R/pois.R index 6bceef9..7b71c22 100755 --- a/R/pois.R +++ b/R/pois.R @@ -24,7 +24,7 @@ #' @template return-sf #' @templateVar valid_for `request = "pois"` #' @examples -#' # POI categories list +#' \donttest{# POI categories list #' ors_pois('list') #' #' # POIs around a buffered point @@ -54,7 +54,7 @@ #' )) #' #' # POI Statistics -#' ors_pois("stats", geometry = geometry) +#' ors_pois("stats", geometry = geometry)} #' @template author #' @export ors_pois <- function(request = c('pois', 'stats', 'list'), diff --git a/R/snap.R b/R/snap.R index 1d0d3b7..4bead00 100644 --- a/R/snap.R +++ b/R/snap.R @@ -16,14 +16,14 @@ #' @template return-parsed #' @template return-sf #' @examples -#' locations <- list( +#' \donttest{locations <- list( #' c(8.669629, 49.413025), #' c(8.675841, 49.418532), #' c(8.665144, 49.415594) #' ) #' #' # query for locations snapped onto the OpenStreetMap road network -#' res <- ors_snap(locations, radius = 350) +#' res <- ors_snap(locations, radius = 350)} #' @template author #' @export ors_snap <- function(locations, @@ -55,5 +55,4 @@ ors_snap <- function(locations, body = body, encode = "json", output = output - ) -} + )} diff --git a/R/zzz.R b/R/zzz.R index 8adb4d7..a66a815 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -1,3 +1,3 @@ .onLoad <- function(lib, pkg) { - validate_geojson <<- jsonvalidate::json_validator(system.file("schema/geojson.json", package = pkg)) + validator$instance <- jsonvalidate::json_validator(system.file("schema/geojson.json", package = pkg)) } diff --git a/README.Rmd b/README.Rmd index 001bc79..16957a3 100644 --- a/README.Rmd +++ b/README.Rmd @@ -1,9 +1,17 @@ --- output: rmarkdown::md_document --- + + + + [![R-CMD-check](https://github.com/GIScience/openrouteservice-r/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/GIScience/openrouteservice-r/actions/workflows/R-CMD-check.yaml) [![Coverage Status](https://img.shields.io/codecov/c/github/GIScience/openrouteservice-r/master.svg)](https://app.codecov.io/github/GIScience/openrouteservice-r?branch=master) -[![lifecycle](https://lifecycle.r-lib.org/articles/figures/lifecycle-experimental.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental) +[![lifecycle](https://lifecycle.r-lib.org/articles/figures/lifecycle-stable.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable) +[![CRAN checks](https://badges.cranchecks.info/summary/openrouteservice.svg)](https://cran.r-project.org/web/checks/check_results_openrouteservice.html) +[![CRAN release](https://www.r-pkg.org/badges/version-ago/openrouteservice)](https://cran.r-project.org/package=openrouteservice) +[![CRAN downloads](http://cranlogs.r-pkg.org/badges/grand-total/openrouteservice)](http://cranlogs.r-pkg.org/badges/grand-total/openrouteservice) + # openrouteservice R client @@ -44,7 +52,7 @@ cat(sprintf(opts_str, paste0(ors_paths, collapse = paste(",", indent, sep="\n")) options(openrouteservice.path = list(directions = "v2/directions")) ``` -## Package News +## Recent package news ```{r news, echo = FALSE, results = 'asis'} lines = readLines("NEWS.md") @@ -58,3 +66,15 @@ news = lines[from:to] news = gsub("^(#+)(.*)", "##\\1\\2", news) cat(paste(news, collapse = "\n")) ``` + +## Publications using openrouteservice R package + +Please feel free to reach out if you would like to have your work added to the list below. + +```{r references, echo = FALSE, results = 'asis'} +lines = readLines("references.md") +lines = gsub('^', '', lines) +lines = gsub('^', '', lines) +lines = gsub(' $', '', lines) +cat(paste(lines, collapse = "\n")) +``` diff --git a/README.md b/README.md index 00576f3..e156395 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,17 @@ + + + [![R-CMD-check](https://github.com/GIScience/openrouteservice-r/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/GIScience/openrouteservice-r/actions/workflows/R-CMD-check.yaml) [![Coverage Status](https://img.shields.io/codecov/c/github/GIScience/openrouteservice-r/master.svg)](https://app.codecov.io/github/GIScience/openrouteservice-r?branch=master) -[![lifecycle](https://lifecycle.r-lib.org/articles/figures/lifecycle-experimental.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental) +[![lifecycle](https://lifecycle.r-lib.org/articles/figures/lifecycle-stable.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable) +[![CRAN +checks](https://badges.cranchecks.info/summary/openrouteservice.svg)](https://cran.r-project.org/web/checks/check_results_openrouteservice.html) +[![CRAN +release](https://www.r-pkg.org/badges/version-ago/openrouteservice)](https://cran.r-project.org/package=openrouteservice) +[![CRAN +downloads](http://cranlogs.r-pkg.org/badges/grand-total/openrouteservice)](http://cranlogs.r-pkg.org/badges/grand-total/openrouteservice) + # openrouteservice R client @@ -37,8 +47,15 @@ conditions](https://openrouteservice.org/terms-of-service/). ## Installation -The package is not yet available from CRAN, but you can install the -development version directly from GitHub. +The latest release version can be readily obtained from CRAN via a call +to + + install.packages("openrouteservice") + +For running the current development version from GitHub it is +recommended to use [pak](https://CRAN.R-project.org/package=pak), as it +handles the installation of all the necessary packages and their system +dependencies automatically. # install.packages("pak") pak::pak("GIScience/openrouteservice-r") @@ -71,7 +88,7 @@ defaults are equivalent of having snap = "v2/snap", export = "v2/export")) -## Package News +## Recent package news ### version 0.6.0 @@ -90,3 +107,61 @@ defaults are equivalent of having #### BUG FIXES - sf output for POIs endpoint (#81) + +### version 0.5.0 + +#### NEW FEATURES + +- Enable snap endpoint. + +## Publications using openrouteservice R package + +Please feel free to reach out if you would like to have your work added +to the list below. + +1. Baumer BS, Kaplan DT, Horton NJ. Modern data science with r. + Chapman; Hall/CRC; 2017. + +2. Cervigni E, Renton M, McKenzie FH, Hickling S, Olaru D. Describing + and mapping diversity and accessibility of the urban food + environment with open data and tools. Applied Geography. + 2020;125:102352. + +3. Petricola S, Reinmuth M, Lautenbach S, Hatfield C, Zipf A. Assessing + road criticality and loss of healthcare accessibility during floods: + The case of cyclone idai, mozambique 2019. International journal of + health geographics. 2022;21(1):14. + +4. Weenink P. Overcoming the modifiable areal unit problem (MAUP) of + socio-economic variables in real estate modelling + *P**h**D**t**h**e**s**i**s* + . 2022. + +5. Shields N, Willis C, Imms C, McKenzie G, Van Dorsselaer B, Bruder + AM, et al. Feasibility of scaling-up a community-based exercise + program for young people with disability. Disability and + Rehabilitation. 2022;44(9):1669–81. + +6. Veloso R, Cespedes J, Caunhye A, Alem D. Brazilian disaster datasets + and real-world instances for optimization and machine learning. Data + in brief. 2022;42:108012. + +7. Cubells J, Miralles-Guasch C, Marquet O. E-scooter and bike-share + route choice and detours: Modelling the influence of built + environment and sociodemographic factors. Journal of transport + geography. 2023;111:103664. + +8. Bhowon Y, Prendergast LA, Taylor NF, Shields N. Using geospatial + analysis to determine the proximity of community gyms for a + population-based cohort of young people with cerebral palsy. + Physiotherapy Canada. 2023;e20220064. + +9. Amato S, Benson JS, Stewart B, Sarathy A, Osler T, Hosmer D, et + al. Current patterns of trauma center proliferation have not led to + proportionate improvements in access to care or mortality after + injury: An ecologic study. Journal of Trauma and Acute Care Surgery. + 2023;94(6):755–64. + +10. Jain A, LaValley M, Dukes K, Lane K, Winter M, Spangler KR, et + al. Modeling health and well-being measures using ZIP code spatial + neighborhood patterns. Scientific Reports. 2024;14(1):9180. diff --git a/man/ors_directions.Rd b/man/ors_directions.Rd index 0c178c1..fa54967 100755 --- a/man/ors_directions.Rd +++ b/man/ors_directions.Rd @@ -45,7 +45,7 @@ Route between two or more locations in the selected \code{format} structured acc Get directions for different modes of transport. } \examples{ -coordinates <- list(c(8.34234, 48.23424), c(8.34423, 48.26424)) +\donttest{coordinates <- list(c(8.34234, 48.23424), c(8.34423, 48.26424)) # simple call ors_directions(coordinates, preference="fastest") @@ -56,7 +56,7 @@ ors_directions(coordinates, profile="cycling-mountain", elevation=TRUE) # list of locations as `data.frame` output as simple features `sf` object locations <- data.frame(lng = c(8.34234, 8.327807, 8.34423), lat = c(48.23424, 48.239368, 48.26424)) -ors_directions(locations, output = "sf") +ors_directions(locations, output = "sf")} } \author{ Andrzej Oleś \href{mailto:andrzej.oles@gmail.com}{andrzej.oles@gmail.com} diff --git a/man/ors_elevation.Rd b/man/ors_elevation.Rd index 4a26dc6..82a32b1 100644 --- a/man/ors_elevation.Rd +++ b/man/ors_elevation.Rd @@ -49,7 +49,7 @@ A GeoJSON based service to query SRTM elevation for Point or LineString 2D geometries and return 3D geometries in various formats. } \examples{ -# point coordinates +\donttest{# point coordinates coordinates <- c(13.349762, 38.11295) ors_elevation("point", coordinates) @@ -62,7 +62,7 @@ coordinates <- list( c(13.349762, 38.11295), c(12.638397, 37.645772) ) -ors_elevation("polyline", coordinates, format_out = "encodedpolyline") +ors_elevation("polyline", coordinates, format_out = "encodedpolyline")} } \author{ Andrzej Oleś \href{mailto:andrzej.oles@gmail.com}{andrzej.oles@gmail.com} diff --git a/man/ors_geocode.Rd b/man/ors_geocode.Rd index d8872d3..21cc7c2 100755 --- a/man/ors_geocode.Rd +++ b/man/ors_geocode.Rd @@ -39,7 +39,7 @@ to be specified for a valid request. If both parameters are specified location takes precedence. } \examples{ -## locations of Heidelberg around the globe +\donttest{## locations of Heidelberg around the globe x <- ors_geocode("Heidelberg") ## set the number of results returned @@ -53,7 +53,7 @@ x <- ors_geocode(list(locality="Heidelberg", county="Heidelberg")) ## reverse geocoding location <- x$features[[1L]]$geometry$coordinates -y <- ors_geocode(location = location, layers = "locality", size = 1) +y <- ors_geocode(location = location, layers = "locality", size = 1)} } \author{ Andrzej Oleś \href{mailto:andrzej.oles@gmail.com}{andrzej.oles@gmail.com} diff --git a/man/ors_isochrones.Rd b/man/ors_isochrones.Rd index 5f37068..0386e50 100755 --- a/man/ors_isochrones.Rd +++ b/man/ors_isochrones.Rd @@ -52,10 +52,10 @@ multiple locations. You may also specify the isochrone interval or provide multiple exact isochrone range values. } \examples{ -ors_isochrones(c(8.34234, 48.23424), interval=20) +\donttest{ors_isochrones(c(8.34234, 48.23424), interval=20) locations <- list(c(8.681495, 49.41461), c(8.686507,49.41943)) -ors_isochrones(locations, range=c(300, 200)) +ors_isochrones(locations, range=c(300, 200))} } \author{ Andrzej Oleś \href{mailto:andrzej.oles@gmail.com}{andrzej.oles@gmail.com} diff --git a/man/ors_matrix.Rd b/man/ors_matrix.Rd index 145c804..007fc82 100755 --- a/man/ors_matrix.Rd +++ b/man/ors_matrix.Rd @@ -39,7 +39,7 @@ Obtain one-to-many, many-to-one and many-to-many matrices for time and distance. } \examples{ -coordinates <- list( +\donttest{coordinates <- list( c(9.970093, 48.477473), c(9.207916, 49.153868), c(37.573242, 55.801281), @@ -53,7 +53,7 @@ res <- ors_matrix(coordinates, metrics = c("duration", "distance"), units = "km" res$durations / 3600 # distance in km -res$distances +res$distances} } \author{ Andrzej Oleś \href{mailto:andrzej.oles@gmail.com}{andrzej.oles@gmail.com} diff --git a/man/ors_optimization.Rd b/man/ors_optimization.Rd index 000c2c6..80d5504 100644 --- a/man/ors_optimization.Rd +++ b/man/ors_optimization.Rd @@ -105,7 +105,7 @@ The helper functions \code{jobs()} and \code{vehicles()} create data.frames which can be used as arguments to \code{ors_optimization()}. } \examples{ -home_base <- c(2.35044, 48.71764) +\donttest{home_base <- c(2.35044, 48.71764) vehicles <- vehicles( id = 1:2, @@ -134,7 +134,7 @@ jobs <- jobs( skills = list(1, 1, 2, 2, 14, 14) ) -ors_optimization(jobs, vehicles) +ors_optimization(jobs, vehicles)} } \author{ Andrzej Oleś \href{mailto:andrzej.oles@gmail.com}{andrzej.oles@gmail.com} diff --git a/man/ors_pois.Rd b/man/ors_pois.Rd index 75edff7..a0b1761 100755 --- a/man/ors_pois.Rd +++ b/man/ors_pois.Rd @@ -54,7 +54,7 @@ with the absolute numbers of POIs of a certain group. \code{list} returns a list of category groups and their ids. } \examples{ -# POI categories list +\donttest{# POI categories list ors_pois('list') # POIs around a buffered point @@ -84,7 +84,7 @@ ors_pois(geometry = geometry, )) # POI Statistics -ors_pois("stats", geometry = geometry) +ors_pois("stats", geometry = geometry)} } \author{ Andrzej Oleś \href{mailto:andrzej.oles@gmail.com}{andrzej.oles@gmail.com} diff --git a/man/ors_snap.Rd b/man/ors_snap.Rd index 14c5329..eccee52 100644 --- a/man/ors_snap.Rd +++ b/man/ors_snap.Rd @@ -48,14 +48,14 @@ Coordinates of snapped location(s) and distance to the original point(s) structu Snap coordinates to road network } \examples{ -locations <- list( +\donttest{locations <- list( c(8.669629, 49.413025), c(8.675841, 49.418532), c(8.665144, 49.415594) ) # query for locations snapped onto the OpenStreetMap road network -res <- ors_snap(locations, radius = 350) +res <- ors_snap(locations, radius = 350)} } \author{ Andrzej Oleś \href{mailto:andrzej.oles@gmail.com}{andrzej.oles@gmail.com} diff --git a/references.Rmd b/references.Rmd new file mode 100644 index 0000000..9911a42 --- /dev/null +++ b/references.Rmd @@ -0,0 +1,6 @@ +--- +output: rmarkdown::md_document +bibliography: references.bib +csl: references.csl +nocite: '@*' +--- diff --git a/references.bib b/references.bib new file mode 100644 index 0000000..ac19ed4 --- /dev/null +++ b/references.bib @@ -0,0 +1,95 @@ +@book{baumer2017modern, + title={Modern data science with R}, + author={Baumer, Benjamin S and Kaplan, Daniel T and Horton, Nicholas J}, + year={2017}, + publisher={Chapman and Hall/CRC} +} + +@article{cervigni2020describing, + title={Describing and mapping diversity and accessibility of the urban food environment with open data and tools}, + author={Cervigni, Eleanor and Renton, Michael and McKenzie, Fiona Haslam and Hickling, Siobhan and Olaru, Doina}, + journal={Applied Geography}, + volume={125}, + pages={102352}, + year={2020}, + publisher={Elsevier} +} + +@article{petricola2022assessing, + title={Assessing road criticality and loss of healthcare accessibility during floods: the case of Cyclone Idai, Mozambique 2019}, + author={Petricola, Sami and Reinmuth, Marcel and Lautenbach, Sven and Hatfield, Charles and Zipf, Alexander}, + journal={International journal of health geographics}, + volume={21}, + number={1}, + pages={14}, + year={2022}, + publisher={Springer} +} + +@phdthesis{weenink2022overcoming, + title={Overcoming the Modifiable Areal Unit Problem (MAUP) of socio-economic variables in real estate modelling}, + author={Weenink, Philibert}, + year={2022} +} + +@article{shields2022feasibility, + title={Feasibility of scaling-up a community-based exercise program for young people with disability}, + author={Shields, Nora and Willis, Claire and Imms, Christine and McKenzie, Georgia and Van Dorsselaer, Ben and Bruder, Andrea M and Kennedy, Rachel A and Bhowon, Yeshna and Southby, Alesha and Prendergast, Luke A and others}, + journal={Disability and Rehabilitation}, + volume={44}, + number={9}, + pages={1669--1681}, + year={2022}, + publisher={Taylor \& Francis} +} + +@article{veloso2022brazilian, + title={Brazilian disaster datasets and real-world instances for optimization and machine learning}, + author={Veloso, Rafaela and Cespedes, Juliana and Caunhye, Aakil and Alem, Douglas}, + journal={Data in brief}, + volume={42}, + pages={108012}, + year={2022}, + publisher={Elsevier} +} + +@article{cubells2023scooter, + title={E-scooter and bike-share route choice and detours: modelling the influence of built environment and sociodemographic factors}, + author={Cubells, Jer{\`o}nia and Miralles-Guasch, Carme and Marquet, Oriol}, + journal={Journal of transport geography}, + volume={111}, + pages={103664}, + year={2023}, + publisher={Elsevier} +} + +@article{bhowon2023using, + title={Using Geospatial Analysis to Determine the Proximity of Community Gyms for a Population-based Cohort of Young People with Cerebral Palsy}, + author={Bhowon, Yeshna and Prendergast, Luke A and Taylor, Nicholas F and Shields, Nora}, + journal={Physiotherapy Canada}, + pages={e20220064}, + year={2023}, + publisher={University of Toronto Press} +} + +@article{amato2023current, + title={Current patterns of trauma center proliferation have not led to proportionate improvements in access to care or mortality after injury: An ecologic study}, + author={Amato, Stas and Benson, Jamie S and Stewart, Barclay and Sarathy, Ashwini and Osler, Turner and Hosmer, David and An, Gary and Cook, Alan and Winchell, Robert J and Malhotra, Ajai K}, + journal={Journal of Trauma and Acute Care Surgery}, + volume={94}, + number={6}, + pages={755--764}, + year={2023}, + publisher={LWW} +} + +@article{jain2024modeling, + title={Modeling health and well-being measures using ZIP code spatial neighborhood patterns}, + author={Jain, Abhi and LaValley, Michael and Dukes, Kimberly and Lane, Kevin and Winter, Michael and Spangler, Keith R and Cesare, Nina and Wang, Biqi and Rickles, Michael and Mohammed, Shariq}, + journal={Scientific Reports}, + volume={14}, + number={1}, + pages={9180}, + year={2024}, + publisher={Nature Publishing Group UK London} +} diff --git a/references.csl b/references.csl new file mode 100644 index 0000000..8a3a148 --- /dev/null +++ b/references.csl @@ -0,0 +1,351 @@ + + diff --git a/tests/testthat/test-api_key.R b/tests/testthat/test-api_key.R index 556b7c0..9e0a754 100644 --- a/tests/testthat/test-api_key.R +++ b/tests/testthat/test-api_key.R @@ -13,18 +13,15 @@ on.exit({ Sys.unsetenv("ORS_API_KEY") api_key_val <- "key_stored_in_keyring" -skip_on_linux <- function() { - if (on_os("linux")) skip("Linux") - invisible(TRUE) -} - test_that("Set key in keyring", { - skip_on_linux() + skip_on_cran() + skip_on_os("linux") expect_silent(ors_api_key(api_key_val)) }) test_that("Get key from keyring", { - skip_on_linux() + skip_on_cran() + skip_on_os("linux") expect_identical(ors_api_key(), api_key_val) }) diff --git a/vignettes/openrouteservice.Rmd b/vignettes/openrouteservice.Rmd index bcc035c..7a591a5 100755 --- a/vignettes/openrouteservice.Rmd +++ b/vignettes/openrouteservice.Rmd @@ -14,15 +14,17 @@ vignette: > ```{r config, include=FALSE} ## increase width for code output -options(width = 100) +.options_old <- options(width = 100) ## set up knitr defaults -knitr::opts_chunk$set(eval = TRUE, out.width = '100%', out.height = '560px') +NOT_CRAN <- identical(tolower(Sys.getenv("NOT_CRAN")), "true") +knitr::opts_chunk$set(purl = NOT_CRAN, eval = NOT_CRAN, + out.width = '100%', out.height = '560px') ``` ## Get started -```{r doc, include=FALSE} +```{r doc, include=FALSE, eval=TRUE} ## create alias doc <- openrouteservice:::doc_link ``` @@ -48,8 +50,15 @@ conditions](https://openrouteservice.org/terms-of-service/). ### Installation -The package is not yet available from CRAN, but you can install the -development version directly from GitHub. +The latest release version can be readily obtained from CRAN via a call to + +```{r cran, eval=FALSE} +install.packages("openrouteservice") +``` + +For running the current development version from GitHub it is recommended to use +[pak](https://CRAN.R-project.org/package=pak), as it handles the installation of +all the necessary packages and their system dependencies automatically. ```{r installation, eval=FALSE} # install.packages("pak") @@ -85,7 +94,7 @@ former approach allowing to bypass the keyring infrastructure. `ors_directions()` interfaces the ORS directions service to compute routes between given `coordinates`. -```{r directions, eval=TRUE} +```{r directions} library(openrouteservice) coordinates <- list(c(8.34234, 48.23424), c(8.34423, 48.26424)) @@ -527,4 +536,9 @@ leaflet() %>% addAwesomeMarkers(data = home_base, icon = awesomeIcons("home")) %>% addRoutes(routes, c("purple", "green")) ``` - + + +```{r cleanup, include=FALSE} +## restore user's options +options(.options_old) +```