Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
93 changes: 49 additions & 44 deletions R/get_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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')
#' )
#' }
#'
Expand All @@ -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")
}

Expand Down Expand Up @@ -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]

Expand Down Expand Up @@ -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"
)
}
6 changes: 3 additions & 3 deletions man/bcdc_get_data.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading