Skip to content

Commit

Permalink
closes #369 (#371)
Browse files Browse the repository at this point in the history
  • Loading branch information
goergen95 authored Aug 29, 2024
1 parent ab72bf4 commit ad9b968
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion tests/testthat/test-calc_indicator.R
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ test_that("Parallelization works", {
)
plan(sequential)

expect_equal(names(stat), c("assetid", "treecover_area", "x"))
expect_equal(names(stat)[1:2], c("assetid", "treecover_area"))
expect_equal(nrow(stat), 9)

stat <- lapply(stat$treecover_area, function(x) x$value)
Expand Down
20 changes: 10 additions & 10 deletions tests/testthat/test-chunking.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
test_that(".crosses_dateline and .split_dateline works", {
bbox <- c(xmin = -175.1, ymin = -0.1, xmax = 175.1, ymax = 0.1)
x <- st_as_sf(st_as_sfc(st_bbox(bbox, crs = st_crs("EPSG:4326"))),
assetid = 1
)
x <- st_as_sfc(st_bbox(bbox, crs = st_crs("EPSG:4326")))
x <- st_sf(assetid = 1, geometry = x)
expect_true(.crosses_dateline(st_geometry(x)[[1]], offset = 10))
expect_false(.crosses_dateline(st_geometry(x)[[1]], offset = 9))
expect_silent(x2 <- .split_dateline(x))
Expand All @@ -19,13 +18,13 @@ test_that(".calc_bbox_area works", {

test_that(".try_make_valid works", {
bbox <- c(xmin = -10.0, ymin = -10.0, xmax = 10.0, ymax = 10.0)
x <- st_as_sf(st_as_sfc(st_bbox(bbox)), crs ="EPSG:4326")
x <- st_as_sf(st_as_sfc(st_bbox(bbox)), crs = "EPSG:4326")
grid <- st_sf(geometry = st_make_grid(x, n = 2))

# invalid geom
invalid <- st_sf(geometry = st_sfc(st_polygon(x = list(
matrix(c(unlist(st_geometry(grid)[1]), 0, -10, -10, 0), ncol = 2, byrow = T)
)), crs = "EPSG:4326"))
)), crs = "EPSG:4326"))
expect_false(st_is_valid(invalid))

# geom collection
Expand All @@ -44,7 +43,8 @@ test_that(".cast_to_polygon works", {
bbox <- c(xmin = -1.0, ymin = -1., xmax = 1.0, ymax = 1.0)
x <- st_as_sfc(st_bbox(bbox))
x <- st_make_grid(x, n = c(2, 2))
x <- st_as_sf(st_sfc(st_multipolygon(x), crs = st_crs("EPSG:4326")), assetid = 1)
x <- st_sfc(st_multipolygon(x), crs = st_crs("EPSG:4326"))
x <- st_sf(geometry = x, assetid = 1)
expect_equal(nrow(x), 1)
expect_true(st_geometry_type(x) == "MULTIPOLYGON")
expect_silent(x2 <- .cast_to_polygon(x))
Expand All @@ -56,7 +56,7 @@ test_that(".cast_to_polygon works", {

test_that(".split_multipolygons works", {
bbox <- c(xmin = -10.0, ymin = -10.0, xmax = 10.0, ymax = 10.0)
x <- st_as_sf(st_as_sfc(st_bbox(bbox)), crs = st_crs("EPSG:4326"))
x <- st_as_sfc(st_bbox(bbox, crs = st_crs("EPSG:4326")))
x <- st_make_grid(x, n = c(4, 4))
x <- st_sf(
assetid = 1, chunked = FALSE,
Expand All @@ -71,7 +71,7 @@ test_that(".split_multipolygons works", {

test_that(".make_grid works", {
bbox <- c(xmin = -10.0, ymin = -10.0, xmax = 10.0, ymax = 10.0)
x <- st_as_sf(st_as_sfc(st_bbox(bbox)),
x <- st_sf(st_as_sfc(st_bbox(bbox)),
crs = st_crs("EPSG:4326"),
assetid = 1
)
Expand All @@ -84,7 +84,7 @@ test_that(".make_grid works", {

test_that(".chunk_geoms works", {
bbox <- c(xmin = -10.0, ymin = -10.0, xmax = 10.0, ymax = 10.0)
x <- st_as_sf(st_as_sfc(st_bbox(bbox)),
x <- st_sf(st_as_sfc(st_bbox(bbox)),
crs = st_crs("EPSG:4326"),
assetid = 1, chunked = TRUE
)
Expand All @@ -99,7 +99,7 @@ test_that(".chunk_geoms works", {

test_that(".finalize_assets works correctly", {
bbox <- c(xmin = -10.0, ymin = -10.0, xmax = 10.0, ymax = 10.0)
x <- st_as_sf(st_as_sfc(st_bbox(bbox)),
x <- st_sf(st_as_sfc(st_bbox(bbox)),
crs = st_crs("EPSG:4326"),
assetid = 1, var = "variable"
)
Expand Down

0 comments on commit ad9b968

Please sign in to comment.