Skip to content

Commit 1e28e8c

Browse files
authored
Merge pull request #69 from ropensci/update_wiki
Update API wiki version
2 parents 7bebc7f + f03ab58 commit 1e28e8c

File tree

15 files changed

+137
-39
lines changed

15 files changed

+137
-39
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Type: Package
22
Package: osmapiR
33
Title: 'OpenStreetMap' API
4-
Version: 0.2.3.9001
4+
Version: 0.2.3.9002
55
Authors@R: c(
66
person("Joan", "Maspons", , "[email protected]", role = c("aut", "cre", "cph"),
77
comment = c(ORCID = "0000-0003-2286-8727")),

NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# osmapiR (development version)
22

33
* Fix for upcoming httr2 1.2.0 release (#67 by @hadley).
4+
* Update documentation and code for server-side changes documented in OSMWikiVersion
5+
[2834473 -> 2878437](https://wiki.openstreetmap.org/w/index.php?title=API_v0.6&diff=2878437&oldid=2834473) (#69).
6+
* Add `format = "json"` for `osm_get_gpx_metadata()`.
7+
* New default for `osm_search_notes()` to `sort = "created_at"` instead of `sort = "updated_at"`.
48

59
# osmapiR 0.2.3
610

OSMwiki_version

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
# last synchronized version of https://wiki.openstreetmap.org/wiki/API_v0.6. Diff current https://wiki.openstreetmap.org/w/index.php?title=API_v0.6&diff=cur&oldid=2834473
2-
2834473
1+
# last synchronized version of https://wiki.openstreetmap.org/wiki/API_v0.6. Diff current https://wiki.openstreetmap.org/w/index.php?title=API_v0.6&diff=cur&oldid=2878437
2+
2878437

R/osm_get_gpx_metadata.R

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#' Otherwise only usable by the owner account and requires authentication.
77
#'
88
#' @param gpx_id A vector of track ids represented by a numeric or a character value.
9-
#' @param format Format of the output. Can be `"R"` (default), `"sf"`, or `"xml"`.
9+
#' @param format Format of the output. Can be `"R"` (default), `"sf"`, `"xml"`, or `"json"`.
1010
#'
1111
#' @return
1212
#' If `format = "R"`, returns a data frame with one trace per row. If `format = "sf"`, returns a `sf` object from
@@ -24,6 +24,7 @@
2424
#' </gpx_file>
2525
#' </osm>
2626
#' ```
27+
#' If `format = "json"`, returns a list with the json structure.
2728
#' @family get GPS' functions
2829
#' @export
2930
#'
@@ -32,7 +33,7 @@
3233
#' trk_meta <- osm_get_gpx_metadata(gpx_id = 3498170)
3334
#' trk_meta
3435
#' }
35-
osm_get_gpx_metadata <- function(gpx_id, format = c("R", "sf", "xml")) {
36+
osm_get_gpx_metadata <- function(gpx_id, format = c("R", "sf", "xml", "json")) {
3637
format <- match.arg(format)
3738
.format <- if (format == "sf") "R" else format
3839
if (format == "sf" && !requireNamespace("sf", quietly = TRUE)) {
@@ -55,6 +56,10 @@ osm_get_gpx_metadata <- function(gpx_id, format = c("R", "sf", "xml")) {
5556
xml2::xml_add_child(out, node)
5657
})
5758
}
59+
} else if (.format == "json") {
60+
out <- outL[[1]]
61+
out$traces <- lapply(outL, function(x) x$trace)
62+
out$trace <- NULL
5863
}
5964
}
6065

R/osmapi_elements.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ osm_version_object <- function(osm_type = c("node", "way", "relation"), osm_id,
685685
# ; HTTP status code 400 (Bad Request)
686686
# : On a malformed request (parameters missing or wrong)
687687
# ; HTTP status code 404 (Not Found)
688-
# : If one of the elements could not be found (By "not found" is meant never existed in the database, if the object was deleted, it will be returned with the attribute visible="false")
688+
# : If one of the elements could not be found (By "not found" is meant never existed in the database or its requested version was redacted, if the object was deleted, it will be returned with the attribute visible="false")
689689
# ; HTTP status code 414 (Request-URI Too Large)
690690
# : If the URI was too long (tested to be > 8213 characters in the URI, or > 725 elements for 10 digit IDs when not specifying versions)
691691
#

R/osmapi_gps_traces.R

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@
133133
# |The GPX file containing the track points. Note that for successful processing, the file must contain trackpoints (<code><trkpt></code>), not only waypoints, and the trackpoints must have a valid timestamp. Since the file is processed asynchronously, the call will complete successfully even if the file cannot be processed. The file may also be a .tar, .tar.gz or .zip containing multiple gpx files, although it will appear as a single entry in the upload log.
134134
# |-
135135
# |description
136-
# |The trace description. Cannot be empty.
136+
# |The trace description. Cannot be empty. Maximum length is 255 characters.
137137
# |-
138138
# |tags
139139
# |A string containing tags for the trace. Can be empty.
@@ -156,7 +156,7 @@
156156
#' Use this to upload a GPX file or archive of GPX files. Requires authentication.
157157
#'
158158
#' @param file The GPX file path containing the track points.
159-
#' @param description The trace description. Cannot be empty.
159+
#' @param description The trace description. Cannot be empty. Maximum length is 255 characters.
160160
#' @param tags A string containing tags for the trace. Can be empty.
161161
#' @param visibility One of the following: `private`, `public`, `trackable`, `identifiable`. For explanations see
162162
#' [OSM trace upload page](https://www.openstreetmap.org/traces/mine) or
@@ -311,14 +311,16 @@ osm_update_gpx <- function(gpx_id, name, description, tags,
311311
# </osm>
312312
# </syntaxhighlight>
313313
# Note: the <code>uid</code> attribute was added in {{gitHub link|openstreetmap/openstreetmap-website/pull/4241| September 2023}}.
314+
#
315+
# This API call also supports a JSON response.
314316

315317
#' Download GPS Track Metadata
316318
#'
317319
#' Use this to access the metadata about a GPX file. Available without authentication if the file is marked public.
318320
#' Otherwise only usable by the owner account and requires authentication.
319321
#'
320322
#' @param gpx_id The track id represented by a numeric or a character value.
321-
#' @param format Format of the output. Can be `"R"` (default) or `"xml"`.
323+
#' @param format Format of the output. Can be `"R"` (default), `"xml"`, or `"json"`.
322324
#'
323325
#' @return
324326
#' If `format = "R"`, returns a data frame with one trace per row. If `format = "xml"`, returns a
@@ -341,19 +343,26 @@ osm_update_gpx <- function(gpx_id, name, description, tags,
341343
#' trk_meta <- osm_get_metadata_gpx(gpx_id = 3498170)
342344
#' trk_meta
343345
#' }
344-
osm_get_metadata_gpx <- function(gpx_id, format = c("R", "xml")) {
346+
osm_get_metadata_gpx <- function(gpx_id, format = c("R", "xml", "json")) {
345347
format <- match.arg(format)
348+
349+
if (format == "json") {
350+
gpx_id <- paste0(gpx_id, ".json")
351+
}
352+
346353
req <- osmapi_request(authenticate = TRUE)
347354
req <- httr2::req_method(req, "GET")
348355
req <- httr2::req_url_path_append(req, "gpx", gpx_id)
349356

350357
resp <- httr2::req_perform(req)
351-
obj_xml <- httr2::resp_body_xml(resp)
352358

353-
if (format == "R") {
354-
out <- gpx_meta_xml2DF(obj_xml)
355-
} else {
356-
out <- obj_xml
359+
if (format %in% c("R", "xml")) {
360+
out <- httr2::resp_body_xml(resp)
361+
if (format == "R") {
362+
out <- gpx_meta_xml2DF(out)
363+
}
364+
} else if (format %in% "json") {
365+
out <- httr2::resp_body_json(resp)
357366
}
358367

359368
return(out)

R/osmapi_map_notes.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ osm_unsubscribe_note <- function(note_id) { # TODO: , format = c("R", "xml", "js
715715
# |<code>sort</code>
716716
# | Sort results by creation or update date.
717717
# | <code>created_at</code> or <code>updated_at</code>
718-
# | <code>updated_at</code>
718+
# | <code>created_at</code>
719719
# |-
720720
# |<code>order</code>
721721
# | Sorting order. <code>oldest</code> is ascending order, <code>newest</code> is descending order.
@@ -755,7 +755,7 @@ osm_unsubscribe_note <- function(note_id) { # TODO: , format = c("R", "xml", "js
755755
#' [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date format. Only works when `from` is supplied.
756756
#' @param closed Specifies the number of days a note needs to be closed to no longer be returned. A value of 0 means
757757
#' only open notes are returned. A value of -1 means all notes are returned. 7 is the default.
758-
#' @param sort Sort results by creation (`"created_at"`) or update date (`"updated_at"`, the default).
758+
#' @param sort Sort results by creation (`"created_at"`, the default) or update date (`"updated_at"`).
759759
#' @param order Sorting order. `"oldest"` is ascending order, `"newest"` is descending order (the default).
760760
#' @param limit Maximum number of results between 1 and 10000 (may change, see `osm_capabilities()$api$notes` for the
761761
#' current value). Default to 100.
@@ -786,7 +786,7 @@ osm_unsubscribe_note <- function(note_id) { # TODO: , format = c("R", "xml", "js
786786
#' my_notes
787787
osm_search_notes <- function(
788788
q, user, bbox, from, to, closed = 7,
789-
sort = c("updated_at", "created_at"), order = c("newest", "oldest"),
789+
sort = c("created_at", "updated_at"), order = c("newest", "oldest"),
790790
limit = getOption("osmapir.api_capabilities")$api$notes["default_query_limit"],
791791
format = c("R", "sf", "xml", "rss", "json", "gpx")) {
792792
sort <- match.arg(sort)

codemeta.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"codeRepository": "https://github.com/ropensci/osmapiR",
99
"issueTracker": "https://github.com/ropensci/osmapiR/issues",
1010
"license": "https://spdx.org/licenses/GPL-3.0",
11-
"version": "0.2.3.9001",
11+
"version": "0.2.3.9002",
1212
"programmingLanguage": {
1313
"@type": "ComputerLanguage",
1414
"name": "R",
@@ -164,7 +164,7 @@
164164
"SystemRequirements": null
165165
},
166166
"keywords": ["openstreetmap", "OSM", "openstreetmap-api", "osmapi", "API", "osm", "r", "r-package"],
167-
"fileSize": "14152.15KB",
167+
"fileSize": "14155.039KB",
168168
"citation": [
169169
{
170170
"@type": "ScholarlyArticle",
@@ -180,7 +180,7 @@
180180
],
181181
"name": "osmapiR: An 'OpenStreetMap API' implementation for R",
182182
"identifier": "10.21105/joss.07151",
183-
"description": "R package version 0.2.3.9001",
183+
"description": "R package version 0.2.3.9002",
184184
"pagination": "7151",
185185
"@id": "https://doi.org/10.21105/joss.07151",
186186
"sameAs": "https://doi.org/10.21105/joss.07151",

man/osm_create_gpx.Rd

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

man/osm_get_gpx_metadata.Rd

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)