Skip to content

Commit 2650d4a

Browse files
authored
fix: Fix vctrs methods for forthcoming vctrs release (#231)
* Increment version number to 0.9.4.9000 * add missing methods + redocument * passing tests with dev vctrs * remove badly added methods * NEWS * nope
1 parent c5c7a6e commit 2650d4a

File tree

6 files changed

+49
-3
lines changed

6 files changed

+49
-3
lines changed

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: wk
22
Title: Lightweight Well-Known Geometry Parsing
3-
Version: 0.9.4
3+
Version: 0.9.4.9000
44
Authors@R:
55
c(
66
person(given = "Dewey",
@@ -31,7 +31,7 @@ Description: Provides a minimal R and C++ API for parsing
3131
License: MIT + file LICENSE
3232
Encoding: UTF-8
3333
Roxygen: list(markdown = TRUE)
34-
RoxygenNote: 7.2.3
34+
RoxygenNote: 7.3.2
3535
Suggests:
3636
testthat (>= 3.0.0),
3737
vctrs (>= 0.3.0),

NAMESPACE

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,9 @@ S3method(rep_len,wk_vctr)
115115
S3method(str,wk_rcrd)
116116
S3method(str,wk_vctr)
117117
S3method(vec_cast.wk_crc,default)
118+
S3method(vec_cast.wk_crc,wk_crc)
118119
S3method(vec_cast.wk_rct,default)
120+
S3method(vec_cast.wk_rct,wk_rct)
119121
S3method(vec_cast.wk_wkb,default)
120122
S3method(vec_cast.wk_wkb,wk_crc)
121123
S3method(vec_cast.wk_wkb,wk_rct)
@@ -274,6 +276,7 @@ S3method(wk_is_geodesic,data.frame)
274276
S3method(wk_is_geodesic,default)
275277
S3method(wk_is_geodesic,wk_wkb)
276278
S3method(wk_is_geodesic,wk_wkt)
279+
S3method(wk_is_geodesic,wk_xy)
277280
S3method(wk_meta,default)
278281
S3method(wk_plot,default)
279282
S3method(wk_restore,data.frame)
@@ -291,6 +294,7 @@ S3method(wk_set_geodesic,data.frame)
291294
S3method(wk_set_geodesic,default)
292295
S3method(wk_set_geodesic,wk_wkb)
293296
S3method(wk_set_geodesic,wk_wkt)
297+
S3method(wk_set_geodesic,wk_xy)
294298
S3method(wk_trans_inverse,wk_trans_affine)
295299
S3method(wk_translate,data.frame)
296300
S3method(wk_translate,default)

NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# wk (development version)
2+
3+
- Ensure package tests pass against forthcoming vctrs (#231).
4+
15
# wk 0.9.4
26

37
- Ensure package tests pass against sf 1.0-18 (#224, #225).

R/pkg-vctrs.R

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,24 +56,28 @@ vec_cast.wk_wkb.wk_wkt <- function(x, to, ...) {
5656
#' @method vec_cast.wk_wkb wk_xy
5757
#' @export
5858
vec_cast.wk_wkb.wk_xy <- function(x, to, ...) {
59+
wk_is_geodesic(x) <- wk_is_geodesic(to)
5960
wk_translate(x, to)
6061
}
6162

6263
#' @method vec_cast.wk_wkb wk_xyz
6364
#' @export
6465
vec_cast.wk_wkb.wk_xyz <- function(x, to, ...) {
66+
wk_is_geodesic(x) <- wk_is_geodesic(to)
6567
wk_translate(x, to)
6668
}
6769

6870
#' @method vec_cast.wk_wkb wk_xym
6971
#' @export
7072
vec_cast.wk_wkb.wk_xym <- function(x, to, ...) {
73+
wk_is_geodesic(x) <- wk_is_geodesic(to)
7174
wk_translate(x, to)
7275
}
7376

7477
#' @method vec_cast.wk_wkb wk_xyzm
7578
#' @export
7679
vec_cast.wk_wkb.wk_xyzm <- function(x, to, ...) {
80+
wk_is_geodesic(x) <- wk_is_geodesic(to)
7781
wk_translate(x, to)
7882
}
7983

@@ -195,24 +199,28 @@ vec_cast.wk_wkt.wk_wkb <- function(x, to, ...) {
195199
#' @method vec_cast.wk_wkt wk_xy
196200
#' @export
197201
vec_cast.wk_wkt.wk_xy <- function(x, to, ...) {
202+
wk_is_geodesic(x) <- wk_is_geodesic(to)
198203
wk_translate(x, to)
199204
}
200205

201206
#' @method vec_cast.wk_wkt wk_xyz
202207
#' @export
203208
vec_cast.wk_wkt.wk_xyz <- function(x, to, ...) {
209+
wk_is_geodesic(x) <- wk_is_geodesic(to)
204210
wk_translate(x, to)
205211
}
206212

207213
#' @method vec_cast.wk_wkt wk_xym
208214
#' @export
209215
vec_cast.wk_wkt.wk_xym <- function(x, to, ...) {
216+
wk_is_geodesic(x) <- wk_is_geodesic(to)
210217
wk_translate(x, to)
211218
}
212219

213220
#' @method vec_cast.wk_wkt wk_xyzm
214221
#' @export
215222
vec_cast.wk_wkt.wk_xyzm <- function(x, to, ...) {
223+
wk_is_geodesic(x) <- wk_is_geodesic(to)
216224
wk_translate(x, to)
217225
}
218226

@@ -832,6 +840,14 @@ vec_ptype2.wk_rct <- function(x, y, ...) {
832840
UseMethod("vec_ptype2.wk_rct", y) # nocov
833841
}
834842

843+
#' @method vec_cast.wk_rct wk_rct
844+
#' @export
845+
vec_cast.wk_rct.wk_rct <- function(x, to, ...) {
846+
wk_crs_output(x, to)
847+
wk_is_geodesic_output(x, to)
848+
x
849+
}
850+
835851
#' @method vec_ptype2.wk_rct wk_rct
836852
#' @export
837853
vec_ptype2.wk_rct.wk_rct <- function(x, y, ..., x_arg = "x", y_arg = "y") {
@@ -905,6 +921,14 @@ vec_cast.wk_crc.default <- function(x, to, ...) {
905921
vctrs::vec_default_cast(x, to) # nocov
906922
}
907923

924+
#' @method vec_cast.wk_crc wk_crc
925+
#' @export
926+
vec_cast.wk_crc.wk_crc <- function(x, to, ...) {
927+
wk_crs_output(x, to)
928+
wk_is_geodesic_output(x, to)
929+
x
930+
}
931+
908932
#' @rdname vctrs-methods
909933
#' @export vec_ptype2.wk_crc
910934
vec_ptype2.wk_crc <- function(x, y, ...) {

R/wk-crs.R

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,11 @@ wk_is_geodesic.wk_wkt <- function(x) {
184184
attr(x, "geodesic", exact = TRUE) %||% FALSE
185185
}
186186

187+
#' @export
188+
wk_is_geodesic.wk_xy <- function(x) {
189+
attr(x, "geodesic", exact = TRUE) %||% FALSE
190+
}
191+
187192
#' @export
188193
wk_set_geodesic.default <- function(x, geodesic) {
189194
if (geodesic) {
@@ -210,6 +215,12 @@ wk_set_geodesic.wk_wkt <- function(x, geodesic) {
210215
x
211216
}
212217

218+
#' @export
219+
wk_set_geodesic.wk_xy <- function(x, geodesic) {
220+
attr(x, "geodesic") <- geodesic_attr(geodesic)
221+
x
222+
}
223+
213224
geodesic_attr <- function(geodesic) {
214225
if (!is.logical(geodesic) || (length(geodesic) != 1L)) {
215226
stop("`geodesic` must be TRUE, FALSE, or NA", call. = FALSE)

tests/testthat/test-wk-crs.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ test_that("geodesic getting and setting works for wkt", {
5252
})
5353

5454
test_that("geodesic setting gives a warning when this isn't supported", {
55-
expect_warning(wk_set_geodesic(xy(), TRUE), "for object of class 'wk_xy'")
55+
expect_warning(
56+
wk_set_geodesic(structure(list(), class = "foofy"), TRUE),
57+
"for object of class 'foofy'"
58+
)
5659
})
5760

5861
test_that("wk_geodesic_output() works", {

0 commit comments

Comments
 (0)