Skip to content

Commit e6fa9d6

Browse files
committed
don't allow snap level >30
1 parent 4a20687 commit e6fa9d6

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

R/s2-options.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ s2_snap_identity <- function() {
109109
#' @rdname s2_options
110110
#' @export
111111
s2_snap_level <- function(level) {
112+
if (level > 30) {
113+
stop("`level` must be an intger between 1 and 30", call. = FALSE)
114+
}
115+
112116
structure(list(level = level), class = "snap_level")
113117
}
114118

tests/testthat/test-s2-options.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ 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")
99
expect_error(s2_options(snap_radius = 100), "radius is too large")
10+
expect_error(s2_snap_level(31), "between 1 and 30")
1011
})

tests/testthat/test-s2-transformers.R

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -470,12 +470,6 @@ test_that("s2_rebuild() works", {
470470
)
471471
)
472472
)
473-
474-
# S2Builder error
475-
expect_error(
476-
s2_rebuild("POINT (0.01 0.01)", options = s2_options(snap = s2_snap_level(32))),
477-
"Snap function moved vertex"
478-
)
479473
})
480474

481475
test_that("real data survives the S2BooleanOperation", {

0 commit comments

Comments
 (0)