Skip to content

Commit d0defae

Browse files
committed
validity checks
Former-commit-id: 8ee4f38 Former-commit-id: a2a6f714118216b17cff6b181a97be27bea56801
1 parent 13d8d63 commit d0defae

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

R/trans.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ ct_scale <- new_generic("ct_scale", c("x", "t"))
9696

9797
#' @importFrom dplyr mutate
9898
method(ct_scale, list(PointFrame, class_numeric)) <- \(x, t) {
99+
stopifnot(length(t) == 2, is.finite(t))
99100
y <- NULL # R CMD check
100101
x@data <- x@data |>
101102
mutate(x=x*t[1]) |>
@@ -107,6 +108,7 @@ method(ct_scale, list(PointFrame, class_numeric)) <- \(x, t) {
107108
# could fix, but unclear what's expected.
108109
#' @importFrom sfarrow read_sf_dataset
109110
method(ct_scale, list(ShapeFrame, class_numeric)) <- \(x, t) {
111+
stopifnot(length(t) == 2, is.finite(t))
110112
x@data <- read_sf_dataset(x@data)
111113
x@data$geometry <- x@data$geometry*t(t)
112114
return(x)
@@ -124,6 +126,7 @@ ct_rotate <- new_generic("ct_rotate", c("x", "t"))
124126

125127
#' @importFrom dplyr mutate select
126128
method(ct_rotate, list(PointFrame, class_numeric)) <- \(x, t) {
129+
stopifnot(length(t) == 1, is.finite(t))
127130
y <- .y <- .x <- NULL # R CMD check
128131
R <- .R(t*pi/180)
129132
x@data <- x@data |>
@@ -137,6 +140,7 @@ method(ct_rotate, list(PointFrame, class_numeric)) <- \(x, t) {
137140

138141
#' @importFrom sfarrow read_sf_dataset
139142
method(ct_rotate, list(ShapeFrame, class_numeric)) <- \(x, t) {
143+
stopifnot(length(t) == 1, is.finite(t))
140144
R <- .R(t*pi/180)
141145
x@data <- read_sf_dataset(x@data)
142146
x@data$geometry <- x@data$geometry * R

0 commit comments

Comments
 (0)