Skip to content

Commit c8892e3

Browse files
committed
check snap radius input
1 parent e85868e commit c8892e3

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

R/s2-options.R

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@ s2_options <- function(model = NULL,
6868
simplify_edge_chains = FALSE,
6969
split_crossing_edges = FALSE,
7070
idempotent = FALSE) {
71+
# check snap radius (passing in a huge snap radius can cause problems)
72+
if (snap_radius > 3) {
73+
stop(
74+
"Snap radius is too large. Did you pass in a snap radius in meters instead of radians?",
75+
call. = FALSE
76+
)
77+
}
78+
7179
structure(
7280
list(
7381
# model needs to be "unset" by default because there are differences in polygon

tests/testthat/test-s2-options.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ test_that("s2_options() works", {
66
test_that("s2_options() errors are readable", {
77
expect_error(s2_intersects("POINT EMPTY", "POINT EMPTY", options = NULL), "must be created using")
88
expect_error(s2_options(model = "not a model"), "must be one of")
9+
expect_error(s2_options(snap_radius = 100), "radius is too large")
910
})

0 commit comments

Comments
 (0)