Skip to content

Commit 8d0adb5

Browse files
committed
feat: sf output for snapping
1 parent 11bd849 commit 8d0adb5

File tree

6 files changed

+27
-13
lines changed

6 files changed

+27
-13
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: openrouteservice
22
Title: Openrouteservice API Client
3-
Version: 0.5.1
3+
Version: 0.5.2
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.

NEWS.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# openrouteservice 0.5.2
2+
3+
## NEW FEATURES
4+
5+
- sf output for snapping.
6+
17
# openrouteservice 0.5.1
28

39
## BUG FIXES

R/api_call.R

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ parse_content <- function (content,
249249

250250
res[names(properties)] <- properties
251251
}
252-
else if (endpoint!="geocode") {
252+
else if (endpoint %in% c("isochrones", "pois")) {
253253
for (i in 1:length(res)) {
254254
# attempt to parse JSON strings to R objects
255255
if (is.character(res[[i]])) {
@@ -261,11 +261,14 @@ parse_content <- function (content,
261261
})
262262
}
263263
}
264-
# use integer indices
265-
if ("group_index" %in% names(res))
266-
res$group_index <- type.convert(res$group_index, as.is = TRUE)
267264
}
268265

266+
# use integer indices
267+
id_cols <- c("group_index", "source_id")
268+
id_cols <- id_cols[id_cols %in% names(res)]
269+
for (name in id_cols)
270+
res[[name]] <- type.convert(res[[name]], as.is = TRUE)
271+
269272
return(res)
270273
}
271274

R/snap.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#' @templateVar return Coordinates of snapped location(s) and distance to the original point(s)
1515
#' @template return-text
1616
#' @template return-parsed
17+
#' @template return-sf
1718
#' @examples
1819
#' locations = list(
1920
#' c(8.669629, 49.413025),
@@ -32,7 +33,7 @@ ors_snap <- function(locations,
3233
format = c('geojson', 'json'),
3334
...,
3435
api_key = ors_api_key(),
35-
output = c("parsed", "text")) {
36+
output = c("parsed", "text", "sf")) {
3637
## required arguments with no default value
3738
if (missing(locations))
3839
stop('Missing argument "locations"')

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ defaults are equivalent of having
7070

7171
## Package News
7272

73+
### version 0.5.2
74+
75+
#### NEW FEATURES
76+
77+
- sf output for snapping.
78+
7379
### version 0.5.1
7480

7581
#### BUG FIXES
@@ -81,9 +87,3 @@ defaults are equivalent of having
8187
#### NEW FEATURES
8288

8389
- Enable snap endpoint.
84-
85-
### version 0.4.0
86-
87-
#### NEW FEATURES
88-
89-
- Enable optimization endpoint.

man/ors_snap.Rd

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)