Skip to content

Commit 0647e9f

Browse files
authored
Merge pull request #84 from GIScience/fix/pois_sf_output
fix: error when using sf output for pois
2 parents d33e1ca + 735390c commit 0647e9f

File tree

4 files changed

+39
-22
lines changed

4 files changed

+39
-22
lines changed

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: openrouteservice
22
Title: Openrouteservice API Client
3-
Version: 0.5.0
3+
Version: 0.5.1
44
Authors@R: person("Andrzej", "Oleś", email = "andrzej.oles@gmail.com", comment = c(ORCID = "0000-0003-0285-2787"), role = c("aut", "cre"))
55
Description: The package streamlines access to the services provided by openrouteservice.org.
66
It allows you to painlessly query for directions, geocoding, isochrones, time-distance matrices, and POIs.
@@ -13,4 +13,4 @@ Encoding: UTF-8
1313
LazyData: true
1414
VignetteBuilder: knitr
1515
Roxygen: list(markdown = TRUE)
16-
RoxygenNote: 7.3.1
16+
RoxygenNote: 7.3.2

NEWS.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# openrouteservice 0.5.1
2+
3+
## BUG FIXES
4+
5+
- sf output for POIs endpoint (#81)
6+
17
# openrouteservice 0.5.0
28

39
## NEW FEATURES

R/api_call.R

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ parse_content <- function (content,
236236
if (output=="sf" && is_geojson) {
237237
res <- tryCatch(geojson_sf(content), error = function(e) stop(e$message,": ", content, call. = FALSE))
238238

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

249249
res[names(properties)] <- properties
250250
}
251+
else if (endpoint!="geocode") {
252+
for (i in 1:length(res)) {
253+
# attempt to parse JSON strings to R objects
254+
if (is.character(res[[i]])) {
255+
res[[i]] <- lapply(res[[i]], function(x) {
256+
if (is.na(x))
257+
NA
258+
else
259+
parseJSON(x)
260+
})
261+
}
262+
}
263+
# use integer indices
264+
if ("group_index" %in% names(res))
265+
res$group_index <- type.convert(res$group_index, as.is = TRUE)
266+
}
251267

252268
return(res)
253269
}

README.md

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
Status](https://img.shields.io/codecov/c/github/GIScience/openrouteservice-r/master.svg)](https://app.codecov.io/github/GIScience/openrouteservice-r?branch=master)
44
[![lifecycle](https://lifecycle.r-lib.org/articles/figures/lifecycle-experimental.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
55

6-
openrouteservice R client
7-
=========================
6+
# openrouteservice R client
87

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

31-
Disclaimer
32-
----------
31+
## Disclaimer
3332

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

37-
Installation
38-
------------
36+
## Installation
3937

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

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

46-
Get started
47-
-----------
44+
## Get started
4845

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

53-
Local ORS instance
54-
------------------
50+
## Local ORS instance
5551

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

75-
Package News
76-
------------
71+
## Package News
72+
73+
### version 0.5.1
74+
75+
#### BUG FIXES
76+
77+
- sf output for POIs endpoint (#81)
7778

7879
### version 0.5.0
7980

@@ -86,9 +87,3 @@ Package News
8687
#### NEW FEATURES
8788

8889
- Enable optimization endpoint.
89-
90-
### version 0.3.3
91-
92-
#### BUG FIXES
93-
94-
- Fixed resolving of URL paths to endpoints.

0 commit comments

Comments
 (0)