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
32 changes: 30 additions & 2 deletions R/geocode.R
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,37 @@ geocode <- function(location, output = c("latlon", "latlona", "more", "all"),

# geocode ply and out
if(output == "latlon" || output == "latlona" || output == "more"){
return(ldply(as.list(location), geocode, output = output, source = source, messaging = messaging, inject = inject))
return(
ldply(
as.list(location),
geocode,
output = output,
source = source,
messaging = messaging,
force = force,
urlonly = urlonly,
override_limit = override_limit,
nameType = nameType,
ext = ext,
inject = inject
)
)
} else { # output = all
return(llply(as.list(location), geocode, output = output, source = source, messaging = messaging, inject = inject))
return(
llply(
as.list(location),
geocode,
output = output,
source = source,
messaging = messaging,
force = force,
urlonly = urlonly,
override_limit = override_limit,
nameType = nameType,
ext = ext,
inject = inject
)
)
}
}

Expand Down
24 changes: 24 additions & 0 deletions tests/testthat/test-geocode.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
context("geocode")

register_google(key = Sys.getenv("GOOGLE_GEOCODE_KEY"))

test_that("geocode(urlonly = TRUE) returns url.", {
res <- geocode("Houston, Texas", urlonly = TRUE)
expect_is(res, "character")
expect_match(res, "Houston%2C%20Texas", fixed = TRUE)
expect_message(res, regexp = NA) # No "Source : ..." message
})

test_that("geocode(urlonly = TRUE) works with multiple locations.", {
res <- geocode(c("Houston, Texas", "Washington, DC"), urlonly = TRUE)
expect_match(res[[1, 1]], "Houston%2C%20Texas", fixed = TRUE)
expect_match(res[[2, 1]], "Washington%2C%20DC", fixed = TRUE)
expect_message(res, regexp = NA) # No "Source : ..." message, see #207
})

test_that("geocode(ext) works with multiple locations.", {
res <- geocode(c("Houston", "Washington"), urlonly = TRUE, ext = "ca")
expect_match(res[[1]], ".ca", fixed = TRUE)
expect_match(res[[2, 1]], ".ca", fixed = TRUE)
expect_message(res, regexp = NA) # No "Source : ..." message, see #207
})