Skip to content

Commit

Permalink
Merge pull request #196 from ctoney/1.7.1
Browse files Browse the repository at this point in the history
fixup for 1.8.0
  • Loading branch information
ctoney authored Jan 27, 2024
2 parents 165260f + 37b99ab commit 2e03718
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 28 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ Suggests:
scales,
testthat (>= 3.0.0)
NeedsCompilation: yes
SystemRequirements: GDAL (>= 2.4.0), PROJ
SystemRequirements: GDAL (>= 2.4.0), PROJ, libxml2
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.0
RoxygenNote: 7.3.1
VignetteBuilder: knitr
Config/testthat/edition: 3
29 changes: 15 additions & 14 deletions R/gdal_helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
#' @details
#' A Seek-Optimized ZIP file (SOZip) contains one or more compressed files
#' organized and annotated such that a SOZip-aware reader can perform very
#' fast random access within the .zip file (see \url{https://sozip.org/}).
#' fast random access within the .zip file
#' (see \url{https://github.com/sozip/sozip-spec}).
#' Large compressed files can be accessed directly from SOZip without prior
#' decompression. The .zip file is otherwise fully backward compatible.
#'
Expand Down Expand Up @@ -92,34 +93,34 @@ addFilesInZip <- function(
quiet = FALSE) {

if (as.integer(gdal_version()[2]) < 3070000)
stop("addFilesInZip() requires GDAL >= 3.7.", call. = FALSE)
stop("`addFilesInZip()` requires GDAL >= 3.7.", call. = FALSE)

if (!is.character(zip_file) || length(zip_file) > 1)
stop("zip_file argument must be a string.", call. = FALSE)
stop("`zip_file` must be a string.", call. = FALSE)

if (!is.character(add_files))
stop("add_files must be a character vector of filenames.",
stop("`add_files` must be a character vector of filenames.",
call. = FALSE)

if (!is.null(overwrite)) {
if (!is.logical(overwrite) || length(overwrite) > 1)
stop("overwrite must be an logical scalar.", call. = FALSE)
stop("`overwrite` must be a logical scalar.", call. = FALSE)
}
else {
overwrite <- FALSE
}

if (!is.null(full_paths)) {
if (!is.logical(full_paths) || length(full_paths) > 1)
stop("full_paths must be an logical scalar.", call. = FALSE)
stop("`full_paths` must be a logical scalar.", call. = FALSE)
}
else {
full_paths <- FALSE
}

if (!is.null(quiet)) {
if (!is.logical(quiet) || length(quiet) > 1)
stop("quiet must be an logical scalar.", call. = FALSE)
stop("`quiet` must be a logical scalar.", call. = FALSE)
}
else {
quiet <- FALSE
Expand All @@ -128,31 +129,31 @@ addFilesInZip <- function(
opt <- NULL
if (!is.null(sozip_enabled)) {
if (!is.character(sozip_enabled) || length(sozip_enabled) > 1)
stop("sozip_enabled must be a string.", call. = FALSE)
stop("`sozip_enabled` must be a string.", call. = FALSE)
sozip_enabled <- toupper(sozip_enabled)
if ( !(sozip_enabled %in% c("AUTO", "YES", "NO")) )
stop("sozip_enabled must be one of AUTO, YES or NO.", call. = FALSE)
stop("`sozip_enabled` must be one of AUTO, YES or NO.", call. = FALSE)
else
opt <- c(opt, paste0("SOZIP_ENABLED=", sozip_enabled))
}
if (!is.null(sozip_chunk_size)) {
if (length(sozip_chunk_size) > 1)
stop("sozip_chunk_size must be length-1.", call. = FALSE)
stop("`sozip_chunk_size` must be length-1.", call. = FALSE)
opt <- c(opt, paste0("SOZIP_CHUNK_SIZE=", sozip_chunk_size))
}
if (!is.null(sozip_min_file_size)) {
if (length(sozip_min_file_size) > 1)
stop("sozip_min_file_size must be length-1.", call. = FALSE)
stop("`sozip_min_file_size` must be length-1.", call. = FALSE)
opt <- c(opt, paste0("SOZIP_MIN_FILE_SIZE=", sozip_min_file_size))
}
if (!is.null(num_threads)) {
if (length(num_threads) > 1)
stop("num_threads must be length-1.", call. = FALSE)
stop("`num_threads` must be length-1.", call. = FALSE)
opt <- c(opt, paste0("NUM_THREADS=", num_threads))
}
if (!is.null(content_type)) {
if (!is.character(content_type) || length(content_type) > 1)
stop("content_type must be a string.", call. = FALSE)
stop("`content_type` must be a string.", call. = FALSE)
opt <- c(opt, paste0("CONTENT_TYPE=", content_type))
}

Expand Down Expand Up @@ -225,7 +226,7 @@ addFilesInZip <- function(
getCreationOptions <- function(format, filter=NULL) {

if (!is.character(format) || length(format) > 1)
stop("format argument must be a string.", call.=FALSE)
stop("`format` must be a string.", call.=FALSE)

if (is.null(filter))
filter = "_all_"
Expand Down
2 changes: 1 addition & 1 deletion R/gdalraster.R
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@
#'
#' \code{$clearStatistics()}
#' Clear statistics. Only implemented for now in PAM supported datasets
#' (Peristable Auxiliary Metadata via .aux.xml file). GDAL >= 3.2.
#' (Persistable Auxiliary Metadata via .aux.xml file). GDAL >= 3.2.
#'
#' \code{$getHistogram(band, min, max, num_buckets, incl_out_of_range,
#' approx_ok)}\cr
Expand Down
2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Bindings to GDAL are implemented in the exposed C++ class [`GDALRaster`](https:/
* low-level I/O
* read/set color tables and raster attribute tables
* copy files/move/rename/delete datasets
* create/append to Seek-Optimized ZIP ([SOZip](https://sozip.org/))
* create/append to Seek-Optimized ZIP ([SOZip](https://github.com/sozip/sozip-spec))
* virtual raster (VRT) for virtual cropping, resampling, kernel filtering, mosaicing
* `gdalwarp` wrapper for reproject/resample/crop/mosaic
* coordinate transformation
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ supporting:
- low-level I/O
- read/set color tables and raster attribute tables
- copy files/move/rename/delete datasets
- create/append to Seek-Optimized ZIP ([SOZip](https://sozip.org/))
- create/append to Seek-Optimized ZIP
([SOZip](https://github.com/sozip/sozip-spec))
- virtual raster (VRT) for virtual cropping, resampling, kernel
filtering, mosaicing
- `gdalwarp` wrapper for reproject/resample/crop/mosaic
Expand Down
2 changes: 1 addition & 1 deletion man/GDALRaster-class.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion man/addFilesInZip.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions tests/testthat/test-GDALRaster-class.R
Original file line number Diff line number Diff line change
Expand Up @@ -273,17 +273,17 @@ test_that("get/set band color interpretation works", {
})

test_that("Int64 data type is detected", {
if (as.integer(gdal_version()[2]) >= 3050000) {
f <- system.file("extdata/int64.tif", package="gdalraster")
expect_warning(ds <- new(GDALRaster, f, TRUE))
expect_equal(ds$getDataTypeName(1), "Int64")
ds$close()
}
skip_if(as.integer(gdal_version()[2]) < 3050000)

f <- system.file("extdata/int64.tif", package="gdalraster")
expect_warning(ds <- new(GDALRaster, f, TRUE))
expect_equal(ds$getDataTypeName(1), "Int64")
ds$close()
})

test_that("get/set default RAT works", {
evt_file <- system.file("extdata/storml_evt.tif", package="gdalraster")
f <- paste0(tempdir(), "/", "storml_evt_tmp.tif")
f <- tempfile(fileext=".tif")
file.copy(evt_file, f)
ds <- new(GDALRaster, f, read_only=FALSE)
expect_true(is.null(ds$getDefaultRAT(band=1)))
Expand Down

0 comments on commit 2e03718

Please sign in to comment.