|
428 | 428 | #' @keywords internal
|
429 | 429 | #' @noRd
|
430 | 430 | #' @return names associated to the chosen access key
|
431 |
| -.conf_names <- function(key) { |
| 431 | +.conf_names <- function(...) { |
| 432 | + key <- c(...) |
432 | 433 | res <- tryCatch(
|
433 | 434 | {
|
434 | 435 | names(sits_env$config[[key]])
|
@@ -928,41 +929,23 @@ NULL
|
928 | 929 | #' @param source Data source.
|
929 | 930 | #' @param collection Collection in the data source.
|
930 | 931 | #' @param band Band name
|
931 |
| -#' @param tile Tile |
932 | 932 | #' @details
|
933 | 933 | #' If the band is not found, a default value will be returned from config.
|
934 | 934 | #' If neither source nor collection entries are found in configuration file,
|
935 | 935 | #' an error is thrown.
|
936 | 936 | #' @returns A value in config.
|
937 |
| -.conf_eo_band <- function(source, collection, band, tile = NULL) { |
| 937 | +.conf_eo_band <- function(source, collection, band) { |
938 | 938 | # Format band name
|
939 | 939 | band <- .band_eo(band)
|
940 | 940 | # Return a default value if band does not exists in config
|
941 | 941 | if (!.conf_eo_band_exists(source, collection, band)) {
|
942 |
| - data_type <- "INT2S" |
943 |
| - # does the file exist? |
944 |
| - if (!purrr::is_null(tile)) { |
945 |
| - band_path <- .tile_path(tile, band) |
946 |
| - if (!purrr::is_null(band_path)) { |
947 |
| - rast <- terra::rast(band_path) |
948 |
| - data_type <- terra::datatype(rast) |
949 |
| - conf_band <- .conf("default_vales", data_type) |
950 |
| - } else { |
951 |
| - # file does not exist |
952 |
| - if (!.has(.conf("default_vales", band))) |
953 |
| - conf_band <- .conf("default_vales", band) |
954 |
| - else |
955 |
| - conf_band <- .conf("default_vales", "INT4S") |
956 |
| - } |
| 942 | + if (band %in% .conf_names("default_values", "eo_cube")) { |
| 943 | + return(.conf("default_values", "eo_cube", band)) |
957 | 944 | }
|
| 945 | + return(.conf("default_values", "eo_cube", "default")) |
958 | 946 | }
|
959 |
| - else { |
960 |
| - # Get band config value and return it |
961 |
| - conf_band <- .conf("sources", source, |
962 |
| - "collections", collection, |
963 |
| - "bands", band) |
964 |
| - } |
965 |
| - return(conf_band) |
| 947 | + # Get band config value and return it |
| 948 | + .conf("sources", source, "collections", collection, "bands", band) |
966 | 949 | }
|
967 | 950 | #' @title Config functions for derived_cube
|
968 | 951 | #' @noRd
|
|
0 commit comments