Skip to content

Commit 25e7910

Browse files
committed
reinstate test
1 parent 40749cd commit 25e7910

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

R/vectortranslate.R

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -536,8 +536,11 @@ process_boundary = function(
536536
boundary = NULL,
537537
boundary_type = c("spat", "clipsrc")
538538
) {
539-
# Starting from #313, boundary might be NA on purpose
540-
if (is.na(boundary) || is.null(boundary)) {
539+
# Starting from #313, boundary might be NA on purpose.
540+
# FIXME: How to handle the case where, for whatever reason, boundary is like
541+
# c(NA, valid_polygon)? For the moment I'll just bypass this situation and
542+
# ignore any boundary arg which contains at least one NA.
543+
if (anyNA(boundary) || is.null(boundary)) {
541544
return(vectortranslate_options)
542545
}
543546

@@ -563,7 +566,7 @@ process_boundary = function(
563566
# Check the number of geometries
564567
if (length(boundary) > 1L) {
565568
warning(
566-
"The boundary is composed by more than one features. Selecting the first. ",
569+
"The boundary is composed by more than one feature. Selecting the first.",
567570
call. = FALSE
568571
)
569572
boundary = boundary[1L]

tests/testthat/test-read.R

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -234,18 +234,18 @@ test_that("we can combine boundary = ... with other vectortranslate arguments",
234234
expect_equal(nrow(its_clipsrc_small), sum(its_clipsrc[["highway"]] == "footway", na.rm = TRUE))
235235
})
236236

237-
# test_that("get a warning for more than 1 polygon in boundary = ...", {
238-
# withr::local_envvar(
239-
# .new = list(
240-
# "OSMEXT_DOWNLOAD_DIRECTORY" = tempdir(),
241-
# "TESTTHAT" = "true"
242-
# )
243-
# )
244-
# its_pbf = setup_pbf()
245-
#
246-
# # Warning for more than 1 POLYGON
247-
# expect_warning(oe_read(its_pbf, boundary = c(its_poly, its_poly), quiet = TRUE))
248-
# })
237+
test_that("get warning for more than 1 polygon in boundary = ...", {
238+
withr::local_envvar(
239+
.new = list(
240+
"OSMEXT_DOWNLOAD_DIRECTORY" = tempdir(),
241+
"TESTTHAT" = "true"
242+
)
243+
)
244+
its_pbf = setup_pbf()
245+
246+
# Warning for more than 1 POLYGON
247+
expect_warning(oe_read(its_pbf, boundary = c(its_poly, its_poly), quiet = TRUE))
248+
})
249249

250250
test_that("get error when boundary is not a POLYGON/MULTIPOLYGON", {
251251
withr::local_envvar(

0 commit comments

Comments
 (0)