Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions R/geolocate_polygon.R
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ parse_polygon <- function(query,
# to avoid any issues, any polygons are converted to multipolygons
if(inherits(query, "sf") || inherits(query, "sfc")) {

if(length(query$geometry) < 2) {
if(length(sf::st_geometry(query)) < 2) {
out_query <- build_wkt(query)
} else {
# multiple polygons
n_polygons <- length(query$geometry)
n_polygons <- length(sf::st_geometry(query))
c("Too many polygons.",
i = "`galah_polygon` cannot accept more than 1 polygon at a time.",
x = "{n_polygons} polygons detected in spatial object.") |>
Expand Down
5 changes: 3 additions & 2 deletions R/geolocate_radius.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ parse_point_radius <- function(...,
}

# extract point coordinate values
lat <- sf::st_coordinates(coords)[1]
lon <- sf::st_coordinates(coords)[2]
# (`st_coordinates()` returns columns in X (longitude), Y (latitude) order)
lon <- sf::st_coordinates(coords)[1]
lat <- sf::st_coordinates(coords)[2]

} else { # Coords are supplied as lon/lat arguments

Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-geolocate_radius.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ test_that("`geolocate_radius()` assigns default radius when missing argument", {
})

test_that("`geolocate_radius()` returns radius for sf_POINT object", {
point <- sf::st_sfc(sf::st_point(c(-33.66741, 151.3174)),
point <- sf::st_sfc(sf::st_point(c(151.3174, -33.66741)),
crs = 4326)
expected_object <- list(lat = -33.66741,
lon = 151.3174,
Expand Down