Commit 796f9e03 authored by Dorchies David's avatar Dorchies David
Browse files

feat: add function `get_prelevements_ouvrages`

- Doc corrections in `get_prelevements_...`

Fix #6
parent 803ae773
Pipeline #26100 passed with stages
in 1 minute and 44 seconds
......@@ -5,4 +5,5 @@ export(get_available_params)
export(get_indicateurs_services_communes)
export(get_indicateurs_services_indicateurs)
export(get_prelevements_chroniques)
export(get_prelevements_ouvrages)
export(get_prelevements_points_prelevement)
#' Retrieve time series of withdrawals from Hub'Eau API
#' Retrieve time series of withdrawals from API "Prélèvements en eau"
#'
#' See the API documentation for available filter parameters: \url{https://hubeau.eaufrance.fr/page/api-prelevements-eau#/prelevements/chronique}
#' See the API documentation for available filter parameters: \url{https://hubeau.eaufrance.fr/page/api-prelevements-eau}
#'
#' @template param_get_common
#'
......
#' Retrieve withdrawal devices from API "Prélèvements en eau"
#'
#' See the API documentation for available filter parameters: \url{https://hubeau.eaufrance.fr/page/api-prelevements-eau}
#'
#' @template param_get_common
#'
#' @return a [tibble::tibble] with all available parameters in columns and one row by device.
#' @export
#'
#' @examples
#' # For retrieving the withdrawal devices located in Romilly-sur-Seine
#' get_prelevements_ouvrages(list(code_commune_insee = "10323"))
#'
get_prelevements_ouvrages <- function(params, cfg = config::get(file = system.file("config.yml",
package = "hubeau"))) {
l <- doApiQuery(api = "prelevements",
operation = "ouvrages",
params = params,
cfg = cfg)
l <- lapply(l, function(x) {
x$geometry <- NULL
x$codes_points_prelevements <- NULL
x
})
l <- lapply(l, function(row) {lapply(row, function(cell) { if(is.null(unlist(cell))) NA else unlist(cell) })})
return(purrr::map_df(l, tibble::as_tibble))
}
#' Retrieve withdrawal points from Hub'Eau API
#' Retrieve withdrawal points from API "Prélèvements en eau"
#'
#' See the API documentation for available filter parameters: \url{https://hubeau.eaufrance.fr/page/api-prelevements-eau#/prelevements/prelevement}
#'
#' @template param_get_common
#'
#' @return a [tibble::tibble] with all available parameters in columns and one row by device.
#' @return a [tibble::tibble] with all available parameters in columns and one row by withdrawal point.
#' @export
#'
#' @examples
......
......@@ -48,6 +48,27 @@ default:
- producteur_donnee
- volume_max
- volume_min
ouvrages:
path: referentiel/ouvrages
fields:
- bbox
- code_bdlisa
- code_commune_insee
- code_departement
- code_entite_hydro_cours_eau
- code_entite_hydro_plan_eau
- code_mer_ocean
- code_ouvrage
- code_type_milieu
- codes_points_prelevements
- date_exploitation
- distance
- fields
- latitude
- libelle_departement
- longitude
- nom_commune
- nom_ouvrage
indicateurs_services:
path: v0/indicateurs_services
operations:
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/get_prelevements_ouvrages.R
\name{get_prelevements_ouvrages}
\alias{get_prelevements_ouvrages}
\title{Retrieve withdrawal devices from API "Prélèvements en eau"}
\usage{
get_prelevements_ouvrages(
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 device.
}
\description{
See the API documentation for available filter parameters: \url{https://hubeau.eaufrance.fr/page/api-prelevements-eau}
}
\examples{
# For retrieving the withdrawal devices located in Romilly-sur-Seine
get_prelevements_ouvrages(list(code_commune_insee = "10323"))
}
......@@ -2,7 +2,7 @@
% Please edit documentation in R/get_prelevements_points_prelevement.R
\name{get_prelevements_points_prelevement}
\alias{get_prelevements_points_prelevement}
\title{Retrieve withdrawal points from Hub'Eau API}
\title{Retrieve withdrawal points from API "Prélèvements en eau"}
\usage{
get_prelevements_points_prelevement(
params,
......@@ -16,7 +16,7 @@ get_prelevements_points_prelevement(
configuration}
}
\value{
a \link[tibble:tibble]{tibble::tibble} with all available parameters in columns and one row by device.
a \link[tibble:tibble]{tibble::tibble} with all available parameters in columns and one row by withdrawal point.
}
\description{
See the API documentation for available filter parameters: \url{https://hubeau.eaufrance.fr/page/api-prelevements-eau#/prelevements/prelevement}
......
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