Skip to content

Commit

Permalink
fix: error when using sf output for pois (closes #81)
Browse files Browse the repository at this point in the history
  • Loading branch information
aoles committed Sep 18, 2024
1 parent d33e1ca commit 735390c
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 22 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: openrouteservice
Title: Openrouteservice API Client
Version: 0.5.0
Version: 0.5.1
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.
Expand All @@ -13,4 +13,4 @@ Encoding: UTF-8
LazyData: true
VignetteBuilder: knitr
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# openrouteservice 0.5.1

## BUG FIXES

- sf output for POIs endpoint (#81)

# openrouteservice 0.5.0

## NEW FEATURES
Expand Down
18 changes: 17 additions & 1 deletion R/api_call.R
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ parse_content <- function (content,
if (output=="sf" && is_geojson) {
res <- tryCatch(geojson_sf(content), error = function(e) stop(e$message,": ", content, call. = FALSE))

if (endpoint!="geocode") {
if (endpoint=="directions") {
## convert parsed properties to sf compatible data.frame
properties <- lapply(parseJSON(content)$features, function(feature) {
prop_list <- lapply(feature[['properties']],
Expand All @@ -248,6 +248,22 @@ parse_content <- function (content,

res[names(properties)] <- properties
}
else if (endpoint!="geocode") {
for (i in 1:length(res)) {
# attempt to parse JSON strings to R objects
if (is.character(res[[i]])) {
res[[i]] <- lapply(res[[i]], function(x) {
if (is.na(x))
NA
else
parseJSON(x)
})
}
}
# use integer indices
if ("group_index" %in% names(res))
res$group_index <- type.convert(res$group_index, as.is = TRUE)
}

return(res)
}
Expand Down
33 changes: 14 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
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)

openrouteservice R client
=========================
# openrouteservice R client

*openrouteservice* R package provides easy access to the
[openrouteservice](https://openrouteservice.org) (ORS) API from R. It
Expand All @@ -18,7 +17,8 @@ allows you to painlessly consume the following services:
(accessibility)
- time-distance
[matrix](https://openrouteservice.org/dev/#/api-docs/v2/matrix/%7Bprofile%7D/post)
- [snapping](https://openrouteservice.org/dev/#/api-docs/snap) to ways
- [snapping](https://openrouteservice.org/dev/#/api-docs/v2/snap/%7Bprofile%7D/post)
to ways
- [pois](https://openrouteservice.org/dev/#/api-docs/pois/post)
(points of interest)
- SRTM
Expand All @@ -28,30 +28,26 @@ allows you to painlessly consume the following services:
[optimization](https://openrouteservice.org/dev/#/api-docs/optimization/post)
based on [Vroom](http://vroom-project.org/)

Disclaimer
----------
## Disclaimer

By using this package, you agree to the ORS [terms and
conditions](https://openrouteservice.org/terms-of-service/).

Installation
------------
## Installation

The package is not yet available from CRAN, but you can install the
development version directly from GitHub.

# install.packages("remotes")
remotes::install_github("GIScience/openrouteservice-r")

Get started
-----------
## Get started

See the package
[vignette](https://giscience.github.io/openrouteservice-r/articles/openrouteservice.html)
for an overview of the offered functionality.

Local ORS instance
------------------
## Local ORS instance

The default is to fire any requests against the free public services at
&lt;api.openrouteservice.org&gt;. In order to query a different
Expand All @@ -72,8 +68,13 @@ defaults are equivalent of having
optimization = "optimization",
snap = "v2/snap"))

Package News
------------
## Package News

### version 0.5.1

#### BUG FIXES

- sf output for POIs endpoint (#81)

### version 0.5.0

Expand All @@ -86,9 +87,3 @@ Package News
#### NEW FEATURES

- Enable optimization endpoint.

### version 0.3.3

#### BUG FIXES

- Fixed resolving of URL paths to endpoints.

0 comments on commit 735390c

Please sign in to comment.