From e4611ebce38392aaaff8e5784973137ca3d50455 Mon Sep 17 00:00:00 2001 From: Andy Teucher Date: Wed, 18 Dec 2024 15:54:26 -0800 Subject: [PATCH 1/3] disable s2 while reading spatial data #337 https://r.geocompx.org/read-write\#geographic-web-services --- R/utils.R | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/R/utils.R b/R/utils.R index e8098881..cee4e615 100644 --- a/R/utils.R +++ b/R/utils.R @@ -87,6 +87,11 @@ specify_geom_name <- function(cols_df, CQL_statement){ bcdc_read_sf <- function(x, ...){ + # avoid use of spherical geomotry while reading (#337): + # https://r.geocompx.org/read-write#geographic-web-services + uses_s2 <- sf::sf_use_s2(FALSE) + on.exit(sf::sf_use_s2(uses_s2), add = TRUE, after = FALSE) + if(length(x) == 1){ return(sf::read_sf(x, stringsAsFactors = FALSE, quiet = TRUE, ...)) From 4d6a66eb2cc085f700cd63dc6828f6e60967942e Mon Sep 17 00:00:00 2001 From: Andy Teucher Date: Wed, 18 Dec 2024 15:54:50 -0800 Subject: [PATCH 2/3] Add minimum R version for new on.exit behaviour --- DESCRIPTION | 1 + 1 file changed, 1 insertion(+) diff --git a/DESCRIPTION b/DESCRIPTION index 67a10984..fd4ab963 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -29,6 +29,7 @@ Description: Search, query, and download tabular and License: Apache License (== 2.0) URL: https://bcgov.github.io/bcdata/, https://catalogue.data.gov.bc.ca/, https://github.com/bcgov/bcdata/ BugReports: https://github.com/bcgov/bcdata/issues +Depends: R (>= 3.6) Imports: methods, utils, From 4d559a0be954c9329b5f791c19fce85a88c72437 Mon Sep 17 00:00:00 2001 From: Andy Teucher Date: Thu, 19 Dec 2024 09:54:09 -0800 Subject: [PATCH 3/3] Supress s2 messages --- R/utils.R | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/R/utils.R b/R/utils.R index cee4e615..86c9521c 100644 --- a/R/utils.R +++ b/R/utils.R @@ -89,8 +89,12 @@ bcdc_read_sf <- function(x, ...){ # avoid use of spherical geomotry while reading (#337): # https://r.geocompx.org/read-write#geographic-web-services - uses_s2 <- sf::sf_use_s2(FALSE) - on.exit(sf::sf_use_s2(uses_s2), add = TRUE, after = FALSE) + uses_s2 <- suppressMessages(sf::sf_use_s2(FALSE)) + on.exit( + suppressMessages(sf::sf_use_s2(uses_s2)), + add = TRUE, + after = FALSE + ) if(length(x) == 1){