Skip to content

Commit f6b87a3

Browse files
committed
Use [[ for sf_extSoftVersion() access
1 parent ee27180 commit f6b87a3

File tree

7 files changed

+12
-12
lines changed

7 files changed

+12
-12
lines changed

tests/sfc.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ p <- st_sample(x, 10)
200200
x = st_sfc(st_polygon(list(rbind(c(-180,-90),c(180,-90),c(180,90),c(-180,90),c(-180,-90)))),
201201
crs=st_crs(4326))
202202
#FIXME:
203-
# if (sf_extSoftVersion()["proj.4"] >= "4.9.0") # lwgeom breaks on this
203+
# if (sf_extSoftVersion()[["proj.4"]] >= "4.9.0") # lwgeom breaks on this
204204
# (p <- st_sample(x, 10))
205205
pt = st_multipoint(matrix(1:20,,2))
206206
st_sample(p, 3)

tests/testthat/test_crs.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,18 @@ test_that("sf_proj_info works", {
4141
})
4242

4343
test_that("sf_proj_info works for datum files", {
44-
skip_if_not(sf_extSoftVersion()[["proj.4"]] < "6.0.0")
44+
skip_if(sf_extSoftVersion()[["proj.4"]] >= "6.0.0")
4545
expect_silent(x <- sf_proj_info("have_datum_files"))
4646
})
4747

4848
test_that("$.crs works", {
49-
skip_if_not(sf_extSoftVersion()[["proj.4"]] < "6.0.0")
49+
skip_if(sf_extSoftVersion()[["proj.4"]] >= "6.0.0")
5050
expect_false(is.null(st_crs("+init=epsg:3857")$epsg))
5151
expect_type(st_crs("+init=epsg:3857")$proj4string, "character")
5252
})
5353

5454
test_that("$.crs works with +units", {
55-
skip_if_not(sf_extSoftVersion()[["proj.4"]] < "6.0.0")
55+
skip_if(sf_extSoftVersion()[["proj.4"]] >= "6.0.0")
5656
expect_type(st_crs("+init=epsg:3857 +units=m")$b, "double")
5757
expect_type(st_crs("+init=epsg:3857 +units=m")$units, "character")
5858
})

tests/testthat/test_gdal.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ test_that("st_transform works", {
1212
#attr(s2.tr, "crs")$proj4string = ""
1313
st_crs(s1.tr) = NA_crs_
1414
# st_crs(s2.tr) = NA_crs_
15-
# if (sf_extSoftVersion()["proj.4"] < "5.0.0") # FIXME:
15+
# if (sf_extSoftVersion()[["proj.4"]] < "5.0.0") # FIXME:
1616
# expect_equal(s1.tr, s2.tr)
1717

1818
toCrs = 3857
1919
s1.tr = st_transform(s, toCrs)
2020
#attr(s1.tr, "crs")$proj4string = ""
2121
st_crs(s1.tr) = NA_crs_
2222
# st_crs(s2.tr) = NA_crs_
23-
# if (sf_extSoftVersion()["proj.4"] < "5.0.0") # FIXME:
23+
# if (sf_extSoftVersion()[["proj.4"]] < "5.0.0") # FIXME:
2424
# expect_equal(s1.tr, s2.tr)
2525

2626
expect_silent({
@@ -42,8 +42,8 @@ test_that("st_wrap_dateline works", {
4242
})
4343

4444
test_that('gdal_subdatasets works', {
45-
skip_if_not(sf_extSoftVersion()[["GDAL"]] >= "2.1.0")
46-
skip_if_not(sf_extSoftVersion()[["GDAL"]] < "2.5.0") # FIXME:
45+
skip_if(sf_extSoftVersion()[["GDAL"]] < "2.1.0")
46+
skip_if(sf_extSoftVersion()[["GDAL"]] >= "2.5.0") # FIXME:
4747
skip_on_os("mac") # FIXME:
4848
fname = system.file("nc/cropped.nc", package = "sf")
4949
sd2 = gdal_subdatasets(fname)[[2]]

tests/testthat/test_geos.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ test_that("st_difference works with partially overlapping geometries", {
172172
pl3 = st_polygon(list(matrix(c(0, 1.25, 2, 1.25, 1, 2.5, 0, 1.25), byrow = TRUE, ncol = 2)))
173173
in1 = st_sfc(list(pl1, pl2, pl3))
174174
in2 = st_sf(order = c("A", "B", "C"), geometry = st_sfc(list(pl1, pl2, pl3), crs = 4326), agr = "constant")
175-
if (package_version(gsub("[a-zA-Z]", "", sf_extSoftVersion()["GEOS"])) < "3.9.0") {
175+
if (package_version(gsub("[a-zA-Z]", "", sf_extSoftVersion()[["GEOS"]])) < "3.9.0") {
176176
correct_geom = st_sfc(list(
177177
st_polygon(list(matrix(c(0, 2, 1, 0, 0, 0, 1, 0), ncol = 2))),
178178
st_polygon(list(matrix(c(0.5, 0, 1, 2, 1.5, 1, 0.5, 0.5, 0.5, 1.5, 0.5, 0.5, 1, 0.5), ncol = 2))),

tests/testthat/test_sp.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ test_that("we can convert points & lines to and from sp objects", {
2424

2525
test_that("we can convert SpatialPolygons objects without SF comments to sfc and back", {
2626
skip_if_not_installed("sp")
27-
# skip_if_not(package_version(sf_extSoftVersion()["GEOS"]) >= "3.11.0"); #2079
27+
# skip_if_not(package_version(sf_extSoftVersion()[["GEOS"]]) >= "3.11.0"); #2079
2828
library(sp)
2929
# nested holes https://github.com/r-spatial/evolution/issues/9
3030
p1 <- Polygon(cbind(x=c(0, 0, 10, 10, 0), y=c(0, 10, 10, 0, 0)), hole=FALSE) # I

tests/testthat/test_write.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ test_that("FID feature ID gets written and read", {
122122
tf <- paste0(tempfile(), ".geojson")
123123
write_sf(nc, tf, fid_column_name = "f_id")
124124
nc2 = read_sf(tf, fid_column_name = "f_id")
125-
if (sf_extSoftVersion()["GDAL"] >= "2.3.2")
125+
if (sf_extSoftVersion()[["GDAL"]] >= "2.3.2")
126126
expect_equal(nc$f_id, nc2$f_id)
127127
})
128128

tests/testthat/test_zm_range.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ test_that("zmrange works on more compliated examples", {
120120

121121
test_that("transform includes zm in output", {
122122

123-
skip_if_not(sf_extSoftVersion()["GDAL"] > "2.1.0")
123+
skip_if(sf_extSoftVersion()[["GDAL"]] <= "2.1.0")
124124

125125
p1 = st_point(c(7,52,52))
126126
p2 = st_point(c(-30,20,20))

0 commit comments

Comments
 (0)