Skip to content

Commit

Permalink
fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
OldLipe committed Apr 29, 2024
2 parents 23993b2 + cd1b1c2 commit 41297ba
Show file tree
Hide file tree
Showing 160 changed files with 3,652 additions and 2,437 deletions.
2 changes: 2 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ Collate:
'api_mixture_model.R'
'api_ml_model.R'
'api_mosaic.R'
'api_opensearch.R'
'api_parallel.R'
'api_period.R'
'api_plot_time_series.R'
Expand All @@ -159,6 +160,7 @@ Collate:
'api_s2tile.R'
'api_samples.R'
'api_segments.R'
'api_select.R'
'api_sf.R'
'api_shp.R'
'api_signal.R'
Expand Down
8 changes: 5 additions & 3 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ S3method(.source_collection_access_test,stac_cube)
S3method(.source_collection_access_test,usgs_cube)
S3method(.source_cube,stac_cube)
S3method(.source_filter_tiles,"cdse_cube_sentinel-1-rtc")
S3method(.source_filter_tiles,"deafrica_cube_sentinel-1-rtc")
S3method(.source_filter_tiles,"mpc_cube_sentinel-1-grd")
S3method(.source_filter_tiles,stac_cube)
S3method(.source_item_get_bands,stac_cube)
Expand All @@ -150,6 +151,8 @@ S3method(.source_items_bands_select,stac_cube)
S3method(.source_items_cube,stac_cube)
S3method(.source_items_fid,stac_cube)
S3method(.source_items_new,"aws_cube_landsat-c2-l2")
S3method(.source_items_new,"deafrica_cube_sentinel-1-rtc")
S3method(.source_items_new,"deafrica_cube_sentinel-2-l2a")
S3method(.source_items_new,"mpc_cube_landsat-c2-l2")
S3method(.source_items_new,"mpc_cube_sentinel-1-grd")
S3method(.source_items_new,"mpc_cube_sentinel-1-rtc")
Expand All @@ -158,12 +161,13 @@ S3method(.source_items_new,aws_cube)
S3method(.source_items_new,bdc_cube)
S3method(.source_items_new,cdse_cube)
S3method(.source_items_new,deafrica_cube)
S3method(.source_items_new,deafrica_cube_s2_l2a)
S3method(.source_items_new,hls_cube)
S3method(.source_items_new,sdc_cube)
S3method(.source_items_new,usgs_cube)
S3method(.source_items_tile,"aws_cube_landsat-c2-l2")
S3method(.source_items_tile,"cdse_cube_sentinel-1-rtc")
S3method(.source_items_tile,"deafrica_cube_rainfall-chirps-daily")
S3method(.source_items_tile,"deafrica_cube_rainfall-chirps-monthly")
S3method(.source_items_tile,"mpc_cube_landsat-c2-l2")
S3method(.source_items_tile,"mpc_cube_sentinel-1-grd")
S3method(.source_items_tile,"mpc_cube_sentinel-1-rtc")
Expand All @@ -172,8 +176,6 @@ S3method(.source_items_tile,aws_cube)
S3method(.source_items_tile,bdc_cube)
S3method(.source_items_tile,cdse_cube)
S3method(.source_items_tile,deafrica_cube)
S3method(.source_items_tile,deafrica_cube_rainfall_chirps_daily)
S3method(.source_items_tile,deafrica_cube_rainfall_chirps_monthly)
S3method(.source_items_tile,hls_cube)
S3method(.source_items_tile,sdc_cube)
S3method(.source_items_tile,usgs_cube)
Expand Down
2 changes: 1 addition & 1 deletion R/api_accessors.R
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
paste0("EPSG:", .compact(x))
}
} else {
stop("invalid crs value")
stop(.conf("messages", ".as_crs"))
}
}
#' @title Return CRS from a spatial data structure
Expand Down
12 changes: 5 additions & 7 deletions R/api_accuracy.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
#' @return A tibble with predicted and reference values.
.accuracy_pred_ref <- function(class) {
# retrieve the predicted values
pred <- unlist(purrr::map(class$predicted, function(r) r$class))
pred <- unlist(purrr::map(class[["predicted"]], function(r) r[["class"]]))
# retrieve the reference labels
ref <- class$label
ref <- class[["label"]]
# does the input data contains valid reference labels?
.check_labels(ref)
# build the tibble
Expand Down Expand Up @@ -52,11 +52,9 @@
# are in the validation file
diff_classes <- setdiff(rownames(error_matrix), names(area))
if (length(diff_classes) > 0 &&
length(diff_classes) < length(rownames(error_matrix))) {
warning(
paste("The classified cube does not have all the classes in the",
"validation file."),
call. = FALSE
length(diff_classes) < length(rownames(error_matrix))) {
warning(.conf("messages", ".accuracy_area_assess"),
call. = FALSE
)
# Create a numeric vector with zeros
vec_areas <- rep(0, length(diff_classes))
Expand Down
13 changes: 7 additions & 6 deletions R/api_apply.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
#' @param fn Function to be applied.
#' @return Tibble where function has been applied.
.apply <- function(data, col, fn, ...) {
.check_set_caller(".apply")
# pre-condition
.check_chr_within(col,
within = names(data),
msg = "invalid column name"
.check_chr_within(
col,
within = names(data)
)
# select data do unpack
x <- data[col]
Expand Down Expand Up @@ -214,15 +215,15 @@
.apply_capture_expression <- function(...) {
# Capture dots as a list of quoted expressions
list_expr <- lapply(substitute(list(...), env = environment()),
unlist,
recursive = FALSE
unlist,
recursive = FALSE
)[-1]

# Check bands names from expression
.check_expression(list_expr)

# Get out band
out_band <- toupper(gsub("_", "-", names(list_expr)))
out_band <- toupper(gsub("_", "-", names(list_expr), fixed = TRUE))
names(list_expr) <- out_band

return(list_expr)
Expand Down
16 changes: 9 additions & 7 deletions R/api_band.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
.band_rename.sits <- function(x, bands) {
data_bands <- sits_bands(x)
# pre-condition
.check_chr(bands,
.check_chr(
bands,
allow_empty = FALSE, len_min = length(data_bands),
len_max = length(data_bands)
)
Expand All @@ -43,7 +44,8 @@
.band_rename.raster_cube <- function(x, bands) {
data_bands <- sits_bands(x)
# pre-condition
.check_chr(bands,
.check_chr(
bands,
allow_empty = FALSE,
len_min = length(data_bands),
len_max = length(data_bands)
Expand All @@ -62,12 +64,12 @@
new_bands[data_bands] <- toupper(bands)
colnames(x) <- unname(new_bands)

x <- tidyr::pivot_longer(x,
x <- tidyr::pivot_longer(
x,
cols = toupper(bands),
names_to = "band",
values_to = "path"
)

return(x)
})
}
Expand All @@ -84,23 +86,23 @@
#' @param band band name (may be lower or upper case)
#' @return band name in upper case
.band_eo <- function(band) {
gsub("_", "-", toupper(band))
gsub("_", "-", toupper(band), fixed = TRUE)
}
#' @title Convert band names for derived cubes
#' @name .band_derived
#' @noRd
#' @param band band name (may be lower or upper case)
#' @return band name in lower case
.band_derived <- function(band) {
gsub("_", "-", tolower(band))
gsub("_", "-", tolower(band), fixed = TRUE)
}
#' @title Convert band names for time series
#' @name .band_samples
#' @noRd
#' @param band band name (may be lower or upper case)
#' @return band name in upper case
.band_samples <- function(band) {
gsub("_", "-", toupper(band))
gsub("_", "-", toupper(band), fixed = TRUE)
}
#' @title Convert band names for data cube
#' @name .band_set_case
Expand Down
8 changes: 4 additions & 4 deletions R/api_bbox.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#'
.bbox_equal <- function(bbox1, bbox2, tolerance = 0) {
.is_eq(unlist(bbox1[.bbox_cols]), unlist(bbox2[.bbox_cols]),
tolerance = tolerance
tolerance = tolerance
)
}
#' @title Bounding box API
Expand Down Expand Up @@ -66,15 +66,15 @@ NULL
} else if (.is_point(x)) {
"point"
} else {
stop("cannot extract bbox from object of class ", class(x))
stop(.conf("messages", ".bbox_type"), class(x))
}
}
#' @title Switch bbox type
#' @noRd
#' @returns One of the arguments passed in `...` according to a bbox type.
.bbox_switch <- function(x, ...) {
switch(.bbox_type(x),
...
...
)
}
#' @title Extract a bbox
Expand Down Expand Up @@ -233,6 +233,6 @@ NULL
# Convert WKT to sf CRS object
crs_sf <- sf::st_crs(wkt_crs)
# Convert sf CRS object to PROJ4 string
proj4string <- crs_sf$proj4string
proj4string <- crs_sf[["proj4string"]]
return(proj4string)
}
Loading

0 comments on commit 41297ba

Please sign in to comment.