Skip to content

Commit

Permalink
Merge pull request #61 from ropensci/fix-osm_query_changesets
Browse files Browse the repository at this point in the history
Fix `osm_query_changesets(..., time, time_2)`
  • Loading branch information
jmaspons authored Nov 17, 2024
2 parents 2b68620 + bae689f commit f49f450
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
7 changes: 5 additions & 2 deletions R/osmapi_changesets.R
Original file line number Diff line number Diff line change
Expand Up @@ -689,8 +689,11 @@ osm_download_changeset <- function(changeset_id, format = c("R", "osc", "xml"))
if (!is.null(time) && inherits(time, "POSIXt")) {
time <- format(time, "%Y-%m-%dT%H:%M:%SZ")
}
if (!is.null(time_2) && inherits(time_2, "POSIXt")) {
time_2 <- format(time_2, "%Y-%m-%dT%H:%M:%SZ")
if (!is.null(time_2)) {
stopifnot("`time_2` requires `time` parameter." = !is.null(time))
if (inherits(time_2, "POSIXt")) {
time_2 <- format(time_2, "%Y-%m-%dT%H:%M:%SZ")
}
time <- paste0(time, ",", time_2)
}

Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-changesets.R
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,8 @@ test_that("osm_query_changesets works", {
chaset$time <- osm_query_changesets(
bbox = c(-1.241112, 38.0294955, 8.4203171, 42.9186456),
user = "Mementomoristultus",
time = "2023-06-22T02:23:23Z",
time_2 = "2023-06-22T00:38:20Z"
time = as.POSIXct("2023-06-22T02:20:23Z", tz = "GMT", format = "%Y-%m-%dT%H:%M:%S"),
time_2 = as.POSIXct("2023-06-22T02:30:00Z", tz = "GMT", format = "%Y-%m-%dT%H:%M:%S")
)
chaset$from_to <- osm_query_changesets(
bbox = c(-1.241112, 38.0294955, 8.4203171, 42.9186456),
Expand Down
8 changes: 4 additions & 4 deletions tests/testthat/test-tags_list-wide.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ test_that("Changesets tags_list-wide works", {
tags_list$time <- osm_query_changesets(
bbox = c(-1.241112, 38.0294955, 8.4203171, 42.9186456),
user = "Mementomoristultus",
time = "2023-06-22T02:23:23Z",
time_2 = "2023-06-22T00:38:20Z"
time = "2023-06-22T02:20:23Z",
time_2 = "2023-06-22T02:30:00Z"
)
tags_list$closed <- osm_query_changesets(
bbox = c("-9.3015367,41.8073642,-6.7339533,43.790422"),
Expand All @@ -90,8 +90,8 @@ test_that("Changesets tags_list-wide works", {
tags_wide$time <- osm_query_changesets(
bbox = c(-1.241112, 38.0294955, 8.4203171, 42.9186456),
user = "Mementomoristultus",
time = "2023-06-22T02:23:23Z",
time_2 = "2023-06-22T00:38:20Z",
time = "2023-06-22T02:20:23Z",
time_2 = "2023-06-22T02:30:00Z",
tags_in_columns = TRUE
)
tags_wide$closed <- osm_query_changesets(
Expand Down

0 comments on commit f49f450

Please sign in to comment.