Skip to content

Commit

Permalink
Add tests for type radius in galah_geolocate() #216
Browse files Browse the repository at this point in the history
  • Loading branch information
daxkellie committed Apr 3, 2024
1 parent a10c43b commit a8f0dbe
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion tests/testthat/test-galah_geolocate.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,23 @@ test_that("galah_geolocate works when type is set to polygon", {
expect_match(galah_geolocate(wkt, type = "polygon"), "MULTIPOLYGON")
})

test_that("galah_geolocate switches to use galah_bbox when type is set to bbox", {
test_that("galah_geolocate switches to use galah_bbox when `type = bbox`", {
wkt <- "POLYGON((142.36228 -29.00703,142.74131 -29.00703,142.74131 -29.39064,142.36228 -29.39064,142.36228 -29.00703))"
obj_sf <- wkt |> sf::st_as_sfc()
expect_error(galah_geolocate(wkt, type = "bbox"))
expect_match(galah_geolocate(obj_sf, type = "bbox"), "MULTIPOLYGON")
})

test_that("galah_geolocate switches to use galah_radius when `type = radius`", {
wkt <- "POLYGON((142.36228 -29.00703,142.74131 -29.00703,142.74131 -29.39064,142.36228 -29.39064,142.36228 -29.00703))"
obj_sf <- wkt |> sf::st_as_sfc()
expect_error(galah_geolocate(wkt, type = "radius"), "Missing")
expect_error(galah_geolocate(obj_sf, type = "radius"), "Invalid spatial object")
expect_equal(galah_geolocate(lat = -33.66741,
lon = 151.3174,
radius = 2,
type = "radius"),
list(lat = -33.66741,
lon = 151.3174,
radius = 2))
})

0 comments on commit a8f0dbe

Please sign in to comment.