Skip to content

Commit

Permalink
enh(get_eglv_meta): operator
Browse files Browse the repository at this point in the history
  • Loading branch information
dimfalk committed Dec 27, 2024
1 parent a6cb83d commit bc0112e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: NRWgauges
Title: Web-scraping gauge (meta-)data from various providers in NRW, Germany
Version: 0.3.2
Version: 0.3.3
Date: 2024-12-27
Authors@R:
person("Dimitri", "Falk", , "[email protected]", role = c("aut", "cre"))
Expand Down
2 changes: 2 additions & 0 deletions R/get_eglv_meta.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ get_eglv_meta <- function(x = NULL) {

meta <- data.frame("id" = NA,
"name" = NA,
"operator" = NA,
"waterbody" = NA,
"municipality" = NA,
"X" = NA,
Expand Down Expand Up @@ -63,6 +64,7 @@ get_eglv_meta <- function(x = NULL) {

meta["id"] <- vals[2]
meta["name"] <- vals[1]
meta["operator"] <- ifelse(as.numeric(vals[2]) > 20000, "LV", "EG")
meta["waterbody"] <- vals[3]
meta["municipality"] <- vals[4]
meta["X"] <- vals[5] |> stringr::str_replace(pattern = ",", replacement = ".") |> as.numeric()
Expand Down
12 changes: 6 additions & 6 deletions tests/testthat/test-get_eglv_meta.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ with_mock_api({

meta <- get_eglv_meta(x)

expect_equal(dim(meta), c(1, 9))
expect_equal(dim(meta), c(1, 10))
})

test_that("Dimensions are as expected.", {
Expand All @@ -33,13 +33,13 @@ with_mock_api({

meta <- get_eglv_meta(y)

expect_equal(dim(meta), c(2, 9))
expect_equal(dim(meta), c(2, 10))
})

test_that("Column names are as expected.", {

cnames <- c("id", "name", "waterbody", "municipality", "X", "Y", "river_km",
"catchment_area", "level_zero")
cnames <- c("id", "name", "operator", "waterbody", "municipality", "X", "Y",
"river_km", "catchment_area", "level_zero")

x <- get_eglv_gauges() |> dplyr::filter(id == "10103")

Expand All @@ -50,8 +50,8 @@ with_mock_api({

test_that("Types are as expected.", {

dtype <- c("character", "character", "character", "character", "double",
"double", "double", "double", "double")
dtype <- c("character", "character", "character", "character", "character",
"double", "double", "double", "double", "double")

x <- get_eglv_gauges() |> dplyr::filter(id == "10103")

Expand Down

0 comments on commit bc0112e

Please sign in to comment.