From dc31beae8044477fb54dd5aec5bd9154f6e03cda Mon Sep 17 00:00:00 2001 From: Stephanie Hazlitt Date: Fri, 16 Oct 2026 11:27:06 -0700 Subject: [PATCH 1/3] update example resource --- R/get_data.R | 91 +++++++++++++++++++++++--------------------- man/bcdc_get_data.Rd | 4 +- 2 files changed, 50 insertions(+), 45 deletions(-) diff --git a/R/get_data.R b/R/get_data.R index 871ed31a..c246b38a 100644 --- a/R/get_data.R +++ b/R/get_data.R @@ -47,12 +47,12 @@ #' ) #' #' try( -#' bcdc_get_data('ca70a76a-a1a9-455b-a2f4-24ae151e4058') +#' bcdc_get_data('2a5d2e5e-36eb-412b-89ff-508dae26a7ff') #' ) #' #' # Using a `bcdc_record` object obtained from `bcdc_get_record`: #' try( -#' record <- bcdc_get_record('ca70a76a-a1a9-455b-a2f4-24ae151e4058') +#' record <- bcdc_get_record('2a5d2e5e-36eb-412b-89ff-508dae26a7ff') #' ) #' #' try( @@ -122,7 +122,9 @@ #' ) #' @export bcdc_get_data <- function(record, resource = NULL, verbose = TRUE, ...) { - if (!has_internet()) stop("No access to internet", call. = FALSE) # nocov + if (!has_internet()) { + stop("No access to internet", call. = FALSE) + } # nocov UseMethod("bcdc_get_data") } @@ -246,12 +248,15 @@ bcdc_get_data.bcdc_record <- function( choices <- clean_wfs(resource_df$name) ## To deal with situations where the resource names are the same - if (any(duplicated(choices))) + if (any(duplicated(choices))) { choices <- glue::glue("{choices} ({resource_df$format})") + } choice_input <- utils::menu(choices, title = "Please choose one option:") - if (choice_input == 0) stop("No resource selected", call. = FALSE) + if (choice_input == 0) { + stop("No resource selected", call. = FALSE) + } name_choice <- choices[choice_input] @@ -292,44 +297,44 @@ bcdc_get_data.bcdc_record <- function( bcdc_read_functions <- function() { dplyr::tribble( - ~format, - ~package, - ~fun, - "kml", - "sf", - "read_sf", - "geojson", - "sf", - "read_sf", - "gpkg", - "sf", - "read_sf", - "gdb", - "sf", - "read_sf", - "fgdb", - "sf", - "read_sf", - "shp", - "sf", - "read_sf", - "csv", - "readr", - "read_csv", - "txt", - "readr", - "read_tsv", - "tsv", - "readr", - "read_tsv", - "xlsx", - "readxl", - "read_xlsx", - "xls", - "readxl", - "read_xls", - "json", - "jsonlite", + ~format , + ~package , + ~fun , + "kml" , + "sf" , + "read_sf" , + "geojson" , + "sf" , + "read_sf" , + "gpkg" , + "sf" , + "read_sf" , + "gdb" , + "sf" , + "read_sf" , + "fgdb" , + "sf" , + "read_sf" , + "shp" , + "sf" , + "read_sf" , + "csv" , + "readr" , + "read_csv" , + "txt" , + "readr" , + "read_tsv" , + "tsv" , + "readr" , + "read_tsv" , + "xlsx" , + "readxl" , + "read_xlsx" , + "xls" , + "readxl" , + "read_xls" , + "json" , + "jsonlite" , "read_json" ) } diff --git a/man/bcdc_get_data.Rd b/man/bcdc_get_data.Rd index ae879527..04f181c7 100644 --- a/man/bcdc_get_data.Rd +++ b/man/bcdc_get_data.Rd @@ -46,12 +46,12 @@ try( ) try( - bcdc_get_data('ca70a76a-a1a9-455b-a2f4-24ae151e4058') + bcdc_get_data('2a5d2e5e-36eb-412b-89ff-508dae26a7ff') ) # Using a `bcdc_record` object obtained from `bcdc_get_record`: try( - record <- bcdc_get_record('ca70a76a-a1a9-455b-a2f4-24ae151e4058') + record <- bcdc_get_record('2a5d2e5e-36eb-412b-89ff-508dae26a7ff') ) try( From ed12a0f1150054f4ac9e0199519142e7c882e940 Mon Sep 17 00:00:00 2001 From: Stephanie Hazlitt Date: Thu, 12 Nov 2026 16:10:05 -0700 Subject: [PATCH 2/3] update excel sheet name --- R/get_data.R | 2 +- man/bcdc_get_data.Rd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/get_data.R b/R/get_data.R index c246b38a..fe7074c8 100644 --- a/R/get_data.R +++ b/R/get_data.R @@ -101,7 +101,7 @@ #' ## we can control what is read in from an excel file #' ## using arguments from readxl::read_excel #' try( -#' bcdc_get_data('8620ce82-4943-43c4-9932-40730a0255d6', sheet = 'Regional Districts') +#' bcdc_get_data('8620ce82-4943-43c4-9932-40730a0255d6', sheet = 'Purpose Built Rental') #' ) #' } #' diff --git a/man/bcdc_get_data.Rd b/man/bcdc_get_data.Rd index 04f181c7..2bb7eb5a 100644 --- a/man/bcdc_get_data.Rd +++ b/man/bcdc_get_data.Rd @@ -100,7 +100,7 @@ try( ## we can control what is read in from an excel file ## using arguments from readxl::read_excel try( - bcdc_get_data('8620ce82-4943-43c4-9932-40730a0255d6', sheet = 'Regional Districts') + bcdc_get_data('8620ce82-4943-43c4-9932-40730a0255d6', sheet = 'Purpose Built Rental') ) } From 0e6afdc50034a9c9d6820bfb9f8f7e865e835a63 Mon Sep 17 00:00:00 2001 From: Stephanie Hazlitt Date: Thu, 12 Nov 2026 16:17:13 -0700 Subject: [PATCH 3/3] add news entry --- NEWS.md | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/NEWS.md b/NEWS.md index 641aae25..e4c9d2f9 100644 --- a/NEWS.md +++ b/NEWS.md @@ -3,6 +3,7 @@ * Fixed YAML front matter in the service documentation vignette that newer versions of pandoc fail to parse, and replaced the deprecated `.Dim` attribute name with `dim` in a test. +* Update example bcdc_get_data code to use record with a resource (#376) and use an existing Excel sheet. # bcdata 0.5.3 @@ -17,11 +18,11 @@ # bcdata 0.5.1 -* Fix bugs where `bcdc_search_facets()`, `bcdc_list_group_records()` and - `bcdc_list_organization_records()` were not returning all records after - the upgrade to CKAN 2.9 (#353). Includes adding tests and bcdata-specific +* Fix bugs where `bcdc_search_facets()`, `bcdc_list_group_records()` and + `bcdc_list_organization_records()` were not returning all records after + the upgrade to CKAN 2.9 (#353). Includes adding tests and bcdata-specific options for these queries, see `bcdc_options()`. -* Added examples of partial query using `%like%` and `%in%` in +* Added examples of partial query using `%like%` and `%in%` in `bcdc_query_geodata()` (#356, thanks @bevingtona). # bcdata 0.5.0 @@ -111,7 +112,7 @@ - `bcdc_describe_feature` now joins an object description column to the returned object to provide more information about a field directly in R. #241, #259 - Better documentation and information surrounding the - `bcdata.max_geom_pred_size` option. #243, #258 + `bcdata.max_geom_pred_size` option. #243, #258 - Add new function `bcdc_check_geom_size` so users can check prior to submitting a WFS request with `filter` to see if the request will require a bounding box conversion. #243, #258 @@ -158,7 +159,7 @@ conversion. #243, #258 corresponding docs and tests (#180). ### IMPROVEMENTS -* Add explore-silviculture-data-using-bcdata vignette/article. h/t @hgriesbauer +* Add explore-silviculture-data-using-bcdata vignette/article. h/t @hgriesbauer * Add `head` and `tail` methods for `bcdc.promise` objects. Thanks to @hgriesbauer for the suggestion! (#182, #186) * Provide `as_tibble` as an alias for `collect` in line with `dbplyr` behaviour @@ -192,12 +193,12 @@ by setting a `BCDC_KEY` environment variable with their catalogue API token * Add back in querying vignette * Using `tidyselect` so that `select.bcdc_promise` behaviour is typical of `dplyr::select` ($140, #138) -* Using GitHub actions for CI. +* Using GitHub actions for CI. ### MINOR BREAKING CHANGES * Remove `BEYOND()` and `RELATE()` geometry predicates as they are currently not fully supported by geoserver - + ### BUG FIXES * Now precompiling vignettes so that queries are submitted locally and no actually requests are made from CRAN (#151) @@ -216,7 +217,7 @@ by setting a `BCDC_KEY` environment variable with their catalogue API token # bcdata 0.1.1 * Expand and standardize checking w[ms]f features to make package more resistant - to slight warehouse API changes. + to slight warehouse API changes. * Data retrieval functions now work with BCGW name (#106) * Add CITATION file (#104) * Increased test coverage (#112)