Tests in tests/testthat/test-filter_spatial() are not currently passing. To run them: test(filter = "filter_spatial"). Here are two key pieces of the output:
test-filter_spatial.R:31: error: Alameda County (sp)
no applicable method for 'st_transform' applied to an object of class "c('SpatialPolygonsDataFrame', 'SpatialPolygons', 'Spatial', 'SpatialPolygonsNULL', 'SpatialVector')"
Backtrace:
1. testthat::expect_success(...) tests/testthat/test-filter_spatial.R:31:2
2. mapview::mapview(test_tracts)
10. mapview::addFeatures(., ALA_county_WGS84, fill = FALSE, color = "red")
16. leafem::addFeatures(map = map, data = data, pane = pane, ...)
17. sf::st_transform(data, sf::st_crs(map@object[[1]]))
test-filter_spatial.R:76: error: Richmond CARE Impact Region
unable to find an inherited method for function 'proj4string' for signature '"sf"'
Backtrace:
1. testthat::expect_message(...) tests/testthat/test-filter_spatial.R:76:2
6. geotools::filter_spatial(spobj1, spobj2)
7. geotools::filter_spatial_sp(x, y, FUN = FUN, ..., verbose = verbose) R/filter_spatial.R:26:4
8. sp::proj4string(spobj2) R/filter_spatial.R:92:2
It might be necessary to either:
- Make
filter_spatial(spobj1, spobj2, ...) an S4 method, so that it dispatches based on the class of both spobj1 and spobj2; or
- Retain it as an S3 method — dispatching only on the class of
spobj1 — but put some if ... else logic inside filter_spatial() to coerce the class of spobj2 to the class of spobj1, before it dispatches to either filter_spatial_sp() or filter_spatial_sf(), either of which should expect both spobj1 and spobj2 to be of the same class.
Tests in
tests/testthat/test-filter_spatial()are not currently passing. To run them:test(filter = "filter_spatial"). Here are two key pieces of the output:It might be necessary to either:
filter_spatial(spobj1, spobj2, ...)an S4 method, so that it dispatches based on the class of bothspobj1andspobj2; orspobj1— but put someif ... elselogic insidefilter_spatial()to coerce the class ofspobj2to the class ofspobj1, before it dispatches to eitherfilter_spatial_sp()orfilter_spatial_sf(), either of which should expect bothspobj1andspobj2to be of the same class.