From 1e2c9648ef6309782261eefc16a575ae2d750c49 Mon Sep 17 00:00:00 2001 From: Daniel Possenriede Date: Mon, 26 Mar 2018 17:45:22 +0200 Subject: [PATCH 1/2] geocode: add missing parameters to ldply call, closes #207 --- R/geocode.R | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/R/geocode.R b/R/geocode.R index 27b7a01..3cee8bb 100644 --- a/R/geocode.R +++ b/R/geocode.R @@ -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 + ) + ) } } From 8f4894e6ee7693ad21dd8d78dcd05c4e0016319e Mon Sep 17 00:00:00 2001 From: Daniel Possenriede Date: Fri, 26 Oct 2018 20:25:54 +0200 Subject: [PATCH 2/2] add tests re #207 / #210 --- tests/testthat/test-geocode.R | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 tests/testthat/test-geocode.R diff --git a/tests/testthat/test-geocode.R b/tests/testthat/test-geocode.R new file mode 100644 index 0000000..cb05198 --- /dev/null +++ b/tests/testthat/test-geocode.R @@ -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 +})