From 962d99d17bc00e3a40d4b4bdc4704b9252dae4c9 Mon Sep 17 00:00:00 2001 From: Dorchies David <david.dorchies@inrae.fr> Date: Thu, 23 Dec 2021 18:06:38 +0100 Subject: [PATCH] feat(hydrometrie): add obs_elab interface Refs #14 --- NAMESPACE | 1 + R/get_hydrometrie_obs_elab.R | 23 +++++++++++++++++++++++ inst/config.yml | 15 +++++++++++++++ man/get_hydrometrie_obs_elab.Rd | 27 +++++++++++++++++++++++++++ 4 files changed, 66 insertions(+) create mode 100644 R/get_hydrometrie_obs_elab.R create mode 100644 man/get_hydrometrie_obs_elab.Rd diff --git a/NAMESPACE b/NAMESPACE index ed1cd39..8fa7bbe 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -2,6 +2,7 @@ export(doApiQuery) export(get_available_params) +export(get_hydrometrie_obs_elab) export(get_hydrometrie_observations_tr) export(get_hydrometrie_sites) export(get_hydrometrie_stations) diff --git a/R/get_hydrometrie_obs_elab.R b/R/get_hydrometrie_obs_elab.R new file mode 100644 index 0000000..c11e57b --- /dev/null +++ b/R/get_hydrometrie_obs_elab.R @@ -0,0 +1,23 @@ +#' Retrieve hydrometric elaborate observations from API "Hydrométrie" +#' +#' See the API documentation for available filter parameters: \url{https://hubeau.eaufrance.fr/page/api-hydrometrie#operations-hydrometrie-observationsElaborees} +#' +#' @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 hydrometric last real time observed discharge at station 'H020302002' +#' get_hydrometrie_obs_elab(list(code_entite = "H0203020", grandeur_hydro_elab = "QmM")) +get_hydrometrie_obs_elab <- function(params, + cfg = config::get(file = system.file("config.yml", + package = "hubeau"))) { + l <- doApiQuery( + api = "hydrometrie", + operation = "obs_elab", + params = params, + cfg = cfg + ) + convert_list_to_tibble(l) +} diff --git a/inst/config.yml b/inst/config.yml index a88f2f7..628a162 100644 --- a/inst/config.yml +++ b/inst/config.yml @@ -150,6 +150,21 @@ default: - latitude - longitude - timestep + obs_elab: + path: obs_elab + fields: + - bbox + - code_entite + - cursor + - date_debut_obs_elab + - date_fin_obs_elab + - distance + - fields + - grandeur_hydro_elab + - latitude + - longitude + - resultat_max + - resultat_min niveaux_nappes: path: v1/niveaux_nappes operations: diff --git a/man/get_hydrometrie_obs_elab.Rd b/man/get_hydrometrie_obs_elab.Rd new file mode 100644 index 0000000..b81c3e1 --- /dev/null +++ b/man/get_hydrometrie_obs_elab.Rd @@ -0,0 +1,27 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/get_hydrometrie_obs_elab.R +\name{get_hydrometrie_obs_elab} +\alias{get_hydrometrie_obs_elab} +\title{Retrieve hydrometric elaborate observations from API "Hydrométrie"} +\usage{ +get_hydrometrie_obs_elab( + 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-hydrometrie#operations-hydrometrie-observationsElaborees} +} +\examples{ +# Retrieve the hydrometric last real time observed discharge at station 'H020302002' +get_hydrometrie_obs_elab(list(code_entite = "H0203020", grandeur_hydro_elab = "QmM")) +} -- GitLab