From cdd158eea773f4f1df3e92eda986b6814433a965 Mon Sep 17 00:00:00 2001 From: Rolf Simoes Date: Thu, 18 Jul 2024 20:00:20 +0200 Subject: [PATCH 1/3] Fix limit parameter wrong type --- NEWS.md | 4 ++++ R/parse-utils.R | 5 ++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/NEWS.md b/NEWS.md index d2e5ae4a..7b6e8f45 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,9 @@ # rstac (development version) +# rstac 1.0.1 (Released 2024-07-18) + +* Fix `limit` parameter as integer type in `stac_search()` and `items()` + # rstac 1.0.0 (Released 2024-02-14) * Add support to static catalogs; diff --git a/R/parse-utils.R b/R/parse-utils.R index c8652beb..3e60c757 100644 --- a/R/parse-utils.R +++ b/R/parse-utils.R @@ -45,9 +45,8 @@ .parse_limit <- function(limit) { if (length(limit) != 1) .error("Parameter `limit` must be a single value.") - limit <- as.character(limit) - limit_int <- suppressWarnings(as.integer(limit)) - if (any(is.na(as.integer(limit))) || as.character(limit_int) != limit) + limit <- suppressWarnings(as.integer(limit)) + if (is.na(limit)) .error("Param `limit` must be an integer.") return(limit) } From af369e54358d607359338a1f289d746689e9a261 Mon Sep 17 00:00:00 2001 From: Rolf Simoes Date: Thu, 18 Jul 2024 20:27:49 +0200 Subject: [PATCH 2/3] Improve documentation --- NEWS.md | 3 +++ R/assets-funs.R | 5 ++++- R/ext_filter.R | 6 ++++++ R/items-funs.R | 11 +++++++++-- man/assets_functions.Rd | 5 ++++- man/ext_filter.Rd | 9 +++++++++ man/items_functions.Rd | 10 ++++++++-- man/preview_plot.Rd | 2 +- 8 files changed, 44 insertions(+), 7 deletions(-) diff --git a/NEWS.md b/NEWS.md index 7b6e8f45..f6ddb106 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,7 +2,10 @@ # rstac 1.0.1 (Released 2024-07-18) +* Add support to `jpg` in `preview_plot()` function (#161) +* Fix variable in filter expressions (non-standard evaluation) (#160) * Fix `limit` parameter as integer type in `stac_search()` and `items()` +* Improve `items_reap()` documentation (#152) # rstac 1.0.0 (Released 2024-02-14) diff --git a/R/assets-funs.R b/R/assets-funs.R index e35d0a47..4fb4e66b 100644 --- a/R/assets-funs.R +++ b/R/assets-funs.R @@ -91,7 +91,10 @@ #' Multiple expressions are combine with `AND` operator. Expressions can #' use `asset` helper functions (i.e. `asset_key()`, `asset_eo_bands()`, #' and `asset_raster_bands()`). Multiple expressions are combined with -#' `AND` operator. +#' `AND` operator. `assets_select()` uses non-standard evaluation to evaluate +#' its expressions. That means users must escape any variable or call to +#' be able to use them in the expressions. The escape is done by using +#' `double-curly-braces`, i.e., `{{variable}}`. #' #' **WARNING:** Errors in the evaluation of expressions are #' considered as `FALSE`. diff --git a/R/ext_filter.R b/R/ext_filter.R index 6c3bac55..92e49051 100644 --- a/R/ext_filter.R +++ b/R/ext_filter.R @@ -36,6 +36,12 @@ #' to CQL2 expressions. The following topics describe the correspondences #' between `rstac` expressions and CQL2 operators. #' +#' ## Non-standard evaluation +#' - `ext_filter()` uses non-standard evaluation to evaluate its expressions. +#' That means users must escape any variable or call to be able to use them +#' in the expressions. The escape is done by using `double-curly-braces`, +#' i.e., `{{variable}}`. +#' #' ## Standard comparison operators #' - `==`, `>=`, `<=`, `>`, `<`, and `!=` operators correspond to #' `=`, `>=`, `<=`, `>`, `<`, and `<>` in CQL2, respectively. diff --git a/R/items-funs.R b/R/items-funs.R index 87338ef5..f5bf6041 100644 --- a/R/items-funs.R +++ b/R/items-funs.R @@ -95,8 +95,15 @@ #' methods, such as [add_headers][httr::add_headers] or #' [set_cookies][httr::set_cookies]. #' -#' \item `items_filter()`: ellipsis is used to pass logical -#' expressions to be evaluated against a `doc_item` field as filter criteria. +#' \item `items_filter()`: ellipsis is used to pass logical expressions to +#' be evaluated against a `doc_item` field as filter criteria. Expressions +#' must be evaluated as a logical value where `TRUE` selects the item +#' and `FALSE` discards it. Multiple expressions are combine with `AND` +#' operator. `items_filter()` uses non-standard evaluation to evaluate +#' its expressions. That means users must escape any variable or call to +#' be able to use them in the expressions. The escape is done by using +#' `double-curly-braces`, i.e., `{{variable}}`. + #' #' **WARNING:** the evaluation of filter expressions changed in `rstac` 0.9.2. #' Older versions of `rstac` used `properties` field to evaluate filter diff --git a/man/assets_functions.Rd b/man/assets_functions.Rd index 936bc29c..416470d0 100644 --- a/man/assets_functions.Rd +++ b/man/assets_functions.Rd @@ -218,7 +218,10 @@ a logical value where \code{TRUE} selects the asset and \code{FALSE} discards it Multiple expressions are combine with \code{AND} operator. Expressions can use \code{asset} helper functions (i.e. \code{asset_key()}, \code{asset_eo_bands()}, and \code{asset_raster_bands()}). Multiple expressions are combined with -\code{AND} operator. +\code{AND} operator. \code{assets_select()} uses non-standard evaluation to evaluate +its expressions. That means users must escape any variable or call to +be able to use them in the expressions. The escape is done by using +\code{double-curly-braces}, i.e., \code{{{variable}}}. \strong{WARNING:} Errors in the evaluation of expressions are considered as \code{FALSE}. diff --git a/man/ext_filter.Rd b/man/ext_filter.Rd index e57b61d6..8e29bbef 100644 --- a/man/ext_filter.Rd +++ b/man/ext_filter.Rd @@ -56,6 +56,15 @@ To allow users to express filter criteria in R language, \code{rstac} takes advantage of the abstract syntax tree (AST) to translate R expressions to CQL2 expressions. The following topics describe the correspondences between \code{rstac} expressions and CQL2 operators. +\subsection{Non-standard evaluation}{ +\itemize{ +\item \code{ext_filter()} uses non-standard evaluation to evaluate its expressions. +That means users must escape any variable or call to be able to use them +in the expressions. The escape is done by using \code{double-curly-braces}, +i.e., \code{{{variable}}}. +} +} + \subsection{Standard comparison operators}{ \itemize{ \item \code{==}, \code{>=}, \code{<=}, \code{>}, \code{<}, and \code{!=} operators correspond to diff --git a/man/items_functions.Rd b/man/items_functions.Rd index 1df1aa96..b447e5c6 100644 --- a/man/items_functions.Rd +++ b/man/items_functions.Rd @@ -292,8 +292,14 @@ additional \code{httr} options to \link[httr:GET]{GET} or \link[httr:POST]{POST} methods, such as \link[httr:add_headers]{add_headers} or \link[httr:set_cookies]{set_cookies}. -\item \code{items_filter()}: ellipsis is used to pass logical -expressions to be evaluated against a \code{doc_item} field as filter criteria. +\item \code{items_filter()}: ellipsis is used to pass logical expressions to +be evaluated against a \code{doc_item} field as filter criteria. Expressions +must be evaluated as a logical value where \code{TRUE} selects the item +and \code{FALSE} discards it. Multiple expressions are combine with \code{AND} +operator. \code{items_filter()} uses non-standard evaluation to evaluate +its expressions. That means users must escape any variable or call to +be able to use them in the expressions. The escape is done by using +\code{double-curly-braces}, i.e., \code{{{variable}}}. \strong{WARNING:} the evaluation of filter expressions changed in \code{rstac} 0.9.2. Older versions of \code{rstac} used \code{properties} field to evaluate filter diff --git a/man/preview_plot.Rd b/man/preview_plot.Rd index 4ce4a078..96ead0c5 100644 --- a/man/preview_plot.Rd +++ b/man/preview_plot.Rd @@ -15,5 +15,5 @@ A rastergrob grob from package \code{grid}. \description{ This is a helper function to plot preview assets (e.g. quicklook, thumbnail, rendered_preview). -Currently, only png, jpeg and jpg formats are supported. +Currently, only png and jpeg formats are supported. } From ec49751e7b8848b13e31431cd70e94e5b1f440ad Mon Sep 17 00:00:00 2001 From: Rolf Simoes Date: Thu, 18 Jul 2024 20:52:09 +0200 Subject: [PATCH 3/3] Remove knitr vignettes --- DESCRIPTION | 1 - 1 file changed, 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 85f91ad5..37890339 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -88,4 +88,3 @@ Collate: 'rstac.R' 'rstac-funs.R' Roxygen: list(markdown = TRUE) -VignetteBuilder: knitr