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

docs: work on manual #177

Merged
merged 10 commits into from
Nov 7, 2024
8 changes: 4 additions & 4 deletions R/client.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#' Initialise an EMODnet WFS client
#' @description Initialise an EMODnet WFS client
#'
#' @title Connect to a data source (service)
#'
#' @param service the EMODnet OGC WFS service name.
#' For available services, see [`emodnet_wfs()`].
Expand All @@ -13,10 +15,8 @@
#' @export
#'
#' @seealso `WFSClient` in package `ows4R`.
#' @examples
#' \dontrun{
#' @examplesIf interactive()
#' wfs <- emodnet_init_wfs_client(service = "bathymetry")
#' }
emodnet_init_wfs_client <- function(service,
service_version = NULL,
logger = NULL) {
Expand Down
6 changes: 4 additions & 2 deletions R/emodnet_wfs.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
stringsAsFactors = FALSE
)
}
#' Available EMODnet Web Feature Services
#' @description Available EMODnet Web Feature Services
#'
#' @title Which data sources (services) are available?
#'
#' @return Tibble of available EMODnet Web Feature Services
#'
#' @examples
#' @examplesIf interactive()
#' emodnet_wfs()
#' @export
emodnet_wfs <- memoise::memoise(.emodnet_wfs)
13 changes: 8 additions & 5 deletions R/info.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
service_url = get_service_name(wfs$getUrl()),
layer_name = purrr::map_chr(wfs_layers, ~ .x$getName()),
title = purrr::map_chr(wfs_layers, ~ .x$getTitle()),
abstract = purrr::map_chr(wfs_layers, ~ get_abstract_null(.x)),

Check warning on line 17 in R/info.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/info.R,line=17,col=43,[unnecessary_lambda_linter] Pass get_abstract_null directly as a symbol to map_chr() instead of wrapping it in an unnecessary anonymous function. For example, prefer purrr::map(DF, sum) to purrr::map(DF, ~sum(.x)).
class = purrr::map_chr(wfs_layers, ~ .x$getClassName()),
format = purrr::map_chr(wfs_layers, guess_layer_format)
) %>%
Expand Down Expand Up @@ -65,7 +65,7 @@
title = purrr::map_chr(capabilities$getFeatureTypes(), ~ .x$getTitle()),
abstract = purrr::map_chr(
capabilities$getFeatureTypes(),
~ get_abstract_null(.x)

Check warning on line 68 in R/info.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/info.R,line=68,col=7,[unnecessary_lambda_linter] Pass get_abstract_null directly as a symbol to map_chr() instead of wrapping it in an unnecessary anonymous function. For example, prefer purrr::map(DF, sum) to purrr::map(DF, ~sum(.x)).
),
class = purrr::map_chr(capabilities$getFeatureTypes(), ~ .x$getClassName()),
format = purrr::map_chr(capabilities$getFeatureTypes(), guess_layer_format)
Expand All @@ -76,26 +76,29 @@
layer_name = strsplit(layer_name, ":", fixed = TRUE)[[1]][2]
)
}
#' Get WFS available layer information
#' @description Get WFS available layer information
#'
#' @title Metadata about data available from the different services:
#' data (layers) from a data source (service),
#' metadata on layers from a service,
#' metadata on layers from all services.
#'
#' @param wfs A `WFSClient` R6 object with methods for interfacing an
#' OGC Web Feature Service.
#' OGC Web Feature Service. From [`emodnet_init_wfs_client()`].
#' @inheritParams emodnet_init_wfs_client
#' @return a tibble containing metadata on each layer available from the
#' service.
#' @export
#' @describeIn emodnet_get_wfs_info Get info on all layers from
#' an EMODnet WFS service.
#' @examples
#' \dontrun{
#' @examplesIf interactive()
#' emodnet_get_wfs_info(service = "bathymetry")
#' # Query a wfs object
#' wfs_bio <- emodnet_init_wfs_client("biology")
#' emodnet_get_wfs_info(wfs_bio)
#' # Get info for specific layers from wfs object
#' layers <- c("mediseh_zostera_m_pnt", "mediseh_posidonia_nodata")
#' emodnet_get_layer_info(wfs = wfs_bio, layers = layers)
#' }
emodnet_get_wfs_info <- memoise::memoise(.emodnet_get_wfs_info)

#' @describeIn emodnet_get_wfs_info Get metadata on all layers and all available
Expand Down
43 changes: 24 additions & 19 deletions R/layer_attributes.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@
#'
#' @return output of `summary()` on the attributes (variables) in a given layer
#' for a given service.
#' @family attributes
#' @export
#'
#' @examples
#' \dontrun{
#' @examplesIf interactive()
#' layer_attributes_summarise(
#' service = "biology",
#' layer = "mediseh_zostera_m_pnt"
#' )
#' }
layer_attributes_summarise <- function(wfs = NULL,
service = NULL,
service_version = NULL,
Expand All @@ -33,22 +32,23 @@ layer_attributes_summarise <- function(wfs = NULL,
)
}

