diff --git a/DESCRIPTION b/DESCRIPTION index e946a868..3e1ffb98 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -42,14 +42,14 @@ Imports: glue (>= 1.6.0), jsonlite (>= 1.6.0), leaflet (>= 2.1.0), - leaflet.extras (>= 1.0.0), purrr (>= 0.3), readr (>= 2.1), readxl (>= 1.4.0), rlang (>= 1.0), sf (>= 1.0), tidyselect (>= 1.1.0), - xml2 (>= 1.3.0) + xml2 (>= 1.3.0), + htmltools Suggests: covr, ggplot2, @@ -61,7 +61,7 @@ VignetteBuilder: knitr Encoding: UTF-8 Roxygen: list(markdown = TRUE) -RoxygenNote: 7.3.2 +RoxygenNote: 7.3.3 Collate: 'bcdata-package.R' 'bcdc-get-citation.R' diff --git a/R/bcdc-web-services.R b/R/bcdc-web-services.R index 6dcd8e62..5d024859 100644 --- a/R/bcdc-web-services.R +++ b/R/bcdc-web-services.R @@ -104,7 +104,9 @@ #' } #' @export bcdc_query_geodata <- function(record, crs = 3005) { - if (!has_internet()) stop("No access to internet", call. = FALSE) # nocov + if (!has_internet()) { + stop("No access to internet", call. = FALSE) + } # nocov UseMethod("bcdc_query_geodata") } @@ -227,7 +229,9 @@ bcdc_query_geodata.bcdc_record <- function(record, crs = 3005) { #' @export bcdc_preview <- function(record) { # nocov start - if (!has_internet()) stop("No access to internet", call. = FALSE) + if (!has_internet()) { + stop("No access to internet", call. = FALSE) + } UseMethod("bcdc_preview") } @@ -271,6 +275,11 @@ make_wms <- function(x) { layer=pub%3A{x}" ) + legend_html <- htmltools::tags$div( + style = "padding: 10px; background: white;", + htmltools::tags$img(src = wms_legend, alt = "Legend") + ) + leaflet::leaflet() %>% leaflet::addProviderTiles( leaflet::providers$CartoDB.Positron, @@ -281,7 +290,7 @@ make_wms <- function(x) { layers = glue::glue("pub:{x}"), options = wms_options ) %>% - leaflet.extras::addWMSLegend(uri = wms_legend) %>% + leaflet::addControl(legend_html, position = "topright") %>% leaflet::setView(lng = -126.5, lat = 54.5, zoom = 5) } # nocov end diff --git a/tests/testthat/test-get-data.R b/tests/testthat/test-get-data.R index 404ba472..054741e7 100644 --- a/tests/testthat/test-get-data.R +++ b/tests/testthat/test-get-data.R @@ -245,6 +245,7 @@ test_that("bcdc_get_data fails when no downloadable resources", { test_that("bcdc_get_data fails when >1 resource not specified & noninteractive", { skip_if_net_down() skip_on_cran() + skip_if(interactive()) expect_error( bcdc_get_data("21c72822-2502-4431-b9a2-92fc9401ef12"), "The record you are trying to access appears to have more than one resource." diff --git a/tests/testthat/test-query-geodata-filter.R b/tests/testthat/test-query-geodata-filter.R index ac392865..1f57aeeb 100644 --- a/tests/testthat/test-query-geodata-filter.R +++ b/tests/testthat/test-query-geodata-filter.R @@ -323,7 +323,9 @@ test_that("a BCGW name works with filter", { ret <- bcdc_query_geodata("WHSE_IMAGERY_AND_BASE_MAPS.GSR_AIRPORTS_SVW") %>% filter(WITHIN(little_box)) %>% collect() - expect_equal(nrow(ret), 367) + + expect_gt(nrow(ret), 350) + expect_lt(nrow(ret), 400) }) test_that("Using BBOX works", {