Skip to content

Commit dd99d18

Browse files
fix error in sits_mosaic
1 parent 77d5a63 commit dd99d18

File tree

2 files changed

+35
-8
lines changed

2 files changed

+35
-8
lines changed

R/api_file.R

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,20 +127,34 @@
127127
)
128128
}
129129

130-
#' @title Build a file path for a mosaic
130+
#' @title Build a file path for a mosaic of derived cubes
131131
#' @noRd
132132
#' @param tile Tile of data cube
133133
#' @param band Spectral band
134134
#' @param version Version name
135135
#' @param output_dir Directory where file will be saved
136136
#' @returns File path for mosaic
137-
.file_mosaic_name <- function(tile, band, version, output_dir) {
137+
.file_mosaic_name_derived <- function(tile, band, version, output_dir) {
138138
.file_path(
139139
tile[["satellite"]], tile[["sensor"]], "MOSAIC",
140140
.tile_start_date(tile), .tile_end_date(tile), band, version,
141141
ext = "tif", output_dir = output_dir
142142
)
143143
}
144+
#' @title Build a file path for a mosaic of raster cubes
145+
#' @noRd
146+
#' @param tile Tile of data cube
147+
#' @param band Spectral band
148+
#' @param version Version name
149+
#' @param output_dir Directory where file will be saved
150+
#' @returns File path for mosaic
151+
.file_mosaic_name_raster <- function(tile, band, version, output_dir) {
152+
.file_path(
153+
tile[["satellite"]], tile[["sensor"]], "MOSAIC",
154+
.tile_start_date(tile), band, version,
155+
ext = "tif", output_dir = output_dir
156+
)
157+
}
144158
#' @title Build a file path for a cropped file
145159
#' @noRd
146160
#' @param tile Tile of data cube

R/api_mosaic.R

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@
9292
multicores,
9393
version,
9494
progress) {
95+
# check if cube is derived
96+
if ("derived_cube" %in% class(cube))
97+
derived_cube <- TRUE
98+
else
99+
derived_cube <- FALSE
95100
# Create band date as jobs
96101
band_date_cube <- .mosaic_split_band_date(cube)
97102
# Get band configs from tile
@@ -109,12 +114,20 @@
109114
base_tile <- .tile(cube)
110115
# Update tile name
111116
.tile_name(base_tile) <- "MOSAIC"
112-
out_file <- .file_mosaic_name(
113-
tile = base_tile,
114-
band = .tile_bands(base_tile),
115-
version = version,
116-
output_dir = output_dir
117-
)
117+
if (derived_cube)
118+
out_file <- .file_mosaic_name_derived(
119+
tile = base_tile,
120+
band = .tile_bands(base_tile),
121+
version = version,
122+
output_dir = output_dir
123+
)
124+
else
125+
out_file <- .file_mosaic_name_raster(
126+
tile = base_tile,
127+
band = .tile_bands(base_tile),
128+
version = version,
129+
output_dir = output_dir
130+
)
118131
# Resume feature
119132
if (.raster_is_valid(out_file, output_dir = output_dir)) {
120133
if (.check_messages()) {

0 commit comments

Comments
 (0)