Skip to content

Commit

Permalink
Merge pull request #1208 from M3nin0/fix/regularize-deletion
Browse files Browse the repository at this point in the history
fix roi/tile validation and file deletion
  • Loading branch information
gilbertocamara authored Sep 2, 2024
2 parents 972f8ba + 0f12c1b commit a6aa810
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 3 additions & 4 deletions R/api_gdalcubes.R
Original file line number Diff line number Diff line change
Expand Up @@ -477,15 +477,15 @@
.check_set_caller(".gc_regularize")
# require gdalcubes package
.check_require_packages("gdalcubes")

# prepare temp_output_dir
temp_output_dir <- file.path(output_dir, ".sits")
if (!dir.exists(temp_output_dir)) {
dir.create(temp_output_dir, recursive = TRUE)
}
# set to delete all files in temp dir
on.exit(unlink(list.files(temp_output_dir, full.names = TRUE)), add = TRUE)
# timeline of intersection
timeline <- .gc_get_valid_timeline(cube, period = period)

# filter only intersecting tiles
if (.has(roi)) {
cube <- .cube_filter_spatial(cube, roi = roi)
Expand All @@ -502,8 +502,7 @@
)
# start processes
.parallel_start(workers = multicores)
on.exit(.parallel_stop())

on.exit(.parallel_stop(), add = TRUE)
# does a local cube exist
local_cube <- tryCatch(
{
Expand Down
4 changes: 3 additions & 1 deletion R/sits_regularize.R
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ sits_regularize.raster_cube <- function(cube, ...,
output_dir <- .file_path_expand(output_dir)
.check_output_dir(output_dir)
# check for ROI and tiles
.check_roi_tiles(roi, tiles)
if (!is.null(roi) || !is.null(tiles)) {
.check_roi_tiles(roi, tiles)
}
# check multicores
.check_num_parameter(multicores, min = 1, max = 2048)
# check progress
Expand Down

0 comments on commit a6aa810

Please sign in to comment.