Skip to content

Commit

Permalink
Merge pull request #85 from GIScience/feat/export_endpoint
Browse files Browse the repository at this point in the history
Add export endpoint
  • Loading branch information
aoles authored Oct 18, 2024
2 parents 0378e2f + 670ce9a commit 961447d
Show file tree
Hide file tree
Showing 9 changed files with 142 additions and 12 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export(jobs)
export(ors_api_key)
export(ors_directions)
export(ors_elevation)
export(ors_export)
export(ors_geocode)
export(ors_isochrones)
export(ors_matrix)
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# openrouteservice 0.6.0

## NEW FEATURES

- Enable export endpoint.

# openrouteservice 0.5.2

## NEW FEATURES
Expand Down
3 changes: 2 additions & 1 deletion R/api_call.R
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ ors_path <- function(endpoint) {
pois = "pois",
elevation = "elevation",
optimization = "optimization",
snap = "v2/snap"
snap = "v2/snap",
export = "v2/export"
)
if (missing(endpoint))
return(default_paths)
Expand Down
22 changes: 16 additions & 6 deletions R/doc_utils.R
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
doc_url <- function(service) {
url_template <- switch(service,
directions =, isochrones =, matrix =, snap = "https://openrouteservice.org/dev/#/api-docs/v2/%s/{profile}/post",
pois =, optimization = "https://openrouteservice.org/dev/#/api-docs/%s/post",
"https://openrouteservice.org/dev/#/api-docs/%s")
url_template <- switch(
service,
directions = ,
isochrones = ,
matrix = ,
snap = ,
export =
"https://openrouteservice.org/dev/#/api-docs/v2/%s/{profile}/post",
pois = ,
optimization =
"https://openrouteservice.org/dev/#/api-docs/%s/post",
"https://openrouteservice.org/dev/#/api-docs/%s"
)
sprintf(url_template, service)
}

doc_link <- function(service, label=service) sprintf("[%s](%s)", label, doc_url(service))
doc_link <- function(service, label = service)
sprintf("[%s](%s)", label, doc_url(service))

signup_url <- function (label) {
url <- "https://openrouteservice.org/dev/#/signup"
if ( missing(label) )
if (missing(label))
url
else
sprintf("[%s](%s)", label, url)
Expand Down
50 changes: 50 additions & 0 deletions R/export.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#' Openrouteservice Export
#'
#' Export the base graph for different modes of transport.
#'
#' @template param-coordinates
#' @templateVar argname bbox
#' @templateVar suffix defining the SW and NE corners of a rectangular area of interest
#' @template param-profile
#' @template param-common
#' @templateVar dotsargs parameters
#' @templateVar endpoint export
#' @template return
#' @templateVar return Lists of graph nodes and edges contained in the provided bounding box and relevant for the given routing profile. The edge property `weight` represents travel time in seconds. The response is
#' @template return-text
#' @template return-parsed
#' @examples
#' \dontrun{
#' bbox <- list(
#' c(8.681495, 49.41461),
#' c(8.686507, 49.41943)
#' )
#'
#' res <- ors_export(bbox)
#' }
#' @template author
#' @export
ors_export <- function(bbox,
profile = ors_profile(),
...,
api_key = ors_api_key(),
output = c("parsed", "text")) {
## required arguments with no default value
if (missing(bbox))
stop('Missing argument "bbox"')

## required arguments with defaults
profile <- match.arg(profile)
output <- match.arg(output)

## request parameters
body <- list(bbox = bbox, ...)

api_call(
path = c("v2/export", profile),
api_key = api_key,
body = body,
encode = "json",
output = output
)
}
2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ The default is to fire any requests against the free public services at
instance, say a local one, set

```{r openrouteservice.url, eval=FALSE}
options(openrouteservice.url = "http://localhost:8080/ors")
options(openrouteservice.url = "http://localhost:8082/ors")
```

If necessary, endpoint configuration can be further customized through
Expand Down
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ allows you to painlessly consume the following services:
- time-distance
[matrices](https://openrouteservice.org/dev/#/api-docs/v2/matrix/%7Bprofile%7D/post)
- [snapping](https://openrouteservice.org/dev/#/api-docs/v2/snap/%7Bprofile%7D/post)
to ways
to OpenStreetMap ways
- [exporting](https://openrouteservice.org/dev/#/api-docs/v2/export/%7Bprofile%7D/post)
the underlying routing graph structure
- [pois](https://openrouteservice.org/dev/#/api-docs/pois/post)
(points of interest)
- SRTM
Expand Down Expand Up @@ -70,7 +72,7 @@ The default is to fire any requests against the free public services at
&lt;api.openrouteservice.org&gt;. In order to query a different
openrouteservice instance, say a local one, set

options(openrouteservice.url = "http://localhost:8080/ors")
options(openrouteservice.url = "http://localhost:8082/ors")

If necessary, endpoint configuration can be further customized through
`openrouteservice.paths` which specifies a named list of paths. The
Expand All @@ -83,10 +85,17 @@ defaults are equivalent of having
pois = "pois",
elevation = "elevation",
optimization = "optimization",
snap = "v2/snap"))
snap = "v2/snap",
export = "v2/export"))

## Recent package news

### version 0.6.0

#### NEW FEATURES

- Enable export endpoint.

### version 0.5.2

#### NEW FEATURES
Expand Down
52 changes: 52 additions & 0 deletions man/ors_export.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion vignettes/openrouteservice.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ to painlessly consume the following services:
- `r doc('geocode', label='geocoding')` powered by [Pelias](https://pelias.io)
- `r doc('isochrones')` (accessibility)
- time-distance `r doc('matrix', label='matrices')`
- `r doc('snap', label='snapping')` to ways
- `r doc('snap', label='snapping')` to OpenStreetMap ways
- `r doc('export', label='exporting')` the underlying routing graph structure
- `r doc('pois')` (points of interest)
- SRTM `r doc('elevation')` for point and lines geometries
- routing `r doc('optimization')` based on [Vroom](http://vroom-project.org/)
Expand Down

0 comments on commit 961447d

Please sign in to comment.