Skip to content

Commit

Permalink
remove web responses with 0 rows - fixes DOI-USGS#361
Browse files Browse the repository at this point in the history
  • Loading branch information
dblodgett-usgs committed Oct 9, 2023
1 parent e73ae20 commit 66e954a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion DESCRIPTION
@@ -1,7 +1,7 @@
Package: nhdplusTools
Type: Package
Title: NHDPlus Tools
Version: 1.0.0
Version: 1.0.1
Authors@R: c(person(given = "David",
family = "Blodgett",
role = c("aut", "cre"),
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
@@ -1,3 +1,8 @@
nhdplusTools 1.0.1
==========

- fixed bug with large nhdplus downloads with empty tiles. #361

nhdplusTools 1.0.0
==========

Expand Down
5 changes: 5 additions & 0 deletions R/geoserver_tools.R
Expand Up @@ -227,6 +227,11 @@ unify_types <- function(out) {
}
}
}

rows <- sapply(out, nrow)

out <- out[rows > 0]

out
}

Expand Down
11 changes: 11 additions & 0 deletions tests/testthat/test_02_subset_extras.R
Expand Up @@ -170,3 +170,14 @@ test_that("extras", {
expect_equal(nhdplusTools:::get_empty("MULTIPOINT"), sf::st_multipoint())
expect_error(nhdplusTools:::get_empty("BORKED"), "unexpected geometry type")
})

test_that("unify_types", {

check <- list(data.frame(), data.frame(one = 1, two = "2"), data.frame(one = "1", two = 2))

out <- nhdplusTools:::unify_types(check)

expect_equal(out,
list(structure(list(one = 1, two = 2), row.names = c(NA, -1L), class = "data.frame"),
structure(list(one = 1, two = 2), row.names = c(NA, -1L), class = "data.frame")))
})

0 comments on commit 66e954a

Please sign in to comment.