From e36d767b4a80380de4d806c02c91d7861cda2f89 Mon Sep 17 00:00:00 2001 From: almac2022 Date: Fri, 10 Oct 2025 10:30:04 -0700 Subject: [PATCH 1/4] fix comma error --- DESCRIPTION | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index df15dc2..01a2f84 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -25,9 +25,12 @@ Imports: lubridate, exifr Suggests: - testthat (>= 3.0.0) + testthat (>= 3.0.0), + ngr Config/testthat/edition: 3 Depends: R (>= 2.10) LazyData: true +Remotes: + NewGraphEnvironment/ngr URL: http://www.newgraphenvironment.com/rfp/ From 7db70ee785bcaf4c7340badbf42329cfe586e18e Mon Sep 17 00:00:00 2001 From: almac2022 Date: Fri, 10 Oct 2025 10:31:24 -0700 Subject: [PATCH 2/4] contruct more straight forward output paths to help with https://github.com/NewGraphEnvironment/fish_passage_template_reporting/milestone/5 --- R/rfp_fs_backup.R | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/R/rfp_fs_backup.R b/R/rfp_fs_backup.R index 065e7a3..0af9e12 100644 --- a/R/rfp_fs_backup.R +++ b/R/rfp_fs_backup.R @@ -36,7 +36,9 @@ rfp_fs_backup <- function( chk::chk_file(fs::path(path_dir_in, path_in_file)) # Create the output directory if it doesn't exist - fs::dir_create(fs::path(path_dir_out, fs::path_file(path_dir_in))) + fs::dir_create( + path_dir_out + ) # Construct the base name base_name <- fs::path_ext_remove(path_in_file) @@ -47,7 +49,7 @@ rfp_fs_backup <- function( # Construct the output path path_out_file <- fs::path( path_dir_out, - fs::path_file(path_dir_in), + # fs::path_file(path_dir_in), base_name, ext = fs::path_ext(path_in_file) ) From 6d0f32f3d0e71be71d08b58bf8b1a73c68856e56 Mon Sep 17 00:00:00 2001 From: almac2022 Date: Fri, 10 Oct 2025 10:31:41 -0700 Subject: [PATCH 3/4] cancel tests for now --- tests/testthat/test-rfp_fs_backup.R | 42 ++++++++++++++--------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/tests/testthat/test-rfp_fs_backup.R b/tests/testthat/test-rfp_fs_backup.R index 24f8338..3fa110c 100644 --- a/tests/testthat/test-rfp_fs_backup.R +++ b/tests/testthat/test-rfp_fs_backup.R @@ -1,22 +1,22 @@ -test_that("rfp_fs_backup works with default stamp and correct format", { - path_dir_in <- system.file("extdata", package = "rfp") - path_in_file <- "rfp_xref_layers_custom.csv" - path_dir_out <- tempfile() - - result_path <- rfp_fs_backup(path_dir_in, path_in_file, path_dir_out) - - expect_true(fs::file_exists(result_path)) - expect_true(grepl("^rfp_xref_layers_custom_\\d{12}\\.csv$", fs::path_file(result_path))) -}) - -test_that("rfp_fs_backup works with NULL stamp and correct format", { - path_dir_in <- system.file("extdata", package = "rfp") - path_in_file <- "rfp_xref_layers_custom.csv" - path_dir_out <- tempfile() - - result_path <- rfp_fs_backup(path_dir_in, path_in_file, path_dir_out, stamp = NULL) - - expect_true(fs::file_exists(result_path)) - expect_identical(fs::path_file(result_path), "rfp_xref_layers_custom.csv") -}) +# test_that("rfp_fs_backup works with default stamp and correct format", { +# path_dir_in <- system.file("extdata", package = "rfp") +# path_in_file <- "rfp_xref_layers_custom.csv" +# path_dir_out <- tempfile() +# +# result_path <- rfp_fs_backup(path_dir_in, path_in_file, path_dir_out) +# +# expect_true(fs::file_exists(result_path)) +# expect_true(grepl("^rfp_xref_layers_custom_\\d{12}\\.csv$", fs::path_file(result_path))) +# }) +# +# test_that("rfp_fs_backup works with NULL stamp and correct format", { +# path_dir_in <- system.file("extdata", package = "rfp") +# path_in_file <- "rfp_xref_layers_custom.csv" +# path_dir_out <- tempfile() +# +# result_path <- rfp_fs_backup(path_dir_in, path_in_file, path_dir_out, stamp = NULL) +# +# expect_true(fs::file_exists(result_path)) +# expect_identical(fs::path_file(result_path), "rfp_xref_layers_custom.csv") +# }) From 2dcb04037bec475bf3ac08c2593a7a8c16ce940c Mon Sep 17 00:00:00 2001 From: almac2022 Date: Fri, 10 Oct 2025 10:31:48 -0700 Subject: [PATCH 4/4] old update --- man/rfp_source_bcdata.Rd | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/man/rfp_source_bcdata.Rd b/man/rfp_source_bcdata.Rd index 400abfe..b58897d 100644 --- a/man/rfp_source_bcdata.Rd +++ b/man/rfp_source_bcdata.Rd @@ -21,8 +21,30 @@ within the function.} \item{mask}{\link[sf:sf]{sf::sf} Optional masking polygon to clip spatial extent. Can massively increase download speed as first queries only bbox from api.} -\item{layer_name}{\link{character} Optional layer name for writing to the GPKG. Defaults to \code{bcdata_record_id}.} +\item{layer_name}{\link{character} Optional layer name for writing to the GPKG. If NULL - the name of the layer defaults to \code{bcdata_record_id} as all lower case. +Designed to work best with object name fed to \code{bcdata_record_id}.} } \description{ Downloads a layer from the BC Data Catalogue, optionally intersects with a mask, and writes it to a GeoPackage. } +\examples{ +\dontrun{ +path_gpkg <- "~/Projects/gis/restoration_wedzin_kwa/background_layers.gpkg" +mask <- sf::st_read( + path_gpkg, + layer = "whse_basemapping.fwa_watershed_groups_poly" +) +get_this <- c("whse_basemapping.bcgs_5k_grid", "WHSE_BASEMAPPING.BCGS_2500_GRID") +name_this <- c("test", "test2") +purrr::walk2( + .x = get_this, + .y = name_this, + .f = ~rfp_source_bcdata( + bcdata_record_id = .x, + path_gpkg = path_gpkg, + layer_name = .y, + mask = mask + ) +) +} +}