|
| 1 | + |
1 | 2 | test_that("s2_cap works", {
|
2 |
| - s2_cap(s2_data_countries("Antarctica")) |
3 |
| - s2_cap(s2_data_countries("Netherlands")) |
4 |
| - s2_cap(s2_data_countries("Fiji")) |
| 3 | + cap_ant <- s2_data_countries("Antarctica") |
| 4 | + expect_is(s2_cap(cap_ant), "data.frame") |
| 5 | + expect_identical(nrow(s2_cap(cap_ant)), 1L) |
| 6 | + expect_true(s2_cap(cap_ant)$lat < -80) |
| 7 | + expect_true(s2_cap(cap_ant)$angle > 20) |
| 8 | + |
| 9 | + expect_identical(nrow(s2_cap(s2_data_countries(c("Antarctica", "Netherlands")))), 2L) |
| 10 | + |
| 11 | + expect_true(s2_cap(s2_data_countries("Netherlands"))$angle < 2) |
| 12 | + expect_true(s2_cap(s2_data_countries("Fiji"))$angle < 2) |
5 | 13 | })
|
6 | 14 |
|
7 | 15 | test_that("s2_lat_lng_rect works", {
|
8 |
| - s2_lat_lng_rect(s2_data_countries("Antarctica")) |
9 |
| - s2_lat_lng_rect(s2_data_countries("Netherlands")) |
10 |
| - s2_lat_lng_rect(s2_data_countries("Fiji")) |
11 |
| - s2_lat_lng_rect("MULTIPOINT(-179 0,179 1,-180 10)") |
12 |
| - s2_lat_lng_rect("LINESTRING(-179 0,179 1)") |
| 16 | + rect_ant <- s2_lat_lng_rect(s2_data_countries("Antarctica")) |
| 17 | + expect_is(rect_ant, "data.frame") |
| 18 | + expect_named(rect_ant, c("lat_lo", "lat_hi", "lng_lo", "lng_hi", "lat_cnt", "lng_cnt")) |
| 19 | + expect_identical(nrow(s2_lat_lng_rect(s2_data_countries(c("Antarctica", "Netherlands")))), 2L) |
| 20 | + expect_equal(rect_ant$lng_lo, -180) |
| 21 | + expect_equal(rect_ant$lng_hi, 180) |
| 22 | + expect_equal(rect_ant$lat_lo, -90) |
| 23 | + expect_true(rect_ant$lat_hi < -60) |
| 24 | + |
| 25 | + expect_identical(nrow(s2_lat_lng_rect(s2_data_countries(c("Antarctica", "Netherlands")))), 2L) |
| 26 | + |
| 27 | + rect_nl <- s2_lat_lng_rect(s2_data_countries("Netherlands")) |
| 28 | + expect_true((rect_nl$lng_hi - rect_nl$lng_lo) < 4) |
| 29 | + |
| 30 | + rect_fiji <- s2_lat_lng_rect(s2_data_countries("Fiji")) |
| 31 | + expect_true(rect_fiji$lng_hi < rect_fiji$lng_lo) |
| 32 | + |
| 33 | + rect_multipoint <- s2_lat_lng_rect("MULTIPOINT(-179 0,179 1,-180 10)") |
| 34 | + expect_equal(rect_multipoint$lat_lo, 0) |
| 35 | + expect_equal(rect_multipoint$lat_hi, 10) |
| 36 | + expect_equal(rect_multipoint$lng_lo, 179) |
| 37 | + expect_equal(rect_multipoint$lng_hi, -179) |
| 38 | + |
| 39 | + rect_linestring <- s2_lat_lng_rect("LINESTRING(-179 0,179 1)") |
| 40 | + expect_equal(rect_linestring$lat_lo, 0) |
| 41 | + expect_equal(rect_linestring$lat_hi, 1) |
| 42 | + expect_equal(rect_linestring$lng_lo, 179) |
| 43 | + expect_equal(rect_linestring$lng_hi, -179) |
13 | 44 | })
|
0 commit comments