Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

source: start inclusion of DEAustralia products #1159

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
add new deaustralia data products
  • Loading branch information
M3nin0 committed Jun 16, 2024
commit 91e12828ec4296a0ecb77dec59b448f82ac7083c
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ Collate:
'api_source_bdc.R'
'api_source_cdse.R'
'api_source_deafrica.R'
'api_source_deaustralia.R'
'api_source_hls.R'
'api_source_local.R'
'api_source_mpc.R'
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ 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,deaustralia_cube)
S3method(.source_items_new,hls_cube)
S3method(.source_items_new,sdc_cube)
S3method(.source_items_new,usgs_cube)
Expand All @@ -184,6 +185,7 @@ 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,deaustralia_cube)
S3method(.source_items_tile,hls_cube)
S3method(.source_items_tile,sdc_cube)
S3method(.source_items_tile,usgs_cube)
Expand Down
49 changes: 49 additions & 0 deletions R/api_source_deaustralia.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# ---- source api ----
#' @title Create an items object in an DEAustralia cube
#' @keywords internal
#' @noRd
#' @description \code{.source_items_new()} this function is called to create
#' an items object. In case of Web services, this function is responsible for
#' making the Web requests to the server.
#' @param source Name of the STAC provider.
#' @param ... Other parameters to be passed for specific types.
#' @param collection Collection to be searched in the data source.
#' @param stac_query Query that follows the STAC protocol
#' @param tiles Selected tiles (optional)
#' @param platform Satellite platform (optional).
#' @return An object referring the images of a sits cube.
#' @export
.source_items_new.deaustralia_cube <- function(source, ...,
collection,
stac_query,
tiles = NULL,
platform = NULL) {
# Convert roi to bbox
roi <- .stac_intersects_as_bbox(stac_query)
stac_query[["params"]][["intersects"]] <- NULL
stac_query[["params"]][["bbox"]] <- roi$bbox
# making the request
items_info <- rstac::post_request(q = stac_query, ...)
.check_stac_items(items_info)
# if more than 2 times items pagination are found the progress bar
# is displayed
progress <- rstac::items_matched(items_info) >
2 * .conf("rstac_pagination_limit")
# check documentation mode
progress <- .check_documentation(progress)

# fetching all the metadata and updating to upper case instruments
items_info <- rstac::items_fetch(items = items_info, progress = progress)
# checks if the items returned any items
.check_stac_items(items_info)
return(items_info)
}

#' @keywords internal
#' @noRd
#' @export
.source_items_tile.deaustralia_cube <- function(source, ...,
items,
collection = NULL) {
rstac::items_reap(items, field = c("properties", "odc:region_code"))
}
Loading