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

feat(piezometrie): add chroniques and chroniques_tr functions

Fix #8
parent 73c95280
No related merge requests found
Showing with 145 additions and 34 deletions
+145 -34
......@@ -17,6 +17,6 @@ Imports:
urltools
RoxygenNote: 7.1.1
Roxygen: list(markdown = TRUE)
Suggests:
Suggests:
testthat (>= 3.0.0)
Config/testthat/edition: 3
......@@ -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)
......
#' 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)
}
#' 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)
}
......@@ -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",
......
......@@ -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
% 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")
}
% 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")
}
......@@ -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"))
}
Supports Markdown
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