Skip to content

Commit

Permalink
tests .read_vector() in directory with write permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
goergen95 committed Oct 21, 2024
1 parent 4412487 commit b528b1a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

- `get_nasa_srtm()` now uses GDAL's VSI path option `pc_url_signing=yes` to
sign URLs from Microsoft Planetary Computer (#383)

## Internal

- test for `.read_vector()` now copies input GPKG to a directory with write
permissions to avoid CRAN check failures when included in a read only directory

# mapme.biodiversity 0.9.2

Expand Down
14 changes: 10 additions & 4 deletions tests/testthat/test-calc_indicator.R
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ test_that(".read_raster works correctly", {
files <- list.files(temp_loc, full.names = TRUE)
footprints <- make_footprints(files, what = "raster")
footprints[["location"]] <- files
extent1 <- c(xmin=-179.9, xmax=179.9, ymin=-89.9, ymax=89.9)
extent2 <- c(xmin=-180, xmax=180, ymin=-90, ymax=90)
extent1 <- c(xmin = -179.9, xmax = 179.9, ymin = -89.9, ymax = 89.9)
extent2 <- c(xmin = -180, xmax = 180, ymin = -90, ymax = 90)
x <- st_as_sfc(st_bbox(extent1, crs = "EPSG:4326"))

tiled_temporal <- .read_raster(x, footprints)
Expand All @@ -256,9 +256,15 @@ test_that(".read_raster works correctly", {
})

test_that(".read_vector works", {
skip_on_cran()
if (sf::sf_extSoftVersion()[["GDAL"]] < "3.7.0") skip()
v <- system.file("extdata", "burundi.gpkg", package = "mapme.biodiversity")

# copy to directory with w permissions, as ogrinfo otherwise fails on CRAN
org <- system.file("extdata", "burundi.gpkg", package = "mapme.biodiversity")
outdir <- tempfile()
dir.create(outdir)
v <- file.path(outdir, basename(org))
file.copy(org, v)

x <- st_as_sf(st_as_sfc(st_bbox(read_sf(v))))
fps <- make_footprints(v, what = "vector")
fps[["location"]] <- v
Expand Down

0 comments on commit b528b1a

Please sign in to comment.