|
1 | 1 | context ("sp-osm")
|
2 | 2 |
|
3 | 3 | test_that ("multipolygon", {
|
4 |
| - x_sf <- sf::st_read (test_path ("fixtures", "osm-multi.osm"), |
5 |
| - layer = "multipolygons", quiet = TRUE |
6 |
| - ) |
| 4 | + osm_multi <- test_path ("fixtures", "osm-multi.osm") |
| 5 | + x_sf <- sf::st_read (osm_multi, layer = "multipolygons", quiet = TRUE) |
7 | 6 | x_sp <- as (x_sf, "Spatial")
|
8 | 7 | q0 <- opq (bbox = c (1, 1, 5, 5))
|
9 |
| - x <- osmdata_sp (q0, test_path ("fixtures", "osm-multi.osm"))$osm_multipolygons |
| 8 | + x <- osmdata_sp (q0, osm_multi)$osm_multipolygons |
10 | 9 | # GDAL spits out a whole lot of generic field names, so first the
|
11 | 10 | # two have to be reduced to common fields.
|
12 | 11 | x <- x [, which (names (x) %in% names (x_sp))]
|
@@ -59,12 +58,11 @@ test_that ("multipolygon", {
|
59 | 58 |
|
60 | 59 |
|
61 | 60 | test_that ("multilinestring", {
|
62 |
| - x_sf <- sf::st_read (test_path ("fixtures", "osm-multi.osm"), |
63 |
| - layer = "multilinestrings", quiet = TRUE |
64 |
| - ) |
| 61 | + osm_multi <- test_path ("fixtures", "osm-multi.osm") |
| 62 | + x_sf <- sf::st_read (osm_multi, layer = "multilinestrings", quiet = TRUE) |
65 | 63 | x_sp <- as (x_sf, "Spatial")
|
66 | 64 | q0 <- opq (bbox = c (1, 1, 5, 5))
|
67 |
| - x <- osmdata_sp (q0, test_path ("fixtures", "osm-multi.osm"))$osm_multilines |
| 65 | + x <- osmdata_sp (q0, osm_multi)$osm_multilines |
68 | 66 | x <- x [, which (names (x) %in% names (x_sp))]
|
69 | 67 | x_sp <- x_sp [, which (names (x_sp) %in% names (x))]
|
70 | 68 | rownames (slot (x, "data")) <- rownames (slot (x_sp, "data"))
|
@@ -96,12 +94,11 @@ test_that ("multilinestring", {
|
96 | 94 | })
|
97 | 95 |
|
98 | 96 | test_that ("ways", {
|
99 |
| - x_sf <- sf::st_read (test_path ("fixtures", "osm-ways.osm"), |
100 |
| - layer = "lines", quiet = TRUE |
101 |
| - ) |
| 97 | + osm_ways <- test_path ("fixtures", "osm-ways.osm") |
| 98 | + x_sf <- sf::st_read (osm_ways, layer = "lines", quiet = TRUE) |
102 | 99 | x_sp <- as (x_sf, "Spatial")
|
103 | 100 | q0 <- opq (bbox = c (1, 1, 5, 5))
|
104 |
| - x <- osmdata_sp (q0, test_path ("fixtures", "osm-ways.osm"))$osm_lines |
| 101 | + x <- osmdata_sp (q0, osm_ways)$osm_lines |
105 | 102 | x <- x [, which (names (x) %in% names (x_sp))]
|
106 | 103 | x_sp <- x_sp [, which (names (x_sp) %in% names (x))]
|
107 | 104 | np <- length (slot (slot (x, "lines") [[1]], "Lines"))
|
|
0 commit comments