Commit 2d274d84 authored by Dorchies David's avatar Dorchies David
Browse files

feat: add `get_hydrometrie_stations`

Refs #7
parent 78c8c13e
No related merge requests found
Pipeline #26112 passed with stages
in 1 minute and 44 seconds
Showing with 104 additions and 0 deletions
+104 -0
......@@ -2,6 +2,7 @@
export(doApiQuery)
export(get_available_params)
export(get_hydrometrie_stations)
export(get_indicateurs_services_communes)
export(get_indicateurs_services_indicateurs)
export(get_prelevements_chroniques)
......
#' Retrieve hydrometric stations from API "Hydrométrie"
#'
#' See the API documentation for available filter parameters: \url{https://hubeau.eaufrance.fr/page/api-hydrometrie}
#'
#' @template param_get_common
#' @param code_sandre_reseau_station optional [logical] indicating if `code_sandre_reseau_station` field is included in the result; if so, one line is added by item and other fields are repeated
#'
#' @return a [tibble::tibble] with all available parameters in columns and one row by device, year and usage.
#' @export
#'
#' @examples
#' # For retrieving the hydrometric stations in the department of Aube
#' get_hydrometrie_stations(list(code_departement = "10"))
#'
get_hydrometrie_stations <- function(params, code_sandre_reseau_station = FALSE, cfg = config::get(file = system.file("config.yml",
package = "hubeau"))) {
l <- doApiQuery(api = "hydrometrie",
operation = "stations",
params = params,
cfg = cfg)
l <- lapply(l, function(x) {
if (!code_sandre_reseau_station) {
x$code_sandre_reseau_station <- NULL
}
x$geometry <- NULL
x
})
convert_list_to_tibble(l)
}
......@@ -4,6 +4,14 @@
#'
#' Currently available APIs and related "operations" are listed below.
#'
#' **API "Hydrométrie"**
#'
#' API documentation: \url{https://hubeau.eaufrance.fr/page/api-hydrometrie}
#'
#' Available functions:
#'
#' - [get_hydrometrie_stations]
#'
#' **API "Indicateurs des services"**
#'
#' API documentation: \url{https://hubeau.eaufrance.fr/page/api-indicateurs-services}
......@@ -20,6 +28,7 @@
#' Available functions:
#'
#' - [get_prelevements_chroniques]
#' - [get_prelevements_ouvrages]
#' - [get_prelevements_points_prelevement]
#'
#' @docType package
......
......@@ -95,3 +95,27 @@ default:
- code_departement
- fields
- type_service
hydrometrie:
path: v1/hydrometrie
operations:
stations:
path: referentiel/stations
fields:
- bbox
- code_commune_station
- code_cours_eau
- code_departement
- code_region
- code_sandre_reseau_station
- code_site
- code_station
- date_fermeture_station
- date_ouverture_station
- distance
- en_service
- fields
- latitude
- libelle_cours_eau
- libelle_site
- libelle_station
- longitude
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/get_hydrometrie_stations.R
\name{get_hydrometrie_stations}
\alias{get_hydrometrie_stations}
\title{Retrieve hydrometric stations from API "Hydrométrie"}
\usage{
get_hydrometrie_stations(
params,
code_sandre_reseau_station = FALSE,
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{code_sandre_reseau_station}{optional \link{logical} indicating if \code{code_sandre_reseau_station} field is included in the result; if so, one line is added by item and other fields are repeated}
\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, year and usage.
}
\description{
See the API documentation for available filter parameters: \url{https://hubeau.eaufrance.fr/page/api-hydrometrie}
}
\examples{
# For retrieving the hydrometric stations in the department of Aube
get_hydrometrie_stations(list(code_departement = "10"))
}
......@@ -10,6 +10,15 @@ The 'hubeau' package provides functions for APIs and related "operations". These
\details{
Currently available APIs and related "operations" are listed below.
\strong{API "Hydrométrie"}
API documentation: \url{https://hubeau.eaufrance.fr/page/api-hydrometrie}
Available functions:
\itemize{
\item \link{get_hydrometrie_stations}
}
\strong{API "Indicateurs des services"}
API documentation: \url{https://hubeau.eaufrance.fr/page/api-indicateurs-services}
......@@ -27,6 +36,7 @@ API documentation: \url{https://hubeau.eaufrance.fr/page/api-prelevements-eau}
Available functions:
\itemize{
\item \link{get_prelevements_chroniques}
\item \link{get_prelevements_ouvrages}
\item \link{get_prelevements_points_prelevement}
}
}
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