Commit ee56175f authored by Dorchies David's avatar Dorchies David
Browse files

feat: add `get_hydrometrie_observations_tr`

Fix #7
parent c5f6b053
Pipeline #26122 failed with stages
in 59 seconds
......@@ -2,6 +2,7 @@
export(doApiQuery)
export(get_available_params)
export(get_hydrometrie_observations_tr)
export(get_hydrometrie_sites)
export(get_hydrometrie_stations)
export(get_indicateurs_services_communes)
......
#' Retrieve hydrometric "real time" observations from API "Hydrométrie"
#'
#' See the API documentation for available filter parameters: \url{https://hubeau.eaufrance.fr/page/api-hydrometrie}
#'
#' @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 hydrometric last real time observed discharge at station 'H020302002'
#' get_hydrometrie_observations_tr(list(code_entite = "H0203020", grandeur_hydro = "Q"))
#'
get_hydrometrie_observations_tr <- function(params,
unique_site = TRUE,
cfg = config::get(file = system.file("config.yml",
package = "hubeau"))) {
l <- doApiQuery(
api = "hydrometrie",
operation = "observations_tr",
params = params,
cfg = cfg
)
l <- lapply(l, function(x) {
x$geometry <- NULL
if (is.null(x$code_station)) {
# See bug https://github.com/BRGM/hubeau/issues/73
NULL
} else {
x
}
})
l[sapply(l, is.null)] <- NULL
convert_list_to_tibble(l)
}
......@@ -10,6 +10,7 @@
#'
#' Available functions:
#'
#' - [get_hydrometrie_observations_tr]
#' - [get_hydrometrie_sites]
#' - [get_hydrometrie_stations]
#'
......
......@@ -136,3 +136,17 @@ default:
- 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
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/get_hydrometrie_observations_tr.R
\name{get_hydrometrie_observations_tr}
\alias{get_hydrometrie_observations_tr}
\title{Retrieve hydrometric "real time" observations from API "Hydrométrie"}
\usage{
get_hydrometrie_observations_tr(
params,
unique_site = TRUE,
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}
}
\examples{
# For retrieving the hydrometric last real time observed discharge at station 'H020302002'
get_hydrometrie_observations_tr(list(code_entite = "H0203020", grandeur_hydro = "Q"))
}
......@@ -16,6 +16,7 @@ API documentation: \url{https://hubeau.eaufrance.fr/page/api-hydrometrie}
Available functions:
\itemize{
\item \link{get_hydrometrie_observations_tr}
\item \link{get_hydrometrie_sites}
\item \link{get_hydrometrie_stations}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment