Skip to content

Commit

Permalink
fix error in sits_mosaic
Browse files Browse the repository at this point in the history
  • Loading branch information
gilbertocamara committed Feb 21, 2025
1 parent 77d5a63 commit dd99d18
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 8 deletions.
18 changes: 16 additions & 2 deletions R/api_file.R
Original file line number Diff line number Diff line change
Expand Up @@ -127,20 +127,34 @@
)
}

#' @title Build a file path for a mosaic
#' @title Build a file path for a mosaic of derived cubes
#' @noRd
#' @param tile Tile of data cube
#' @param band Spectral band
#' @param version Version name
#' @param output_dir Directory where file will be saved
#' @returns File path for mosaic
.file_mosaic_name <- function(tile, band, version, output_dir) {
.file_mosaic_name_derived <- function(tile, band, version, output_dir) {
.file_path(
tile[["satellite"]], tile[["sensor"]], "MOSAIC",
.tile_start_date(tile), .tile_end_date(tile), band, version,
ext = "tif", output_dir = output_dir
)
}
#' @title Build a file path for a mosaic of raster cubes
#' @noRd
#' @param tile Tile of data cube
#' @param band Spectral band
#' @param version Version name
#' @param output_dir Directory where file will be saved
#' @returns File path for mosaic
.file_mosaic_name_raster <- function(tile, band, version, output_dir) {
.file_path(
tile[["satellite"]], tile[["sensor"]], "MOSAIC",
.tile_start_date(tile), band, version,
ext = "tif", output_dir = output_dir
)
}
#' @title Build a file path for a cropped file
#' @noRd
#' @param tile Tile of data cube
Expand Down
25 changes: 19 additions & 6 deletions R/api_mosaic.R
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@
multicores,
version,
progress) {
# check if cube is derived
if ("derived_cube" %in% class(cube))
derived_cube <- TRUE
else
derived_cube <- FALSE
# Create band date as jobs
band_date_cube <- .mosaic_split_band_date(cube)
# Get band configs from tile
Expand All @@ -109,12 +114,20 @@
base_tile <- .tile(cube)
# Update tile name
.tile_name(base_tile) <- "MOSAIC"
out_file <- .file_mosaic_name(
tile = base_tile,
band = .tile_bands(base_tile),
version = version,
output_dir = output_dir
)
if (derived_cube)
out_file <- .file_mosaic_name_derived(
tile = base_tile,
band = .tile_bands(base_tile),
version = version,
output_dir = output_dir
)
else
out_file <- .file_mosaic_name_raster(
tile = base_tile,
band = .tile_bands(base_tile),
version = version,
output_dir = output_dir
)
# Resume feature
if (.raster_is_valid(out_file, output_dir = output_dir)) {
if (.check_messages()) {
Expand Down

0 comments on commit dd99d18

Please sign in to comment.