diff --git a/NAMESPACE b/NAMESPACE index da6adecfc21c18a78386566f0e02b24de81e62d8..a4a1b4076b8e8fdd133c2f970d6a671a37be6d00 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -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) diff --git a/R/get_prelevements_chroniques.R b/R/get_prelevements_chroniques.R index 69929d695aa39dc398f438f6c340d16140ccc615..dd526e02c4f248b315b189a83d8370a9941efbf7 100644 --- a/R/get_prelevements_chroniques.R +++ b/R/get_prelevements_chroniques.R @@ -1,6 +1,6 @@ -#' 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 #' diff --git a/R/get_prelevements_ouvrages.R b/R/get_prelevements_ouvrages.R new file mode 100644 index 0000000000000000000000000000000000000000..f6826fa9fd011d0ba4d44ec9a930bdabc83e7cfc --- /dev/null +++ b/R/get_prelevements_ouvrages.R @@ -0,0 +1,28 @@ +#' 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)) +} diff --git a/R/get_prelevements_points_prelevement.R b/R/get_prelevements_points_prelevement.R index de077c746ef987e03d09ae122e1f0a02269e293f..d7fa0745f0901265f3cf88ce29dc83d58e913794 100644 --- a/R/get_prelevements_points_prelevement.R +++ b/R/get_prelevements_points_prelevement.R @@ -1,10 +1,10 @@ -#' 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 diff --git a/inst/config.yml b/inst/config.yml index e95862137d2cc886ee6cc9101f3625ff0e161d9d..47c8e6ad51df52fa2c1b6dc6ecf1d0b27ac39684 100644 --- a/inst/config.yml +++ b/inst/config.yml @@ -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: diff --git a/man/get_prelevements_ouvrages.Rd b/man/get_prelevements_ouvrages.Rd new file mode 100644 index 0000000000000000000000000000000000000000..7925b6ade5179a54f09664037d7e0aeb8b8b4ae1 --- /dev/null +++ b/man/get_prelevements_ouvrages.Rd @@ -0,0 +1,28 @@ +% 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")) + +} diff --git a/man/get_prelevements_points_prelevement.Rd b/man/get_prelevements_points_prelevement.Rd index fbb2846e4568395829b8f500034cd7ca23084556..efea333bd4f4adc3076da248349965e956a22024 100644 --- a/man/get_prelevements_points_prelevement.Rd +++ b/man/get_prelevements_points_prelevement.Rd @@ -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}