Skip to content

Commit

Permalink
Test error fix
Browse files Browse the repository at this point in the history
- Local test passed
  • Loading branch information
Insang Song committed Nov 17, 2023
1 parent c766386 commit d10c8bc
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
13 changes: 11 additions & 2 deletions R/check.R
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,23 @@ check_bbox <- function(
query_crs <- check_crs(data_query)

ref_crs <- check_crs(reference)
if (is.null(reference_crs)) {
reference <-
sf::st_as_sfc(
sf::st_bbox(reference),
crs = ref_crs
)
}
if (is.na(query_crs) || is.null(query_crs)) {
stop("The dataset you queried has no CRS.
Please make sure your dataset has the correct CRS.\n")

Check warning on line 149 in R/check.R

View check run for this annotation

Codecov / codecov/patch

R/check.R#L148-L149

Added lines #L148 - L149 were not covered by tests
}
data_query_bb <- sf::st_bbox(data_query)
data_query_bb <-
sf::st_as_sfc(sf::st_bbox(data_query),
crs = sf::st_crs(data_query))

query_matched <- sf::st_transform(data_query_bb, sf::st_crs(ref_crs))
check_result <- sf::st_within(query_matched, reference)
check_result <- as.logical(unlist(sf::st_within(query_matched, reference)))
return(check_result)
}

Expand Down
15 changes: 12 additions & 3 deletions scomps_rmarkdown_litr.rmd
Original file line number Diff line number Diff line change
Expand Up @@ -943,14 +943,23 @@ check_bbox <- function(
query_crs <- check_crs(data_query)
ref_crs <- check_crs(reference)
if (is.null(reference_crs)) {
reference <-
sf::st_as_sfc(
sf::st_bbox(reference),
crs = ref_crs
)
}
if (is.na(query_crs) || is.null(query_crs)) {
stop("The dataset you queried has no CRS.
Please make sure your dataset has the correct CRS.\n")
}
data_query_bb <- sf::st_bbox(data_query)
data_query_bb <-
sf::st_as_sfc(sf::st_bbox(data_query),
crs = sf::st_crs(data_query))
query_matched <- sf::st_transform(data_query_bb, sf::st_crs(ref_crs))
check_result <- sf::st_within(query_matched, reference)
check_result <- as.logical(unlist(sf::st_within(query_matched, reference)))
return(check_result)
}
Expand All @@ -968,7 +977,7 @@ testthat::test_that("Check bbox abides.", {
nc <- system.file(package = "sf", "shape/nc.shp")
nc <- sf::read_sf(nc)
nc <- sf::st_transform(nc, "EPSG:5070")
ncp <- sf::read_sf("../testdata/nc_random_point.rds")
ncp <- readRDS(testthat::test_path("..", "testdata", "nc_random_point.rds"))
ncp <- sf::st_transform(ncp, "EPSG:5070")
testthat::expect_no_error(check_bbox(ncp, nc))
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/tests.R
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ testthat::test_that("Check bbox abides.", {
nc <- system.file(package = "sf", "shape/nc.shp")
nc <- sf::read_sf(nc)
nc <- sf::st_transform(nc, "EPSG:5070")
ncp <- sf::read_sf("../testdata/nc_random_point.rds")
ncp <- readRDS(testthat::test_path("..", "testdata", "nc_random_point.rds"))
ncp <- sf::st_transform(ncp, "EPSG:5070")

testthat::expect_no_error(check_bbox(ncp, nc))
Expand Down
Binary file modified tools/tarballs/scomps_0.0.5.11172023.tar.gz
Binary file not shown.

0 comments on commit d10c8bc

Please sign in to comment.