Skip to content

Commit

Permalink
Fix concatenation of xml_nodeset for calls in batches
Browse files Browse the repository at this point in the history
Only the first node of each batch after the first were included.
  • Loading branch information
jmaspons committed Jun 13, 2024
1 parent 1e67bb5 commit 1fc7ba8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
6 changes: 4 additions & 2 deletions R/osm_get_changesets.R
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,10 @@ osm_get_changesets <- function(changeset_id, include_discussion = FALSE,
}
} else if (format == "xml") {
out <- xml2::xml_new_root(outL[[1]])
for (i in seq_len(length(outL) - 1)) {
xml2::xml_add_child(out, xml2::xml_child(outL[[i + 1]]))
for (i in seq_along(outL[-1]) + 1) {
lapply(xml2::xml_children(outL[[i]]), function(node) {
xml2::xml_add_child(out, node)
})
}
} else if (format == "json") {
out <- outL[[1]]
Expand Down
6 changes: 4 additions & 2 deletions R/osm_get_gpx_metadata.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ osm_get_gpx_metadata <- function(gpx_id, format = c("R", "xml")) {
out <- do.call(rbind, outL)
} else if (format == "xml") {
out <- xml2::xml_new_root(outL[[1]])
for (i in seq_len(length(outL) - 1)) {
xml2::xml_add_child(out, xml2::xml_child(outL[[i + 1]]))
for (i in seq_along(outL[-1]) + 1) {
lapply(xml2::xml_children(outL[[i]]), function(node) {
xml2::xml_add_child(out, node)
})
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions R/osm_get_notes.R
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,10 @@ osm_get_notes <- function(note_id, format = c("R", "xml", "rss", "json", "gpx"))
out <- do.call(rbind, outL)
} else if (format %in% c("xml", "rss", "gpx")) {
out <- xml2::xml_new_root(outL[[1]])
for (i in seq_len(length(outL) - 1)) {
xml2::xml_add_child(out, xml2::xml_child(outL[[i + 1]]))
for (i in seq_along(outL[-1]) + 1) {
lapply(xml2::xml_children(outL[[i]]), function(node) {
xml2::xml_add_child(out, node)
})
}
# TODO: remove namespaces for format %in% c("rss", "gpx"). xml2::xml_structure(out) [<wpt [lon, lat]> VS <wpt [lon, lat, xmlns]>]
# xml namespace https://community.rstudio.com/t/adding-nodes-in-xml2-how-to-avoid-duplicate-default-namespaces/84870/
Expand Down

0 comments on commit 1fc7ba8

Please sign in to comment.