Skip to content

Commit

Permalink
style: styler
Browse files Browse the repository at this point in the history
  • Loading branch information
maelle committed Mar 15, 2024
1 parent c70bd9b commit c2c2248
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 104 deletions.
2 changes: 1 addition & 1 deletion EMODnetWFS.Rproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ SaveWorkspace: No
AlwaysSaveHistory: Default

EnableCodeIndexing: Yes
UseSpacesForTab: No
UseSpacesForTab: Yes
NumSpacesForTab: 4
Encoding: UTF-8

Expand Down
56 changes: 28 additions & 28 deletions R/client.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,49 +18,49 @@
#' wfs <- emodnet_init_wfs_client(service = "bathymetry")
#' }
emodnet_init_wfs_client <- function(service,
service_version = NULL,
logger = NULL) {
deprecate_message_service_version(
service_version,
"deprecate_message_service_version"
)
service_version = NULL,
logger = NULL) {
deprecate_message_service_version(
service_version,
"deprecate_message_service_version"
)

check_service_name(service)
check_service_name(service)

service_url <- get_service_url(service)
service_url <- get_service_url(service)

wfs <- suppressWarnings(
ows4R::WFSClient$new(
service_url,
serviceVersion = "2.0.0",
headers = c("User-Agent" = emodnetwfs_user_agent()),
logger = logger
)
)
wfs <- suppressWarnings(
ows4R::WFSClient$new(
service_url,
serviceVersion = "2.0.0",
headers = c("User-Agent" = emodnetwfs_user_agent()),
logger = logger
)
)

check_wfs(wfs)
cli_alert_success("WFS client created successfully")
cli_alert_info("Service: {.val {wfs$getUrl()}}")
cli_alert_info("Version: {.val {wfs$getVersion()}}")
check_wfs(wfs)
cli_alert_success("WFS client created successfully")
cli_alert_info("Service: {.val {wfs$getUrl()}}")
cli_alert_info("Version: {.val {wfs$getVersion()}}")

wfs
wfs
}

check_service_name <- function(service) {
checkmate::assert_choice(service, emodnet_wfs()$service_name)
checkmate::assert_choice(service, emodnet_wfs()$service_name)
}

check_wfs <- function(wfs) {
checkmate::assertR6(
wfs,
classes = c("WFSClient", "OWSClient", "OGCAbstractObject", "R6")
)
checkmate::assertR6(
wfs,
classes = c("WFSClient", "OWSClient", "OGCAbstractObject", "R6")
)
}

get_service_url <- function(service) {
emodnet_wfs()$service_url[emodnet_wfs()$service_name == service]
emodnet_wfs()$service_url[emodnet_wfs()$service_name == service]
}