#' Get layer attribute description
#' @description Get layer attribute description
#'
#' @title Variables available in a dataset (layer) from a data source (service).
#'
#' @inheritParams emodnet_init_wfs_client
#' @inheritParams emodnet_get_wfs_info
#' @inheritParams layer_attributes_summarise
#'
#' @return data.frame containing layer attribute descriptions (metadata).
#' @family attributes
#' @export
#'
#' @examples
#' \dontrun{
#' @examplesIf interactive()
#' layer_attribute_descriptions(
#' service = "biology",
#' layer = "mediseh_zostera_m_pnt"
#' )
#' }
layer_attribute_descriptions <- function(wfs = NULL,
service = NULL,
service_version = NULL, layer) {
Expand All @@ -64,22 +64,23 @@ layer_attribute_descriptions <- function(wfs = NULL,
}


#' Get names of layer attributes
#' Names of variables (attributes) available from a dataset (layer)
#' in a data source (service).
#'
#' @inheritParams emodnet_init_wfs_client
#' @inheritParams emodnet_get_wfs_info
#' @inheritParams layer_attributes_summarise
#'
#' @family attributes
#'
#' @return character vector of layer attribute (variable) names.
#' @export
#'
#' @examples
#' \dontrun{
#' @examplesIf interactive()
#' layer_attributes_get_names(
#' service = "biology",
#' layer = "mediseh_zostera_m_pnt"
#' )
#' }
layer_attributes_get_names <- function(wfs = NULL,
service = NULL,
service_version = NULL,
Expand All @@ -96,7 +97,10 @@ layer_attributes_get_names <- function(wfs = NULL,
)$name
}

#' Inspect layer attributes
#' @description Inspect layer attributes
#'
#' @title Summary of individual variable (attribute) in a dataset (layer) from a
#' data source (service).
#'
#' @inheritParams layer_attributes_summarise
#' @param attribute character string, name of layer attribute (variable). Use
Expand All @@ -107,17 +111,16 @@ layer_attributes_get_names <- function(wfs = NULL,
#' @return Detailed summary of individual attribute (variable). Particularly
#' useful for inspecting
#' factor or character variable levels or unique values.
#' @family attributes
#' @export
#'
#' @examples
#' \dontrun{
#' @examplesIf interactive()
#' wfs <- emodnet_init_wfs_client(service = "biology")
#' layer_attributes_get_names(wfs, layer = "mediseh_zostera_m_pnt")
#' layer_attribute_inspect(
#' wfs, layer = "mediseh_zostera_m_pnt",
#' attribute = "country"
#' )
#' }
layer_attribute_inspect <- function(wfs = NULL,
service = NULL,
service_version = NULL,
Expand Down Expand Up @@ -161,7 +164,10 @@ layer_attribute_inspect <- function(wfs = NULL,
)
}

#' Get layer attribute values tibble
#' @description Get layer attribute values tibble
#'
#' @title Possible values of variables (attributes) in a dataset (layer)
#' from a data source (service).
#'
#' @inheritParams emodnet_init_wfs_client
#' @inheritParams emodnet_get_wfs_info
Expand All @@ -174,12 +180,11 @@ layer_attribute_inspect <- function(wfs = NULL,
#' useful for inspecting attribute values and constructing feature filters
#' for more
#' targeted and faster layer download.
#' @family attributes
#' @export
#'
#' @examples
#' \dontrun{
#' @examplesIf interactive()
#' layer_attributes_tbl(service = "biology", layer = "mediseh_zostera_m_pnt")
#' }
layer_attributes_tbl <- function(wfs = NULL,
service = NULL,
service_version = NULL, layer) {
Expand Down
2 changes: 1 addition & 1 deletion R/layers.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#' Get EMODnet WFS layers
#' Get EMODnet WFS datasets (layers)
#'
#' Performs an WFS getFeature request for layers from a `wfs` object or
#' specified EMODnet Service. Filtering
Expand Down Expand Up @@ -160,7 +160,7 @@
# if reduce_layers = T, reduce to single sf --------------------------------
if (reduce_layers) {
tryCatch(
out <- purrr::reduce(out, rbind),

Check warning on line 163 in R/layers.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/layers.R,line=163,col=7,[implicit_assignment_linter] Avoid implicit assignments in function calls. For example, instead of `if (x <- 1L) { ... }`, write `x <- 1L; if (x) { ... }`.
error = function(e) {
cli::cli_abort(
c(
Expand Down
4 changes: 2 additions & 2 deletions man/emodnet_get_layers.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions man/emodnet_get_wfs_info.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions man/emodnet_init_wfs_client.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion man/emodnet_wfs.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 11 additions & 3 deletions man/layer_attribute_descriptions.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 12 additions & 3 deletions man/layer_attribute_inspect.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading