diff --git a/DESCRIPTION b/DESCRIPTION index 1e57fc92dedbfb63b8a0f39fa10c832b114f48d7..7b1d8a11bf8f3dd2d3497dd7a7a33b6c3cea1a0d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -17,6 +17,6 @@ Imports: urltools RoxygenNote: 7.1.1 Roxygen: list(markdown = TRUE) -Suggests: +Suggests: testthat (>= 3.0.0) Config/testthat/edition: 3 diff --git a/NAMESPACE b/NAMESPACE index 8342d3c0907d387b33a93bf72ea0f7a28b2beee9..ea72a59a1710decd4aeeea4a6e6b286d5d252ba2 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -7,6 +7,8 @@ export(get_hydrometrie_sites) export(get_hydrometrie_stations) export(get_indicateurs_services_communes) export(get_indicateurs_services_indicateurs) +export(get_niveaux_nappes_chroniques) +export(get_niveaux_nappes_chroniques_tr) export(get_niveaux_nappes_stations) export(get_prelevements_chroniques) export(get_prelevements_ouvrages) diff --git a/R/get_niveaux_nappes_chroniques.R b/R/get_niveaux_nappes_chroniques.R new file mode 100644 index 0000000000000000000000000000000000000000..33f07a2285f17bf10694da8b4620b49b22b850ff --- /dev/null +++ b/R/get_niveaux_nappes_chroniques.R @@ -0,0 +1,30 @@ +#' Retrieve piezometric archived time series from API "Piézométrie" +#' +#' See the API documentation for available filter parameters: \url{https://hubeau.eaufrance.fr/page/api-piezometrie} +#' +#' @template param_get_common +#' +#' @return a [tibble::tibble] with all available parameters in columns and one row by time step and by station. +#' @export +#' +#' @examples +#' # Retrieve the archived observed piezometric level at station '07548X0009/F' (old BSS identifier) +#' # for the year 2020 +#' df <- get_niveaux_nappes_chroniques(list(code_bss = "07548X0009/F", +#' date_debut_mesure = "2020-01-01", +#' date_fin_mesure = "2020-12-31")) +#' +#' # Plot the water elevation (NGF) +#' plot(as.POSIXct(df$date_mesure), df$niveau_nappe_eau, type = "l") +#' +get_niveaux_nappes_chroniques <- function(params, + cfg = config::get(file = system.file("config.yml", + package = "hubeau"))) { + l <- doApiQuery( + api = "niveaux_nappes", + operation = "chroniques", + params = params, + cfg = cfg + ) + convert_list_to_tibble(l) +} diff --git a/R/get_niveaux_nappes_chroniques_tr.R b/R/get_niveaux_nappes_chroniques_tr.R new file mode 100644 index 0000000000000000000000000000000000000000..390b70160a13a257b436cecc3958764f5299ceaa --- /dev/null +++ b/R/get_niveaux_nappes_chroniques_tr.R @@ -0,0 +1,26 @@ +#' Retrieve piezometric "real time" chroniques from API "Piézométrie" +#' +#' See the API documentation for available filter parameters: \url{https://hubeau.eaufrance.fr/page/api-piezometrie} +#' +#' @template param_get_common +#' +#' @return a [tibble::tibble] with all available parameters in columns and one row by time step and by station. +#' @export +#' +#' @examples +#' # For retrieving the last real time observed piezometric level at station 'BSS001VZGZ' (new BSS identifier) +#' df <- get_niveaux_nappes_chroniques_tr(list(bss_id = "BSS001VZGZ")) +#' +#' # Plot the water elevation (NGF) +#' plot(as.POSIXct(df$date_mesure), df$niveau_eau_ngf, type = "l") +get_niveaux_nappes_chroniques_tr <- function(params, + cfg = config::get(file = system.file("config.yml", + package = "hubeau"))) { + l <- doApiQuery( + api = "niveaux_nappes", + operation = "chroniques_tr", + params = params, + cfg = cfg + ) + convert_list_to_tibble(l) +} diff --git a/R/get_niveaux_nappes_stations.R b/R/get_niveaux_nappes_stations.R index e8884ee752a060323a40df98ba755500c0c34bb3..5da5c1b842d583bb87651aee3b51f4da7683b801 100644 --- a/R/get_niveaux_nappes_stations.R +++ b/R/get_niveaux_nappes_stations.R @@ -8,7 +8,7 @@ #' @export #' #' @examples -#' # For retrieving the hydrometric stations in the department of Aube +#' # Retrieve the hydrometric stations in the department of Aube #' get_niveaux_nappes_stations(list(code_departement = "10")) #' get_niveaux_nappes_stations <- function(params, cfg = config::get(file = system.file("config.yml", diff --git a/inst/config.yml b/inst/config.yml index 9d15239d4500268cf329f47161ab4af7460bf680..a88f2f77f32df5bd1cc26cef6388796a282f4d0c 100644 --- a/inst/config.yml +++ b/inst/config.yml @@ -153,6 +153,26 @@ default: niveaux_nappes: path: v1/niveaux_nappes operations: + chroniques: + path: chroniques + fields: + - code_bss + - date_debut_mesure + - date_fin_mesure + - fields + chroniques_tr: + path: chroniques_tr + fields: + - bbox + - bss_id + - code_bss + - date_debut_mesure + - date_fin_mesure + - fields + - niveau_ngf_max + - niveau_ngf_min + - profondeur_max + - profondeur_min stations: path: stations fields: @@ -166,34 +186,3 @@ default: - date_recherche - fields - srid - sites: - path: referentiel/sites - fields: - - bbox - - code_commune_site - - code_cours_eau - - code_departement - - code_region - - code_site - - code_troncon_hydro_site - - code_zone_hydro_site - - distance - - fields - - latitude - - libelle_cours_eau - - libelle_site - - longitude - observations_tr: - path: observations_tr - fields: - - bbox - - code_entite - - cursor - - date_debut_obs - - date_fin_obs - - distance - - fields - - grandeur_hydro - - latitude - - longitude - - timestep diff --git a/man/get_niveaux_nappes_chroniques.Rd b/man/get_niveaux_nappes_chroniques.Rd new file mode 100644 index 0000000000000000000000000000000000000000..36664129eabfc611414a17146420400140366a1c --- /dev/null +++ b/man/get_niveaux_nappes_chroniques.Rd @@ -0,0 +1,34 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/get_niveaux_nappes_chroniques.R +\name{get_niveaux_nappes_chroniques} +\alias{get_niveaux_nappes_chroniques} +\title{Retrieve piezometric archived time series from API "Piézométrie"} +\usage{ +get_niveaux_nappes_chroniques( + params, + cfg = config::get(file = system.file("config.yml", package = "hubeau")) +) +} +\arguments{ +\item{params}{a \link{list} the list of parameters of the queries and their values in the format \code{list(ParamName = "Param value", ...)}, use the function \link{get_available_params} for a list of the available parameters for a given operation in an API and see the API documentation for the complete list of available filter parameters} + +\item{cfg}{a \link{config} object Configuration of the communication. Use by default the internal package +configuration} +} +\value{ +a \link[tibble:tibble]{tibble::tibble} with all available parameters in columns and one row by time step and by station. +} +\description{ +See the API documentation for available filter parameters: \url{https://hubeau.eaufrance.fr/page/api-piezometrie} +} +\examples{ +# Retrieve the archived observed piezometric level at station '07548X0009/F' (old BSS identifier) +# for the year 2020 +df <- get_niveaux_nappes_chroniques(list(code_bss = "07548X0009/F", + date_debut_mesure = "2020-01-01", + date_fin_mesure = "2020-12-31")) + +# Plot the water elevation (NGF) +plot(as.POSIXct(df$date_mesure), df$niveau_nappe_eau, type = "l") + +} diff --git a/man/get_niveaux_nappes_chroniques_tr.Rd b/man/get_niveaux_nappes_chroniques_tr.Rd new file mode 100644 index 0000000000000000000000000000000000000000..19627fd5a6883e74c68e779d792b2bb1765c5ec0 --- /dev/null +++ b/man/get_niveaux_nappes_chroniques_tr.Rd @@ -0,0 +1,30 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/get_niveaux_nappes_chroniques_tr.R +\name{get_niveaux_nappes_chroniques_tr} +\alias{get_niveaux_nappes_chroniques_tr} +\title{Retrieve piezometric "real time" chroniques from API "Piézométrie"} +\usage{ +get_niveaux_nappes_chroniques_tr( + params, + cfg = config::get(file = system.file("config.yml", package = "hubeau")) +) +} +\arguments{ +\item{params}{a \link{list} the list of parameters of the queries and their values in the format \code{list(ParamName = "Param value", ...)}, use the function \link{get_available_params} for a list of the available parameters for a given operation in an API and see the API documentation for the complete list of available filter parameters} + +\item{cfg}{a \link{config} object Configuration of the communication. Use by default the internal package +configuration} +} +\value{ +a \link[tibble:tibble]{tibble::tibble} with all available parameters in columns and one row by time step and by station. +} +\description{ +See the API documentation for available filter parameters: \url{https://hubeau.eaufrance.fr/page/api-piezometrie} +} +\examples{ +# For retrieving the last real time observed piezometric level at station 'BSS001VZGZ' (new BSS identifier) +df <- get_niveaux_nappes_chroniques_tr(list(bss_id = "BSS001VZGZ")) + +# Plot the water elevation (NGF) +plot(as.POSIXct(df$date_mesure), df$niveau_eau_ngf, type = "l") +} diff --git a/man/get_niveaux_nappes_stations.Rd b/man/get_niveaux_nappes_stations.Rd index 279e1a1e1004fdfcdc36a0dcbdd2112358ba2b85..4efbb7dd50e8bea334fc48661b41e723954b3d10 100644 --- a/man/get_niveaux_nappes_stations.Rd +++ b/man/get_niveaux_nappes_stations.Rd @@ -22,7 +22,7 @@ a \link[tibble:tibble]{tibble::tibble} with all available parameters in columns See the API documentation for available filter parameters: \url{https://hubeau.eaufrance.fr/page/api-piezometrie} } \examples{ -# For retrieving the hydrometric stations in the department of Aube +# Retrieve the hydrometric stations in the department of Aube get_niveaux_nappes_stations(list(code_departement = "10")) }