get_service_name <- function(service_url) {
emodnet_wfs()$service_name[emodnet_wfs()$service_url == service_url]
emodnet_wfs()$service_name[emodnet_wfs()$service_url == service_url]
}
5 changes: 2 additions & 3 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,11 @@ rerddap::ed_datasets(url = erddap_url)
rerddap::ed_search(query = "vessel density", url = erddap_url)
human_activities_data_info <- rerddap::info(datasetid = 'humanactivities_9f8a_3389_f08a', url = erddap_url)
human_activities_data_info <- rerddap::info(datasetid = "humanactivities_9f8a_3389_f08a", url = erddap_url)
human_activities_data_info
year_2020_gridded_data <- griddap(datasetx = human_activities_data_info, time = c('2020-03-18', '2020-03-19'))
year_2020_gridded_data <- griddap(datasetx = human_activities_data_info, time = c("2020-03-18", "2020-03-19"))
head(year_2020_gridded_data$data)
```


Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-info.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ test_that("emodnet_get_layer_info() works", {
})

test_that("emodnet_get_wfs_info() errors well", {
expect_snapshot(emodnet_get_wfs_info(), error = TRUE)
expect_snapshot(emodnet_get_wfs_info(), error = TRUE)
})
135 changes: 67 additions & 68 deletions tests/testthat/test-layer_attributes.R
Original file line number Diff line number Diff line change
@@ -1,80 +1,79 @@
test_that("layer attributes stuff works", {
skip_if_offline()
wfs <- create_biology_wfs()
skip_if_offline()
wfs <- create_biology_wfs()

with_mock_dir("biology-layers", {
layer_attr <- layer_attributes_get_names(wfs, layer = "mediseh_zostera_m_pnt")
expect_identical(layer_attr, c("id", "country", "the_geom"))
with_mock_dir("biology-layers", {
layer_attr <- layer_attributes_get_names(wfs, layer = "mediseh_zostera_m_pnt")
expect_identical(layer_attr, c("id", "country", "the_geom"))

layer_attr_desc <- layer_attribute_descriptions(
wfs,
layer = "mediseh_zostera_m_pnt"
)
expect_snapshot_output(layer_attr_desc)
layer_attr_desc <- layer_attribute_descriptions(
wfs,
layer = "mediseh_zostera_m_pnt"
)
expect_snapshot_output(layer_attr_desc)

country <- layer_attribute_inspect(
wfs,
layer = "mediseh_zostera_m_pnt",
attribute = "country"
)
expect_s3_class(country, c("tabyl", "data.frame"))
expect_named(country, c(".", "n", "percent"))
expect_gt(nrow(country), 1L)
country <- layer_attribute_inspect(
wfs,
layer = "mediseh_zostera_m_pnt",
attribute = "country"
)
expect_s3_class(country, c("tabyl", "data.frame"))
expect_named(country, c(".", "n", "percent"))
expect_gt(nrow(country), 1L)

the_geom <- layer_attribute_inspect(
wfs,
layer = "mediseh_zostera_m_pnt",
attribute = "the_geom"
)
expect_s3_class(the_geom, c("sfc_POINT", "sfc"))
the_geom <- layer_attribute_inspect(
wfs,
layer = "mediseh_zostera_m_pnt",
attribute = "the_geom"
)
expect_s3_class(the_geom, c("sfc_POINT", "sfc"))

id <- layer_attribute_inspect(
wfs,
layer = "mediseh_zostera_m_pnt",
attribute = "id"
)
expect_s3_class(id, c("summaryDefault", "table"))
expect_named(id, c("Min.", "1st Qu.", "Median", "Mean", "3rd Qu.", "Max."))
expect_length(id, 6L)
id <- layer_attribute_inspect(
wfs,
layer = "mediseh_zostera_m_pnt",
attribute = "id"
)
expect_s3_class(id, c("summaryDefault", "table"))
expect_named(id, c("Min.", "1st Qu.", "Median", "Mean", "3rd Qu.", "Max."))
expect_length(id, 6L)

attr_summary <- layer_attributes_summarise(
wfs,
layer = "mediseh_zostera_m_pnt"
)
attr_summary <- layer_attributes_summarise(
wfs,
layer = "mediseh_zostera_m_pnt"
)

expect_s3_class(attr_summary, "table")
expect_identical(
attr_summary[, " country"][2:3],
structure(c("Class :character ", "Mode :character "), .Names = c(
"",
""
))
)
expect_identical(
attr_summary[, 2][1],
structure("Min. :0 ", .Names = "")
)
expect_s3_class(attr_summary, "table")
expect_identical(
attr_summary[, " country"][2:3],
structure(c("Class :character ", "Mode :character "), .Names = c(
"",
""
))
)
expect_identical(
attr_summary[, 2][1],
structure("Min. :0 ", .Names = "")
)

crs1 <- get_layer_default_crs(
layer = "mediseh_zostera_m_pnt",
wfs,
output = "epsg.text"
)
expect_identical(crs1, "epsg:4326")
crs1 <- get_layer_default_crs(
layer = "mediseh_zostera_m_pnt",
wfs,
output = "epsg.text"
)
expect_identical(crs1, "epsg:4326")

crs2 <- get_layer_default_crs(
layer = "mediseh_zostera_m_pnt",
wfs,
output = "epsg.num"
)
})
expect_identical(crs2, 4326)

crs3 <- get_layer_default_crs(
layer = "mediseh_zostera_m_pnt",
wfs,
output = "crs"
)
expect_s3_class(crs3, "crs")
crs2 <- get_layer_default_crs(
layer = "mediseh_zostera_m_pnt",
wfs,
output = "epsg.num"
)
})
expect_identical(crs2, 4326)

crs3 <- get_layer_default_crs(
layer = "mediseh_zostera_m_pnt",
wfs,
output = "crs"
)
expect_s3_class(crs3, "crs")
})
1 change: 0 additions & 1 deletion vignettes/articles/ecql_filtering.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,6 @@ emodnet_get_layers(
Let's say we also want to restrict the features returned those having `shape_length` > 1. We can include an additional condition which must be met using an `AND` statement.

```{r, eval=FALSE}
filter_sf1 <- emodnet_get_layers(
wfs = wfs,
layers = "seabed_substrate_1m",
Expand Down
2 changes: 0 additions & 2 deletions vignettes/articles/request-params.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ To limit data returned to the single attribute `"country"` from just 3 features,
Note that when limiting data to specific attributes, all other columns are returned as `NA` (including any spatial, in this case `the_geom`, column).

```{r}
emodnet_get_layers(
wfs = wfs,
layers = "maritimebnds",
Expand All @@ -145,7 +144,6 @@ emodnet_get_layers(
To limit to multiple attributes, separate each attribute name in the character string supplied to `propertyName` by a comma.

```{r}
emodnet_get_layers(
wfs = wfs,
layers = "maritimebnds",
Expand Down

0 comments on commit c2c2248

Please sign in to comment.