.
+#'
+#' @return a logical.
+#'
+#' @seealso
+#'
+#'
+#' @examples
+#' \donttest{
+#' nominatim_check_access()
+#' }
+#' @keywords internal
+#' @export
+nominatim_check_access <- function() {
+ url <- "https://nominatim.openstreetmap.org/status.php?format=json"
+ destfile <- tempfile(fileext = ".json")
+
+ api_res <- api_call(url, destfile, TRUE)
+
+ # nocov start
+ if (isFALSE(api_res)) {
+ return(FALSE)
+ }
+ # nocov end
+ result <- dplyr::as_tibble(jsonlite::fromJSON(destfile, flatten = TRUE))
+
+ # nocov start
+ if (result$status == 0 || result$message == "OK") {
+ return(TRUE)
+ } else {
+ return(FALSE)
+ }
+ # nocov end
+}
+
+skip_if_api_server <- function() {
+ # nocov start
+ if (nominatim_check_access()) {
+ return(invisible(TRUE))
+ }
+
+ if (requireNamespace("testthat", quietly = TRUE)) {
+ testthat::skip("Nominatim API not reachable")
+ }
+ return(invisible())
+ # nocov end
+}
+
+
+#' Helper function for centralize API queries
+#'
+#' @description
+#' A wrapper of [utils::download.file()]. On warning on error it will
+#' retry the call. Requests are adjusted to the rate of 1 query per second.
+#'
+#' See [Nominatim Usage
+#' Policy](https://operations.osmfoundation.org/policies/nominatim/).
+#'
+#' @family api_management
+#'
+#' @inheritParams utils::download.file
+#' @return A logical `TRUE/FALSE`
+#'
+#' @keywords internal
+#'
+api_call <- function(url, destfile, quiet) {
+ # nocov start
+ dwn_res <-
+ tryCatch(
+ download.file(url, destfile = destfile, quiet = quiet, mode = "wb"),
+ warning = function(e) {
+ return(FALSE)
+ },
+ error = function(e) {
+ return(FALSE)
+ }
+ )
+ # nocov end
+ # Always sleep to make 1 call per sec
+ Sys.sleep(1)
+
+ # nocov start
+ if (isFALSE(dwn_res)) {
+ if (isFALSE(quiet)) message("Retrying query")
+ Sys.sleep(1)
+
+ dwn_res <-
+ tryCatch(
+ download.file(url, destfile = destfile, quiet = quiet, mode = "wb"),
+ warning = function(e) {
+ return(FALSE)
+ },
+ error = function(e) {
+ return(FALSE)
+ }
+ )
+ }
+
+ if (isFALSE(dwn_res)) {
+ return(FALSE)
+ } else {
+ return(TRUE)
+ }
+ # nocov end
+}
diff --git a/R/nominatimlite-package.R b/R/nominatimlite-package.R
index 91289122..aaba2ada 100644
--- a/R/nominatimlite-package.R
+++ b/R/nominatimlite-package.R
@@ -8,5 +8,5 @@
NULL
# import stuffs
-#' @importFrom utils download.file
+#' @importFrom utils download.file txtProgressBar setTxtProgressBar
NULL
diff --git a/R/reverse_geo_lite.R b/R/reverse_geo_lite.R
index 444e360c..c1384fdb 100644
--- a/R/reverse_geo_lite.R
+++ b/R/reverse_geo_lite.R
@@ -47,7 +47,7 @@
#'
#' ```
#'
-#' @return A `tibble` with the results.
+#' @return A \CRANpkg{tibble} with the results.
#'
#' @examplesIf nominatim_check_access()
#' \donttest{
@@ -78,6 +78,7 @@ reverse_geo_lite <- function(lat,
full_results = FALSE,
return_coords = TRUE,
verbose = FALSE,
+ progressbar = TRUE,
custom_query = list()) {
# Check inputs
if (!is.numeric(lat) || !is.numeric(long)) {
@@ -111,8 +112,22 @@ reverse_geo_lite <- function(lat,
)
key <- dplyr::distinct(init_key)
+ # Set progress bar
+ ntot <- nrow(key)
+ # Set progress bar if n > 1
+ progressbar <- all(progressbar, ntot > 1)
+ if (progressbar) {
+ pb <- txtProgressBar(min = 0, max = ntot, width = 50, style = 3)
+ }
+
+ seql <- seq(1, ntot, 1)
- all_res <- lapply(seq_len(nrow(key)), function(x) {
+
+ all_res <- lapply(seql, function(x) {
+ if (progressbar) {
+ setTxtProgressBar(pb, x)
+ cat(paste0(" (", x, "/", ntot, ") "))
+ }
rw <- key[x, ]
res_single <- reverse_geo_lite_single(
as.double(rw$lat_cap_int),
@@ -128,7 +143,7 @@ reverse_geo_lite <- function(lat,
res_single
})
-
+ if (progressbar) close(pb)
all_res <- dplyr::bind_rows(all_res)
all_res <- dplyr::left_join(init_key[, c(1, 2)], all_res,
diff --git a/R/reverse_geo_lite_sf.R b/R/reverse_geo_lite_sf.R
index f4365a99..c15e4a27 100644
--- a/R/reverse_geo_lite_sf.R
+++ b/R/reverse_geo_lite_sf.R
@@ -16,7 +16,7 @@
#' @inheritSection reverse_geo_lite About Zooming
#' @inheritSection geo_lite_sf About Geometry Types
#'
-#' @return A `sf` object with the results.
+#' @return A \CRANpkg{sf} object with the results.
#'
#' @examplesIf nominatim_check_access()
#' \donttest{
@@ -67,6 +67,7 @@ reverse_geo_lite_sf <- function(lat,
full_results = FALSE,
return_coords = TRUE,
verbose = FALSE,
+ progressbar = TRUE,
custom_query = list(),
points_only = TRUE) {
# Check inputs
@@ -101,7 +102,22 @@ reverse_geo_lite_sf <- function(lat,
)
key <- dplyr::distinct(init_key)
- all_res <- lapply(seq_len(nrow(key)), function(x) {
+ # Set progress bar
+ ntot <- nrow(key)
+ # Set progress bar if n > 1
+ progressbar <- all(progressbar, ntot > 1)
+ if (progressbar) {
+ pb <- txtProgressBar(min = 0, max = ntot, width = 50, style = 3)
+ }
+
+ seql <- seq(1, ntot, 1)
+
+
+ all_res <- lapply(seql, function(x) {
+ if (progressbar) {
+ setTxtProgressBar(pb, x)
+ cat(paste0(" (", x, "/", ntot, ") "))
+ }
rw <- key[x, ]
res_single <- reverse_geo_lite_sf_single(
as.double(rw$lat_cap_int),
@@ -118,6 +134,7 @@ reverse_geo_lite_sf <- function(lat,
res_single
})
+ if (progressbar) close(pb)
all_res <- dplyr::bind_rows(all_res)
diff --git a/README.md b/README.md
index 15981cc9..19d35c2a 100644
--- a/README.md
+++ b/README.md
@@ -156,6 +156,7 @@ some_addresses <- tribble(
# geocode the addresses
lat_longs <- geo_lite(some_addresses$addr, lat = "latitude", long = "longitude")
+#> | | | 0% | |================= | 33% (1/3) | |================================= | 67% (2/3) | |==================================================| 100% (3/3)
```
Only latitude and longitude are returned from the geocoder service in
@@ -180,6 +181,7 @@ reverse <- reverse_geo_lite(
lat = lat_longs$latitude, long = lat_longs$longitude,
address = "address_found"
)
+#> | | | 0% | |================= | 33% (1/3) | |================================= | 67% (2/3) | |==================================================| 100% (3/3)
```
| address_found | lat | lon |
@@ -195,7 +197,7 @@ the parameters available.
## Citation
-Hernangómez D (2023). nominatimlite: Interface with Nominatim API
+Hernangómez D (2024). nominatimlite: Interface with Nominatim API
Service.
doi:10.5281/zenodo.5113195,
https://dieghernan.github.io/nominatimlite/.
@@ -206,11 +208,11 @@ A BibTeX entry for LaTeX users is
@Manual{R-nominatimlite,
title = {{nominatimlite}: Interface with {Nominatim} {API} Service},
author = {Diego Hernangómez},
- year = {2023},
- version = {0.2.1},
+ year = {2024},
+ version = {0.2.1.9000},
doi = {10.5281/zenodo.5113195},
url = {https://dieghernan.github.io/nominatimlite/},
- abstract = {Lite interface for getting data from OSM service Nominatim . Extract coordinates from addresses, find places near a set of coordinates, search for amenities and return spatial objects on sf format.},
+ abstract = {Lite interface for getting data from OSM service Nominatim . Extract coordinates from addresses, find places near a set of coordinates and return spatial objects on sf format.},
}
## References
diff --git a/codemeta.json b/codemeta.json
index b9230e7e..cbcab856 100644
--- a/codemeta.json
+++ b/codemeta.json
@@ -2,13 +2,13 @@
"@context": "https://doi.org/10.5063/schema/codemeta-2.0",
"@type": "SoftwareSourceCode",
"identifier": "nominatimlite",
- "description": "Lite interface for getting data from 'OSM' service 'Nominatim' . Extract coordinates from addresses, find places near a set of coordinates, search for amenities and return spatial objects on 'sf' format.",
+ "description": "Lite interface for getting data from 'OSM' service 'Nominatim' . Extract coordinates from addresses, find places near a set of coordinates and return spatial objects on 'sf' format.",
"name": "nominatimlite: Interface with 'Nominatim' API Service",
"relatedLink": ["https://dieghernan.github.io/nominatimlite/", "https://CRAN.R-project.org/package=nominatimlite"],
"codeRepository": "https://github.com/dieghernan/nominatimlite",
"issueTracker": "https://github.com/dieghernan/nominatimlite/issues",
"license": "https://spdx.org/licenses/MIT",
- "version": "0.2.1",
+ "version": "0.2.1.9000",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
@@ -154,6 +154,18 @@
"sameAs": "https://CRAN.R-project.org/package=jsonlite"
},
"4": {
+ "@type": "SoftwareApplication",
+ "identifier": "lifecycle",
+ "name": "lifecycle",
+ "provider": {
+ "@id": "https://cran.r-project.org",
+ "@type": "Organization",
+ "name": "Comprehensive R Archive Network (CRAN)",
+ "url": "https://cran.r-project.org"
+ },
+ "sameAs": "https://CRAN.R-project.org/package=lifecycle"
+ },
+ "5": {
"@type": "SoftwareApplication",
"identifier": "sf",
"name": "sf",
@@ -166,7 +178,7 @@
},
"sameAs": "https://CRAN.R-project.org/package=sf"
},
- "5": {
+ "6": {
"@type": "SoftwareApplication",
"identifier": "utils",
"name": "utils"
@@ -175,11 +187,11 @@
},
"applicationCategory": "cartography",
"keywords": ["r", "geocoding", "openstreetmap", "address", "nominatim", "reverse-geocoding", "rstats", "shapefile", "r-package", "spatial", "cran", "api-wrapper", "api", "gis"],
- "fileSize": "258.67KB",
+ "fileSize": "251.765KB",
"citation": [
{
"@type": "SoftwareSourceCode",
- "datePublished": "2023",
+ "datePublished": "2024",
"author": [
{
"@type": "Person",
diff --git a/data/osm_amenities.rda b/data/osm_amenities.rda
deleted file mode 100644
index 34df3242..00000000
Binary files a/data/osm_amenities.rda and /dev/null differ
diff --git a/inst/WORDLIST b/inst/WORDLIST
index 71a12e32..9ef50f02 100644
--- a/inst/WORDLIST
+++ b/inst/WORDLIST
@@ -1,3 +1,4 @@
+Belanger
CMD
Cambon
CodeFactor
@@ -6,20 +7,21 @@ Geocode
Geocodes
Geocoding
Mapbox
+Maëlle
Nominatim
ORCID
OSM
OpenStreetMap
Padgham
+Possenriede
+Rudis
TomTom
Transamerica
+al
api
-atm
-bbq
-biergarten
-centre
codecov
de
+et
geocode
geocoded
geocoder
@@ -28,13 +30,9 @@ geolocated
ie
json
lon
-osm
osmdata
rlang
-stripclub
-swingerclub
-theatre
tibble
-townhall
+tidygeocoder
unnesting
vectorized
diff --git a/inst/schemaorg.json b/inst/schemaorg.json
index 2716cfcb..c637c64e 100644
--- a/inst/schemaorg.json
+++ b/inst/schemaorg.json
@@ -20,7 +20,7 @@
"familyName": "Hernangómez",
"givenName": "Diego"
},
- "description": "Lite interface for getting data from 'OSM' service 'Nominatim' . Extract coordinates from addresses, find places near a set of coordinates, search for amenities and return spatial objects on 'sf' format.",
+ "description": "Lite interface for getting data from 'OSM' service 'Nominatim' . Extract coordinates from addresses, find places near a set of coordinates and return spatial objects on 'sf' format.",
"license": "https://spdx.org/licenses/MIT",
"name": "nominatimlite: Interface with 'Nominatim' API Service",
"programmingLanguage": {
@@ -35,7 +35,7 @@
"url": "https://cran.r-project.org"
},
"runtimePlatform": "R version 4.3.2 (2023-10-31 ucrt)",
- "version": "0.2.1"
+ "version": "0.2.1.9000"
},
{
"id": "https://doi.org/10.5281/zenodo.5113195",
diff --git a/man/bbox_to_poly.Rd b/man/bbox_to_poly.Rd
index a44e85e0..5644db51 100644
--- a/man/bbox_to_poly.Rd
+++ b/man/bbox_to_poly.Rd
@@ -2,7 +2,7 @@
% Please edit documentation in R/bbox_to_poly.R
\name{bbox_to_poly}
\alias{bbox_to_poly}
-\title{Create a bounding box \code{sf} object}
+\title{Create a bounding box \CRANpkg{sf} object}
\usage{
bbox_to_poly(bbox = NA, xmin = NA, ymin = NA, xmax = NA, ymax = NA, crs = 4326)
}
@@ -64,14 +64,7 @@ if (any(!sf::st_is_empty(sfobj))) {
Get spatial (\code{sf}) objects:
\code{\link{geo_address_lookup_sf}()},
-\code{\link{geo_amenity_sf}()},
\code{\link{geo_lite_sf}()},
\code{\link{reverse_geo_lite_sf}()}
-
-Search amenities:
-\code{\link{geo_amenity_sf}()},
-\code{\link{geo_amenity}()},
-\code{\link{osm_amenities}}
}
-\concept{amenity}
\concept{spatial}
diff --git a/man/figures/README-pizzahut-1.png b/man/figures/README-pizzahut-1.png
index 75c8303a..3fbf34d4 100644
Binary files a/man/figures/README-pizzahut-1.png and b/man/figures/README-pizzahut-1.png differ
diff --git a/man/figures/README-statue_liberty-1.png b/man/figures/README-statue_liberty-1.png
index 57b48770..a9755839 100644
Binary files a/man/figures/README-statue_liberty-1.png and b/man/figures/README-statue_liberty-1.png differ
diff --git a/man/figures/lifecycle-archived.svg b/man/figures/lifecycle-archived.svg
new file mode 100644
index 00000000..745ab0c7
--- /dev/null
+++ b/man/figures/lifecycle-archived.svg
@@ -0,0 +1,21 @@
+
diff --git a/man/figures/lifecycle-defunct.svg b/man/figures/lifecycle-defunct.svg
new file mode 100644
index 00000000..d5c9559e
--- /dev/null
+++ b/man/figures/lifecycle-defunct.svg
@@ -0,0 +1,21 @@
+
diff --git a/man/figures/lifecycle-deprecated.svg b/man/figures/lifecycle-deprecated.svg
new file mode 100644
index 00000000..b61c57c3
--- /dev/null
+++ b/man/figures/lifecycle-deprecated.svg
@@ -0,0 +1,21 @@
+
diff --git a/man/figures/lifecycle-experimental.svg b/man/figures/lifecycle-experimental.svg
new file mode 100644
index 00000000..5d88fc2c
--- /dev/null
+++ b/man/figures/lifecycle-experimental.svg
@@ -0,0 +1,21 @@
+
diff --git a/man/figures/lifecycle-maturing.svg b/man/figures/lifecycle-maturing.svg
new file mode 100644
index 00000000..897370ec
--- /dev/null
+++ b/man/figures/lifecycle-maturing.svg
@@ -0,0 +1,21 @@
+
diff --git a/man/figures/lifecycle-questioning.svg b/man/figures/lifecycle-questioning.svg
new file mode 100644
index 00000000..7c1721d0
--- /dev/null
+++ b/man/figures/lifecycle-questioning.svg
@@ -0,0 +1,21 @@
+
diff --git a/man/figures/lifecycle-soft-deprecated.svg b/man/figures/lifecycle-soft-deprecated.svg
new file mode 100644
index 00000000..9c166ff3
--- /dev/null
+++ b/man/figures/lifecycle-soft-deprecated.svg
@@ -0,0 +1,21 @@
+
diff --git a/man/figures/lifecycle-stable.svg b/man/figures/lifecycle-stable.svg
new file mode 100644
index 00000000..9bf21e76
--- /dev/null
+++ b/man/figures/lifecycle-stable.svg
@@ -0,0 +1,29 @@
+
diff --git a/man/figures/lifecycle-superseded.svg b/man/figures/lifecycle-superseded.svg
new file mode 100644
index 00000000..db8d757f
--- /dev/null
+++ b/man/figures/lifecycle-superseded.svg
@@ -0,0 +1,21 @@
+
diff --git a/man/geo_address_lookup.Rd b/man/geo_address_lookup.Rd
index 4025644e..f5c95974 100644
--- a/man/geo_address_lookup.Rd
+++ b/man/geo_address_lookup.Rd
@@ -39,7 +39,7 @@ returned. See also \code{return_addresses}.}
(i.e. \code{list(countrycodes = "US")}). See \strong{Details}.}
}
\value{
-A \code{tibble} with the results found by the query.
+A \CRANpkg{tibble} with the results found by the query.
}
\description{
The lookup API allows to query the address and other details of one or
@@ -71,8 +71,6 @@ Address Lookup API:
Geocoding strings:
\code{\link{geo_address_lookup_sf}()},
-\code{\link{geo_amenity_sf}()},
-\code{\link{geo_amenity}()},
\code{\link{geo_lite_sf}()},
\code{\link{geo_lite}()}
}
diff --git a/man/geo_address_lookup_sf.Rd b/man/geo_address_lookup_sf.Rd
index fe8c9dc3..51b14ce5 100644
--- a/man/geo_address_lookup_sf.Rd
+++ b/man/geo_address_lookup_sf.Rd
@@ -38,7 +38,7 @@ points (\code{TRUE}, which is the default) or potentially other shapes as
provided by the Nominatim API (\code{FALSE}). See \strong{About Geometry Types}.}
}
\value{
-A \code{sf} object with the results.
+A \CRANpkg{sf} object with the results.
}
\description{
The lookup API allows to query the address and other details of one or
@@ -111,14 +111,11 @@ Address Lookup API:
Geocoding strings:
\code{\link{geo_address_lookup}()},
-\code{\link{geo_amenity_sf}()},
-\code{\link{geo_amenity}()},
\code{\link{geo_lite_sf}()},
\code{\link{geo_lite}()}
Get spatial (\code{sf}) objects:
\code{\link{bbox_to_poly}()},
-\code{\link{geo_amenity_sf}()},
\code{\link{geo_lite_sf}()},
\code{\link{reverse_geo_lite_sf}()}
}
diff --git a/man/geo_amenity.Rd b/man/geo_amenity.Rd
index 2487e822..c0aeef23 100644
--- a/man/geo_amenity.Rd
+++ b/man/geo_amenity.Rd
@@ -23,8 +23,7 @@ geo_amenity(
restrict the search area. See \strong{Details}.}
\item{amenity}{A character of a vector of character with the amenities to be
-geolocated (i.e. \code{c("pub", "restaurant")}). See \strong{Details} and
-\link{osm_amenities}.}
+geolocated (i.e. \code{c("pub", "restaurant")}).}
\item{lat}{latitude column name in the output data (default \code{"lat"}).}
@@ -41,23 +40,20 @@ returned. See also \code{return_addresses}.}
\item{verbose}{if \code{TRUE} then detailed logs are output to the console.}
-\item{custom_query}{API-specific parameters to be used.
-See \code{\link[=geo_lite]{geo_lite()}}.}
+\item{custom_query}{API-specific parameters to be used.}
\item{strict}{Logical \code{TRUE/FALSE}. Force the results to be included inside
the \code{bbox}. Note that Nominatim default behavior may return results located
outside the provided bounding box.}
}
\value{
-A \code{tibble} with the results.
+A \CRANpkg{tibble} with the results.
}
\description{
-This function search amenities as defined by OpenStreetMap on a restricted
-area defined by a bounding box in the form of
-\verb{(, , , )}. This
-function returns the \CRANpkg{tibble} associated with the query, see
-\code{\link[=geo_amenity_sf]{geo_amenity_sf()}} for retrieving the data as a spatial object
-(\CRANpkg{sf} format).
+\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}}
+
+This operation is not supported any more. Use
+\href{https://github.com/ropensci/osmdata}{\strong{osmdata}} instead.
}
\details{
Bounding boxes can be located using different online tools, as
@@ -66,39 +62,7 @@ Bounding boxes can be located using different online tools, as
For a full list of valid amenities see
\url{https://wiki.openstreetmap.org/wiki/Key:amenity}.
}
-\examples{
-\dontshow{if (nominatim_check_access()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf}
-\donttest{
-# Times Square, NY, USA
-bbox <- c(-73.9894467311, 40.75573629, -73.9830630737, 40.75789245)
-
-geo_amenity(bbox = bbox, amenity = "restaurant")
-
-# Several amenities
-geo_amenity(bbox = bbox, amenity = c("restaurant", "pub"))
-
-# Increase limit and use with strict
-geo_amenity(
- bbox = bbox, amenity = c("restaurant", "pub"), limit = 10,
- strict = TRUE
-)
-}
-\dontshow{\}) # examplesIf}
-}
\seealso{
\code{\link[=geo_amenity_sf]{geo_amenity_sf()}}
-
-Search amenities:
-\code{\link{bbox_to_poly}()},
-\code{\link{geo_amenity_sf}()},
-\code{\link{osm_amenities}}
-
-Geocoding strings:
-\code{\link{geo_address_lookup_sf}()},
-\code{\link{geo_address_lookup}()},
-\code{\link{geo_amenity_sf}()},
-\code{\link{geo_lite_sf}()},
-\code{\link{geo_lite}()}
}
-\concept{amenity}
-\concept{geocoding}
+\keyword{internal}
diff --git a/man/geo_amenity_sf.Rd b/man/geo_amenity_sf.Rd
index 45163deb..f492c596 100644
--- a/man/geo_amenity_sf.Rd
+++ b/man/geo_amenity_sf.Rd
@@ -22,8 +22,7 @@ geo_amenity_sf(
restrict the search area. See \strong{Details}.}
\item{amenity}{A character of a vector of character with the amenities to be
-geolocated (i.e. \code{c("pub", "restaurant")}). See \strong{Details} and
-\link{osm_amenities}.}
+geolocated (i.e. \code{c("pub", "restaurant")}).}
\item{limit}{maximum number of results to return per input address. Note
that each query returns a maximum of 50 results.}
@@ -48,14 +47,13 @@ the \code{bbox}. Note that Nominatim default behavior may return results located
outside the provided bounding box.}
}
\value{
-A \code{sf} object with the results.
+A \CRANpkg{sf} object with the results.
}
\description{
-This function search amenities as defined by OpenStreetMap on a restricted
-area defined by a bounding box in the form of
-\verb{(, , , )}. This
-function returns the \CRANpkg{sf} spatial object associated with the query,
-see \code{\link[=geo_amenity]{geo_amenity()}} for retrieving the data in \CRANpkg{tibble} format.
+\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}}
+
+This operation is not supported any more. Use
+\href{https://github.com/ropensci/osmdata}{\strong{osmdata}} instead.
}
\details{
Bounding boxes can be located using different online tools, as
@@ -84,56 +82,4 @@ The function is vectorized, allowing for multiple addresses to be geocoded;
in case of \code{points_only = FALSE} multiple geometry types may be returned.
}
-\examples{
-\dontshow{if (nominatim_check_access()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf}
-\donttest{
-# Madrid, Spain
-
-library(ggplot2)
-
-bbox <- c(-3.888954, 40.311977, -3.517916, 40.643729)
-
-# Restaurants and pubs
-
-rest_pub <- geo_amenity_sf(bbox, c("restaurant", "pub"), limit = 50)
-
-if (any(!sf::st_is_empty(rest_pub))) {
- ggplot(rest_pub) +
- geom_sf()
-}
-
-# Hospital as polygon
-
-hosp <- geo_amenity_sf(bbox, "hospital", points_only = FALSE)
-
-if (any(!sf::st_is_empty(hosp))) {
- ggplot(hosp) +
- geom_sf()
-}
-}
-\dontshow{\}) # examplesIf}
-}
-\seealso{
-\code{\link[=geo_amenity]{geo_amenity()}}
-
-Search amenities:
-\code{\link{bbox_to_poly}()},
-\code{\link{geo_amenity}()},
-\code{\link{osm_amenities}}
-
-Geocoding strings:
-\code{\link{geo_address_lookup_sf}()},
-\code{\link{geo_address_lookup}()},
-\code{\link{geo_amenity}()},
-\code{\link{geo_lite_sf}()},
-\code{\link{geo_lite}()}
-
-Get spatial (\code{sf}) objects:
-\code{\link{bbox_to_poly}()},
-\code{\link{geo_address_lookup_sf}()},
-\code{\link{geo_lite_sf}()},
-\code{\link{reverse_geo_lite_sf}()}
-}
-\concept{amenity}
-\concept{geocoding}
-\concept{spatial}
+\keyword{internal}
diff --git a/man/geo_lite.Rd b/man/geo_lite.Rd
index 8b1ae60a..1f76e33e 100644
--- a/man/geo_lite.Rd
+++ b/man/geo_lite.Rd
@@ -12,6 +12,7 @@ geo_lite(
full_results = FALSE,
return_addresses = TRUE,
verbose = FALSE,
+ progressbar = TRUE,
custom_query = list()
)
}
@@ -35,11 +36,14 @@ returned. See also \code{return_addresses}.}
\item{verbose}{if \code{TRUE} then detailed logs are output to the console.}
+\item{progressbar}{Logical. If \code{TRUE} displays a progress bar to indicate
+the progress of the function.}
+
\item{custom_query}{A named list with API-specific parameters to be used
(i.e. \code{list(countrycodes = "US")}). See \strong{Details}.}
}
\value{
-A \code{tibble} with the results.
+A \CRANpkg{tibble} with the results.
}
\description{
Geocodes addresses given as character values. This
@@ -73,8 +77,6 @@ geo_lite(c("Madrid", "Barcelona"),
Geocoding strings:
\code{\link{geo_address_lookup_sf}()},
\code{\link{geo_address_lookup}()},
-\code{\link{geo_amenity_sf}()},
-\code{\link{geo_amenity}()},
\code{\link{geo_lite_sf}()}
}
\concept{geocoding}
diff --git a/man/geo_lite_sf.Rd b/man/geo_lite_sf.Rd
index 578ee6d0..72058fb9 100644
--- a/man/geo_lite_sf.Rd
+++ b/man/geo_lite_sf.Rd
@@ -10,6 +10,7 @@ geo_lite_sf(
return_addresses = TRUE,
full_results = FALSE,
verbose = FALSE,
+ progressbar = TRUE,
custom_query = list(),
points_only = TRUE
)
@@ -30,6 +31,9 @@ If \code{FALSE} (default) only address columns are returned. See also
\item{verbose}{if \code{TRUE} then detailed logs are output to the console.}
+\item{progressbar}{Logical. If \code{TRUE} displays a progress bar to indicate
+the progress of the function.}
+
\item{custom_query}{A named list with API-specific parameters to be used
(i.e. \code{list(countrycodes = "US")}). See \strong{Details}.}
@@ -38,7 +42,7 @@ points (\code{TRUE}, which is the default) or potentially other shapes as
provided by the Nominatim API (\code{FALSE}). See \strong{About Geometry Types}.}
}
\value{
-A \code{sf} object with the results.
+A \CRANpkg{sf} object with the results.
}
\description{
This function allows you to geocode addresses and return the corresponding
@@ -109,14 +113,11 @@ if (any(!sf::st_is_empty(Madrid))) {
Geocoding strings:
\code{\link{geo_address_lookup_sf}()},
\code{\link{geo_address_lookup}()},
-\code{\link{geo_amenity_sf}()},
-\code{\link{geo_amenity}()},
\code{\link{geo_lite}()}
Get spatial (\code{sf}) objects:
\code{\link{bbox_to_poly}()},
\code{\link{geo_address_lookup_sf}()},
-\code{\link{geo_amenity_sf}()},
\code{\link{reverse_geo_lite_sf}()}
}
\concept{geocoding}
diff --git a/man/nominatim_check_access.Rd b/man/nominatim_check_access.Rd
index 9c62510a..65398060 100644
--- a/man/nominatim_check_access.Rd
+++ b/man/nominatim_check_access.Rd
@@ -10,7 +10,7 @@ nominatim_check_access()
a logical.
}
\description{
-Check if R has access to resources at
+Check if \strong{R} has access to resources at
\url{https://nominatim.openstreetmap.org}.
}
\examples{
diff --git a/man/nominatimlite-package.Rd b/man/nominatimlite-package.Rd
index 1ba31c09..3a627e0d 100644
--- a/man/nominatimlite-package.Rd
+++ b/man/nominatimlite-package.Rd
@@ -8,7 +8,7 @@
\description{
\if{html}{\figure{logo.png}{options: style='float: right' alt='logo' width='120'}}
-Lite interface for getting data from 'OSM' service 'Nominatim' \url{https://nominatim.org/release-docs/latest/}. Extract coordinates from addresses, find places near a set of coordinates, search for amenities and return spatial objects on 'sf' format.
+Lite interface for getting data from 'OSM' service 'Nominatim' \url{https://nominatim.org/release-docs/latest/}. Extract coordinates from addresses, find places near a set of coordinates and return spatial objects on 'sf' format.
}
\seealso{
Useful links:
diff --git a/man/osm_amenities.Rd b/man/osm_amenities.Rd
deleted file mode 100644
index bcf78a4c..00000000
--- a/man/osm_amenities.Rd
+++ /dev/null
@@ -1,144 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/data.R
-\docType{data}
-\encoding{UTF-8}
-\name{osm_amenities}
-\alias{osm_amenities}
-\title{OpenStreetMap amenity database}
-\format{
-A \code{tibble} with with
-100 rows and
-fields:
-\describe{
-\item{category}{The category of the amenity}
-\item{amenity}{The name of the amenity}
-}
-}
-\source{
-\url{https://wiki.openstreetmap.org/wiki/Key:amenity}
-}
-\description{
-Database with the list of amenities available on OpenStreetMap.
-}
-\details{
-\tabular{ll}{
- \strong{category} \tab \strong{amenity} \cr
- Sustenance \tab bar \cr
- Sustenance \tab biergarten \cr
- Sustenance \tab cafe \cr
- Sustenance \tab fast_food \cr
- Sustenance \tab food_court \cr
- Sustenance \tab ice_cream \cr
- Sustenance \tab pub \cr
- Sustenance \tab restaurant \cr
- Education \tab college \cr
- Education \tab driving_school \cr
- Education \tab kindergarten \cr
- Education \tab language_school \cr
- Education \tab library \cr
- Education \tab toy_library \cr
- Education \tab music_school \cr
- Education \tab school \cr
- Education \tab university \cr
- Transportation \tab bicycle_parking \cr
- Transportation \tab bicycle_repair_station \cr
- Transportation \tab bicycle_rental \cr
- Transportation \tab boat_rental \cr
- Transportation \tab boat_sharing \cr
- Transportation \tab bus_station \cr
- Transportation \tab car_rental \cr
- Transportation \tab car_sharing \cr
- Transportation \tab car_wash \cr
- Transportation \tab vehicle_inspection \cr
- Transportation \tab charging_station \cr
- Transportation \tab ferry_terminal \cr
- Transportation \tab fuel \cr
- Transportation \tab grit_bin \cr
- Transportation \tab motorcycle_parking \cr
- Transportation \tab parking \cr
- Transportation \tab parking_entrance \cr
- Transportation \tab parking_space \cr
- Transportation \tab taxi \cr
- Financial \tab atm \cr
- Financial \tab bank \cr
- Financial \tab bureau_de_change \cr
- Healthcare \tab baby_hatch \cr
- Healthcare \tab clinic \cr
- Healthcare \tab dentist \cr
- Healthcare \tab doctors \cr
- Healthcare \tab hospital \cr
- Healthcare \tab nursing_home \cr
- Healthcare \tab pharmacy \cr
- Healthcare \tab social_facility \cr
- Healthcare \tab veterinary \cr
- Entertainment-Arts-Culture \tab arts_centre \cr
- Entertainment-Arts-Culture \tab brothel \cr
- Entertainment-Arts-Culture \tab casino \cr
- Entertainment-Arts-Culture \tab cinema \cr
- Entertainment-Arts-Culture \tab community_centre \cr
- Entertainment-Arts-Culture \tab conference_centre \cr
- Entertainment-Arts-Culture \tab events_venue \cr
- Entertainment-Arts-Culture \tab fountain \cr
- Entertainment-Arts-Culture \tab gambling \cr
- Entertainment-Arts-Culture \tab love_hotel \cr
- Entertainment-Arts-Culture \tab nightclub \cr
- Entertainment-Arts-Culture \tab planetarium \cr
- Entertainment-Arts-Culture \tab public_bookcase \cr
- Entertainment-Arts-Culture \tab social_centre \cr
- Entertainment-Arts-Culture \tab stripclub \cr
- Entertainment-Arts-Culture \tab studio \cr
- Entertainment-Arts-Culture \tab swingerclub \cr
- Entertainment-Arts-Culture \tab theatre \cr
- Public Service \tab courthouse \cr
- Public Service \tab embassy \cr
- Public Service \tab fire_station \cr
- Public Service \tab police \cr
- Public Service \tab post_box \cr
- Public Service \tab post_depot \cr
- Public Service \tab post_office \cr
- Public Service \tab prison \cr
- Public Service \tab ranger_station \cr
- Public Service \tab townhall \cr
- Facilities \tab bbq \cr
- Facilities \tab bench \cr
- Facilities \tab dog_toilet \cr
- Facilities \tab drinking_water \cr
- Facilities \tab give_box \cr
- Facilities \tab shelter \cr
- Facilities \tab shower \cr
- Facilities \tab telephone \cr
- Facilities \tab toilets \cr
- Facilities \tab water_point \cr
- Facilities \tab watering_place \cr
- Waste Management \tab sanitary_dump_station \cr
- Waste Management \tab recycling \cr
- Waste Management \tab waste_basket \cr
- Waste Management \tab waste_disposal \cr
- Waste Management \tab waste_transfer_station \cr
- Others \tab animal_boarding \cr
- Others \tab animal_breeding \cr
- Others \tab animal_shelter \cr
- Others \tab baking_oven \cr
- Others \tab childcare \cr
- Others \tab clock \cr
- Others \tab crematorium \cr
- Others \tab dive_centre \cr
-}
-}
-\note{
-Data extracted on \strong{14 June 2021}.
-}
-\examples{
-
-amenities <- nominatimlite::osm_amenities
-
-amenities
-}
-\seealso{
-Search amenities:
-\code{\link{bbox_to_poly}()},
-\code{\link{geo_amenity_sf}()},
-\code{\link{geo_amenity}()}
-}
-\concept{amenity}
-\concept{datasets}
diff --git a/man/reverse_geo_lite.Rd b/man/reverse_geo_lite.Rd
index f152d9ff..2545e841 100644
--- a/man/reverse_geo_lite.Rd
+++ b/man/reverse_geo_lite.Rd
@@ -11,6 +11,7 @@ reverse_geo_lite(
full_results = FALSE,
return_coords = TRUE,
verbose = FALSE,
+ progressbar = TRUE,
custom_query = list()
)
}
@@ -31,11 +32,14 @@ returned. See also \code{return_addresses}.}
\item{verbose}{if \code{TRUE} then detailed logs are output to the console.}
+\item{progressbar}{Logical. If \code{TRUE} displays a progress bar to indicate
+the progress of the function.}
+
\item{custom_query}{API-specific parameters to be used, passed as a named
list (ie. \code{list(zoom = 3)}). See \strong{Details}.}
}
\value{
-A \code{tibble} with the results.
+A \CRANpkg{tibble} with the results.
}
\description{
Generates an address from a latitude and longitude. Latitudes must be
diff --git a/man/reverse_geo_lite_sf.Rd b/man/reverse_geo_lite_sf.Rd
index 18e3b0cf..c53d1a6d 100644
--- a/man/reverse_geo_lite_sf.Rd
+++ b/man/reverse_geo_lite_sf.Rd
@@ -11,6 +11,7 @@ reverse_geo_lite_sf(
full_results = FALSE,
return_coords = TRUE,
verbose = FALSE,
+ progressbar = TRUE,
custom_query = list(),
points_only = TRUE
)
@@ -32,6 +33,9 @@ returned. See also \code{return_addresses}.}
\item{verbose}{if \code{TRUE} then detailed logs are output to the console.}
+\item{progressbar}{Logical. If \code{TRUE} displays a progress bar to indicate
+the progress of the function.}
+
\item{custom_query}{API-specific parameters to be used, passed as a named
list (ie. \code{list(zoom = 3)}). See \strong{Details}.}
@@ -40,7 +44,7 @@ points (\code{TRUE}, which is the default) or potentially other shapes as
provided by the Nominatim API (\code{FALSE}). See \strong{About Geometry Types}.}
}
\value{
-A \code{sf} object with the results.
+A \CRANpkg{sf} object with the results.
}
\description{
Generates an address from a latitude and longitude. Latitudes must be
@@ -139,7 +143,6 @@ Reverse geocoding coordinates:
Get spatial (\code{sf}) objects:
\code{\link{bbox_to_poly}()},
\code{\link{geo_address_lookup_sf}()},
-\code{\link{geo_amenity_sf}()},
\code{\link{geo_lite_sf}()}
}
\concept{reverse}
diff --git a/man/roxygen/meta.R b/man/roxygen/meta.R
index 3f731d8c..ee4c8a6e 100644
--- a/man/roxygen/meta.R
+++ b/man/roxygen/meta.R
@@ -1,7 +1,6 @@
list(
rd_family_title = list(
lookup = "Address Lookup API: ",
- amenity = "Search amenities: ",
geocoding = "Geocoding strings: ",
reverse = "Reverse geocoding coordinates: ",
spatial = "Get spatial (\\code{sf}) objects: ",
diff --git a/pkgdown/_pkgdown.yml b/pkgdown/_pkgdown.yml
index a44c42d4..1c0810aa 100644
--- a/pkgdown/_pkgdown.yml
+++ b/pkgdown/_pkgdown.yml
@@ -10,9 +10,6 @@ template:
creator: "@dhernangomez"
card: summary_large_image
-development:
- mode: auto
-
repo:
branch: main
@@ -43,11 +40,6 @@ reference:
contents:
- has_concept("spatial")
-- title: Datasets
- desc: Helper datasets.
- contents:
- - has_concept("datasets")
-
- title: About the package
contents:
- nominatimlite-package
diff --git a/tests/testthat/_snaps/geo_amenity.md b/tests/testthat/_snaps/geo_amenity.md
new file mode 100644
index 00000000..5264cbf6
--- /dev/null
+++ b/tests/testthat/_snaps/geo_amenity.md
@@ -0,0 +1,9 @@
+# Deprecated
+
+ Code
+ geo_amenity()
+ Condition
+ Error:
+ ! `geo_amenity()` was deprecated in nominatimlite 0.3.0 and is now defunct.
+ i Operation not supported any more by the Nominatim API.
+
diff --git a/tests/testthat/_snaps/geo_amenity_sf.md b/tests/testthat/_snaps/geo_amenity_sf.md
new file mode 100644
index 00000000..5139302d
--- /dev/null
+++ b/tests/testthat/_snaps/geo_amenity_sf.md
@@ -0,0 +1,9 @@
+# Deprecated
+
+ Code
+ geo_amenity_sf()
+ Condition
+ Error:
+ ! `geo_amenity_sf()` was deprecated in nominatimlite 0.3.0 and is now defunct.
+ i Operation not supported any more by the Nominatim API.
+
diff --git a/tests/testthat/test-geo_amenity.R b/tests/testthat/test-geo_amenity.R
index 5648b43f..b8964b37 100644
--- a/tests/testthat/test-geo_amenity.R
+++ b/tests/testthat/test-geo_amenity.R
@@ -1,190 +1,5 @@
-test_that("Returning not reachable", {
- expect_message(geo_amenity(
- bbox = c(-1.1446, 41.5022, -0.4854, 41.8795),
- amenity = "xbzbzbzoa aiaia"
- ), "not reachable")
+test_that("Deprecated", {
+ skip_if_not_installed("lifecycle")
- skip_on_cran()
- skip_if_api_server()
-
- expect_message(obj <- geo_amenity(
- bbox = c(-1.1446, 41.5022, -0.4854, 41.8795),
- amenity = "xbzbzbzoa aiaia"
- ))
-
- expect_true(nrow(obj) == 1)
- expect_true(obj$query == "xbzbzbzoa aiaia")
- expect_s3_class(obj, "tbl")
- expect_identical(names(obj), c("query", "lat", "lon"))
- expect_true(all(
- vapply(obj, class, FUN.VALUE = character(1))
- == c("character", rep("numeric", 2))
- ))
- expect_true(is.na(obj$lat))
- expect_true(is.na(obj$lon))
-
- expect_message(
- obj_renamed <- geo_amenity(
- bbox = c(-1.1446, 41.5022, -0.4854, 41.8795),
- amenity = "xbzbzbzoa aiaia",
- lat = "lata",
- long = "longa"
- ),
- "not reachable"
- )
-
- expect_identical(names(obj_renamed), c("query", "lata", "longa"))
-
- names(obj_renamed) <- names(obj)
-
- expect_identical(obj, obj_renamed)
-})
-
-test_that("Returning empty query", {
- skip_on_cran()
- skip_if_api_server()
-
-
- expect_message(
- obj <- geo_amenity(
- bbox = c(-88.1446, 41.5022, -87.4854, 41.8795),
- amenity = "grit_bin"
- ),
- "No results"
- )
-
-
- expect_true(nrow(obj) == 1)
- expect_true(obj$query == "grit_bin")
- expect_s3_class(obj, "tbl")
- expect_identical(names(obj), c("query", "lat", "lon"))
- expect_true(all(
- vapply(obj, class, FUN.VALUE = character(1))
- == c("character", rep("numeric", 2))
- ))
- expect_true(is.na(obj$lat))
- expect_true(is.na(obj$lon))
-
- expect_message(
- obj_renamed <- geo_amenity(
- bbox = c(-88.1446, 41.5022, -87.4854, 41.8795),
- amenity = "grit_bin",
- lat = "lata",
- long = "longa"
- ),
- "No results"
- )
-
- expect_identical(names(obj_renamed), c("query", "lata", "longa"))
-
- names(obj_renamed) <- names(obj)
-
- expect_identical(obj, obj_renamed)
-})
-
-
-test_that("Data format", {
- skip_on_cran()
- skip_if_api_server()
- skip_if_offline()
-
- obj <- geo_amenity(
- bbox = c(-1.1446, 41.5022, -0.4854, 41.8795),
- c("pub", "restaurant"),
- )
-
- expect_s3_class(obj, "tbl")
- expect_false(inherits(obj, "sf"))
-})
-
-test_that("Checking query", {
- skip_on_cran()
- skip_if_api_server()
- skip_if_offline()
-
- expect_message(obj <- geo_amenity(
- bbox = c(-1.1446, 41.5022, -0.4854, 41.8795),
- c("pub", "restaurant"),
- limit = 51
- ), "50 results")
-
-
- expect_identical(names(obj), c("query", "lat", "lon", "address"))
-
- obj <- geo_amenity(
- bbox = c(-1.1446, 41.5022, -0.4854, 41.8795),
- "pub",
- long = "ong", lat = "at",
- full_results = FALSE,
- return_addresses = FALSE
- )
- expect_identical(names(obj), c("query", "at", "ong"))
-
- obj <- geo_amenity(
- bbox = c(-1.1446, 41.5022, -0.4854, 41.8795),
- "pub",
- long = "ong", lat = "at",
- full_results = FALSE,
- return_addresses = TRUE
- )
-
- expect_identical(names(obj), c("query", "at", "ong", "address"))
-
- obj <- geo_amenity(
- bbox = c(-1.1446, 41.5022, -0.4854, 41.8795),
- "pub",
- long = "ong", lat = "at",
- full_results = TRUE,
- return_addresses = FALSE
- )
-
- expect_identical(names(obj)[1:4], c("query", "at", "ong", "address"))
- expect_gt(ncol(obj), 4)
-
-
- expect_gt(nrow(geo_amenity(
- bbox = c(-1.1446, 41.5022, -0.4854, 41.8795),
- "pub",
- limit = 10,
- custom_query = list(countrycode = "es")
- )), 4)
- expect_equal(nrow(geo_amenity(
- bbox = c(-1.1446, 41.5022, -0.4854, 41.8795),
- "pub",
- custom_query = list(countrycode = "es")
- )), 1)
- expect_equal(nrow(geo_amenity(
- bbox = c(-1.1446, 41.5022, -0.4854, 41.8795),
- "pub",
- custom_query = list(extratags = 1)
- )), 1)
-
- expect_lt(nrow(geo_amenity(
- bbox = c(-1.1446, 41.5022, -0.4854, 41.8795),
- "pub",
- limit = 1,
- strict = TRUE
- )), 2)
-})
-
-test_that("Dedupe", {
- skip_on_cran()
- skip_if_api_server()
- skip_if_offline()
-
- # Dupes
- dup <- geo_amenity(
- bbox = c(-1.1446, 41.5022, -0.4854, 41.8795),
- rep(c("pub", "restaurant"), 50),
- limit = 1
- )
-
- expect_equal(nrow(dup), 100)
- expect_equal(as.character(dup$query), rep(c("pub", "restaurant"), 50))
-
- # Check deduping
- dedup <- dplyr::distinct(dup)
-
- expect_equal(nrow(dedup), 2)
- expect_equal(as.character(dedup$query), rep(c("pub", "restaurant"), 1))
+ expect_snapshot(geo_amenity(), error = TRUE)
})
diff --git a/tests/testthat/test-geo_amenity_sf.R b/tests/testthat/test-geo_amenity_sf.R
index bf87617a..02f8cbf6 100644
--- a/tests/testthat/test-geo_amenity_sf.R
+++ b/tests/testthat/test-geo_amenity_sf.R
@@ -1,209 +1,5 @@
-test_that("Returning not reachable", {
- expect_message(geo_amenity_sf(
- bbox = c(-1.1446, 41.5022, -0.4854, 41.8795),
- amenity = "xbzbzbzoa aiaia"
- ), "not reachable")
+test_that("Deprecated", {
+ skip_if_not_installed("lifecycle")
- skip_on_cran()
- skip_if_api_server()
-
- expect_message(
- obj <- geo_amenity_sf(
- bbox = c(-1.1446, 41.5022, -0.4854, 41.8795),
- amenity = "xbzbzbzoa aiaia"
- )
- )
-
- expect_true(nrow(obj) == 1)
- expect_true(obj$query == "xbzbzbzoa aiaia")
- expect_s3_class(obj, "sf")
- expect_s3_class(obj, "tbl")
- expect_true(sf::st_is_empty(obj))
- expect_identical(sf::st_crs(obj), sf::st_crs(4326))
-})
-
-
-test_that("Returning empty query", {
- skip_on_cran()
- skip_if_api_server()
-
-
- expect_message(
- obj <- geo_amenity_sf(
- bbox = c(-88.1446, 41.5022, -87.4854, 41.8795),
- amenity = "grit_bin"
- ),
- "No results"
- )
-
-
- expect_true(nrow(obj) == 1)
- expect_true(obj$query == "grit_bin")
- expect_s3_class(obj, "sf")
- expect_s3_class(obj, "tbl")
- expect_true(sf::st_is_empty(obj))
- expect_identical(sf::st_crs(obj), sf::st_crs(4326))
-})
-
-
-test_that("Data format", {
- skip_on_cran()
- skip_if_api_server()
- skip_if_offline()
-
- obj <- geo_amenity_sf(
- bbox = c(-1.1446, 41.5022, -0.4854, 41.8795),
- c("pub", "restaurant"),
- )
-
- expect_s3_class(obj, "sf")
- expect_s3_class(obj, "tbl")
- expect_equal(nrow(obj), 2)
- expect_identical(as.character(obj$query), c("pub", "restaurant"))
-
-
- # Polygon
-
- expect_message(
- hosp <- geo_amenity_sf(
- c(
- -3.888954, 40.311977,
- -3.517916, 40.643729
- ),
- c("hospital", "dump", "pub"),
- points_only = FALSE
- ), "No results for query dump"
- )
-
- expect_s3_class(hosp, "sf")
- expect_s3_class(hosp, "tbl")
- expect_equal(nrow(hosp), 3)
- expect_identical(as.character(hosp$query), c("hospital", "dump", "pub"))
- expect_identical(sf::st_is_empty(hosp), c(FALSE, TRUE, FALSE))
-})
-
-
-test_that("Checking query", {
- skip_on_cran()
- skip_if_api_server()
- skip_if_offline()
-
-
- expect_message(obj <- geo_amenity_sf(
- bbox = c(-1.1446, 41.5022, -0.4854, 41.8795),
- c("pub", "restaurant"),
- limit = 51
- ), "50 results")
-
-
- expect_identical(names(obj), c("query", "address", "geometry"))
- expect_s3_class(obj, "sf")
- expect_s3_class(obj, "tbl")
-
- obj <- geo_amenity_sf(
- bbox = c(-1.1446, 41.5022, -0.4854, 41.8795),
- "pub",
- full_results = FALSE,
- return_addresses = FALSE
- )
- expect_identical(names(obj), c("query", "geometry"))
- expect_s3_class(obj, "sf")
- expect_s3_class(obj, "tbl")
-
- obj <- geo_amenity_sf(
- bbox = c(-1.1446, 41.5022, -0.4854, 41.8795),
- "pub",
- full_results = FALSE,
- return_addresses = TRUE
- )
-
- expect_identical(names(obj), c("query", "address", "geometry"))
- expect_s3_class(obj, "sf")
- expect_s3_class(obj, "tbl")
-
- obj <- geo_amenity_sf(
- bbox = c(-1.1446, 41.5022, -0.4854, 41.8795),
- "pub",
- full_results = TRUE,
- return_addresses = FALSE
- )
-
- expect_identical(names(obj)[1:2], c("query", "address"))
- expect_gt(ncol(obj), 3)
- expect_s3_class(obj, "sf")
- expect_s3_class(obj, "tbl")
- expect_identical(attributes(obj)$sf_column, "geometry")
-
- expect_gt(nrow(geo_amenity_sf(
- bbox = c(-1.1446, 41.5022, -0.4854, 41.8795),
- "pub",
- limit = 10,
- custom_query = list(countrycode = "es")
- )), 4)
-
-
- expect_equal(nrow(geo_amenity_sf(
- bbox = c(-1.1446, 41.5022, -0.4854, 41.8795),
- "pub",
- custom_query = list(countrycode = "es")
- )), 1)
-
- expect_equal(nrow(geo_amenity_sf(
- bbox = c(-1.1446, 41.5022, -0.4854, 41.8795),
- "pub",
- custom_query = list(extratags = 1)
- )), 1)
-
- expect_lt(nrow(geo_amenity_sf(
- bbox = c(-1.1446, 41.5022, -0.4854, 41.8795),
- "pub",
- limit = 1,
- strict = TRUE
- )), 2)
-})
-
-
-test_that("Dedupe", {
- skip_on_cran()
- skip_if_api_server()
- skip_if_offline()
-
- # Dupes
- dup <- geo_amenity_sf(
- bbox = c(-1.1446, 41.5022, -0.4854, 41.8795),
- rep(c("pub", "restaurant"), 50),
- limit = 1
- )
-
- expect_s3_class(dup, "sf")
- expect_s3_class(dup, "tbl")
-
- expect_equal(nrow(dup), 100)
- expect_equal(as.character(dup$query), rep(c("pub", "restaurant"), 50))
-
- # Check deduping
- dedup <- dplyr::distinct(dup)
-
- expect_equal(nrow(dedup), 2)
- expect_equal(as.character(dedup$query), rep(c("pub", "restaurant"), 1))
-})
-
-
-test_that("Verify names", {
- skip_on_cran()
- skip_if_api_server()
- skip_if_offline()
-
- # Ok
- several <- geo_amenity_sf(
- bbox = c(-1.1446, 41.5022, -0.4854, 41.8795),
- c("pub", "restaurant"),
- limit = 20,
- full_results = TRUE
- )
-
- expect_identical(names(several), unique(names(several)))
-
- # Do I have dups by any chance?
- expect_false(any(grepl("\\.[0-9]$", names(several))))
+ expect_snapshot(geo_amenity_sf(), error = TRUE)
})
diff --git a/tests/testthat/test-geo_lite.R b/tests/testthat/test-geo_lite.R
index de3f7de9..473f360f 100644
--- a/tests/testthat/test-geo_lite.R
+++ b/tests/testthat/test-geo_lite.R
@@ -116,6 +116,7 @@ test_that("Dedupe", {
expect_silent(
dup <- geo_lite(rep(c("Pentagon", "Barcelona"), 50),
limit = 1,
+ progressbar = FALSE,
verbose = FALSE
)
)
@@ -129,3 +130,19 @@ test_that("Dedupe", {
expect_equal(nrow(dedup), 2)
expect_equal(as.character(dedup$query), rep(c("Pentagon", "Barcelona"), 1))
})
+
+
+test_that("Progress bar", {
+ skip_on_cran()
+ skip_if_api_server()
+ skip_if_offline()
+ # No pbar
+ expect_silent(geo_lite("Madrid"))
+ expect_silent(geo_lite("Madrid", progressbar = TRUE))
+
+ # Get a pbar
+ expect_output(aa <- geo_lite(c("Madrid", "Barcelona")), "1/2")
+
+ # Not
+ expect_silent(aa <- geo_lite(c("Madrid", "Barcelona"), progressbar = FALSE))
+})
diff --git a/tests/testthat/test-geo_lite_sf.R b/tests/testthat/test-geo_lite_sf.R
index 0ee7b23b..872a7e68 100644
--- a/tests/testthat/test-geo_lite_sf.R
+++ b/tests/testthat/test-geo_lite_sf.R
@@ -155,3 +155,20 @@ test_that("Verify names", {
# Do I have dups by any chance?
expect_false(any(grepl("\\.[0-9]$", names(several))))
})
+
+test_that("Progress bar", {
+ skip_on_cran()
+ skip_if_api_server()
+ skip_if_offline()
+ # No pbar
+ expect_silent(geo_lite_sf("Madrid"))
+ expect_silent(geo_lite_sf("Madrid", progressbar = TRUE))
+
+ # Get a pbar
+ expect_output(aa <- geo_lite_sf(c("Madrid", "Barcelona")), "1/2")
+
+ # Not
+ expect_silent(
+ aa <- geo_lite_sf(c("Madrid", "Barcelona"), progressbar = FALSE)
+ )
+})
diff --git a/tests/testthat/test-reverse_geo_lite.R b/tests/testthat/test-reverse_geo_lite.R
index ca091a1e..d728d6ae 100644
--- a/tests/testthat/test-reverse_geo_lite.R
+++ b/tests/testthat/test-reverse_geo_lite.R
@@ -195,7 +195,7 @@ test_that("Dedupe", {
lats <- rep(c(40.75728, 55.95335), 50)
longs <- rep(c(-73.98586, -3.188375), 50)
- expect_silent(dup <- reverse_geo_lite(lats, longs))
+ expect_silent(dup <- reverse_geo_lite(lats, longs, progressbar = FALSE))
expect_equal(nrow(dup), 100)
@@ -209,3 +209,22 @@ test_that("Dedupe", {
expect_equal(nrow(dedup), 2)
expect_equal(as.character(dedup$address), nms)
})
+
+test_that("Progress bar", {
+ skip_on_cran()
+ skip_if_api_server()
+ skip_if_offline()
+
+ lat <- c(40.75728, 55.95335)
+ long <- c(-73.98586, -3.188375)
+
+ # No pbar
+ expect_silent(reverse_geo_lite(lat[1], long[1]))
+ expect_silent(reverse_geo_lite(lat[1], long[1], progressbar = TRUE))
+
+ # Get a pbar
+ expect_output(aa <- reverse_geo_lite(lat, long), "1/2")
+
+ # Not
+ expect_silent(aa <- reverse_geo_lite(lat, long, progressbar = FALSE))
+})
diff --git a/tests/testthat/test-reverse_geo_lite_sf.R b/tests/testthat/test-reverse_geo_lite_sf.R
index afee89a1..843bcb54 100644
--- a/tests/testthat/test-reverse_geo_lite_sf.R
+++ b/tests/testthat/test-reverse_geo_lite_sf.R
@@ -214,7 +214,7 @@ test_that("Dedupe", {
lats <- rep(c(40.75728, 55.95335), 50)
longs <- rep(c(-73.98586, -3.188375), 50)
- expect_silent(dup <- reverse_geo_lite_sf(lats, longs))
+ expect_silent(dup <- reverse_geo_lite_sf(lats, longs, progressbar = FALSE))
expect_s3_class(dup, "sf")
expect_s3_class(dup, "tbl")
@@ -230,3 +230,22 @@ test_that("Dedupe", {
expect_equal(nrow(dedup), 2)
expect_equal(as.character(dedup$address), nms)
})
+
+test_that("Progress bar", {
+ skip_on_cran()
+ skip_if_api_server()
+ skip_if_offline()
+
+ lat <- c(40.75728, 55.95335)
+ long <- c(-73.98586, -3.188375)
+
+ # No pbar
+ expect_silent(reverse_geo_lite_sf(lat[1], long[1]))
+ expect_silent(reverse_geo_lite_sf(lat[1], long[1], progressbar = TRUE))
+
+ # Get a pbar
+ expect_output(aa <- reverse_geo_lite_sf(lat, long), "1/2")
+
+ # Not
+ expect_silent(aa <- reverse_geo_lite_sf(lat, long, progressbar = FALSE))
+})
diff --git a/vignettes/nominatimlite.Rmd b/vignettes/nominatimlite.Rmd
index 338712ef..9255e4cc 100644
--- a/vignettes/nominatimlite.Rmd
+++ b/vignettes/nominatimlite.Rmd
@@ -1,155 +1,157 @@
----
-title: "Get started with nominatimlite"
-output: rmarkdown::html_vignette
-desc: >
- Quick examples showing what `nominatimlite` can do for you.
-vignette: >
- %\VignetteIndexEntry{Get started with nominatimlite}
- %\VignetteEngine{knitr::rmarkdown}
- %\VignetteEncoding{UTF-8}
-bibliography: references.bib
-link-citations: true
----
-
-
-
-
-
-The goal of `nominatimlite` is to provide a light interface for geocoding
-addresses, based on the [Nominatim
-API](https://nominatim.org/release-docs/latest/). **Nominatim** is a tool to
-search [OpenStreetMap](https://www.openstreetmap.org/) data by name and address
-([geocoding](https://wiki.openstreetmap.org/wiki/Geocoding "Geocoding")) and to
-generate synthetic addresses of OSM points (reverse geocoding).
-
-It also allows to load spatial objects using the `sf` package.
-
-Full site with examples and vignettes on
-
-
-## Why `nominatimlite`?
-
-The main goal of `nominatimlite` is to access the Nominatim API avoiding the
-dependency on `curl`. In some situations, `curl` may not be available or
-accessible, so `nominatimlite` uses base functions to overcome this limitation.
-
-## Recommended packages
-
-There are other packages much more complete and mature than `nominatimlite`,
-that presents similar features:
-
-- [`tidygeocoder`](https://jessecambon.github.io/tidygeocoder/)
- [@R-tidygeocoder]. Allows to interface with Nominatim, Google, TomTom,
- Mapbox, etc. for geocoding and reverse geocoding.
-- [`osmdata`](https://docs.ropensci.org/osmdata/) [@R-osmdata]. Great for
- downloading spatial data from OpenStreetMap, via the [Overpass
- API](https://wiki.openstreetmap.org/wiki/Overpass_API).
-
-## Usage
-
-### `sf` objects
-
-With `nominatimlite` you can extract spatial objects easily:
-
-
-```r
-library(nominatimlite)
-
-# Extract some points - Pizza Hut in California
-
-CA <- geo_lite_sf("California", points_only = FALSE)
-
-pizzahut <- geo_lite_sf("Pizza Hut, California",
- limit = 50,
- custom_query = list(countrycodes = "us")
-)
-
-library(ggplot2)
-
-ggplot(CA) +
- geom_sf() +
- geom_sf(data = pizzahut, col = "red")
-```
-
-{width="100%"}
-
-You can also extract polygon and line objects (if available) using the option
-`points_only = FALSE`:
-
-
-```r
-sol_poly <- geo_lite_sf("Statue of Liberty, NY, USA", points_only = FALSE)
-
-ggplot(sol_poly) +
- geom_sf()
-```
-
-{width="100%"}
-
-### Geocoding and reverse geocoding
-
-*Note: examples adapted from `tidygeocoder` package*
-
-In this first example we will geocode a few addresses using the `geo_lite()`
-function:
-
-
-```r
-library(tibble)
-
-# create a dataframe with addresses
-some_addresses <- tribble(
- ~name, ~addr,
- "White House", "1600 Pennsylvania Ave NW, Washington, DC",
- "Transamerica Pyramid", "600 Montgomery St, San Francisco, CA 94111",
- "Willis Tower", "233 S Wacker Dr, Chicago, IL 60606"
-)
-
-# geocode the addresses
-lat_longs <- geo_lite(some_addresses$addr, lat = "latitude", long = "longitude")
-```
-
-Only latitude and longitude are returned from the geocoder service in this
-example, but `full_results = TRUE` can be used to return all of the data from
-the geocoder service.
-
-
-
-|query | latitude| longitude|address |
-|:------------------------------------------|--------:|----------:|:-----------------------------------------------------------------------------------------------------------------|
-|1600 Pennsylvania Ave NW, Washington, DC | 38.89770| -77.03655|White House, 1600, Pennsylvania Avenue Northwest, Ward 2, Washington, District of Columbia, 20500, United States |
-|600 Montgomery St, San Francisco, CA 94111 | 37.79520| -122.40279|Transamerica Pyramid, 600, Montgomery Street, Financial District, San Francisco, California, 94111, United States |
-|233 S Wacker Dr, Chicago, IL 60606 | 41.87874| -87.63596|Willis Tower, 233, South Wacker Drive, Printer's Row, Loop, Chicago, Cook County, Illinois, 60606, United States |
-
-
-
-To perform reverse geocoding (obtaining addresses from geographic coordinates),
-we can use the `reverse_geo_lite()` function. The arguments are similar to the
-`geo_lite()` function, but now we specify the input data columns with the `lat`
-and `long` arguments. The dataset used here is from the geocoder query above.
-The single line address is returned in a column named by the `address`.
-
-
-```r
-reverse <- reverse_geo_lite(
- lat = lat_longs$latitude, long = lat_longs$longitude,
- address = "address_found"
-)
-```
-
-
-
-|address_found | lat| lon|
-|:-----------------------------------------------------------------------------------------------------------------|--------:|----------:|
-|White House, 1600, Pennsylvania Avenue Northwest, Ward 2, Washington, District of Columbia, 20500, United States | 38.89770| -77.03655|
-|Transamerica Pyramid, 600, Montgomery Street, Financial District, San Francisco, California, 94111, United States | 37.79520| -122.40279|
-|Willis Tower, 233, South Wacker Drive, Printer's Row, Loop, Chicago, Cook County, Illinois, 60606, United States | 41.87874| -87.63596|
-
-
-
-For more advance users, see [Nominatim
-docs](https://nominatim.org/release-docs/latest/api/Search/) to check the
-parameters available.
-
-## References
+---
+title: "Get started with nominatimlite"
+output: rmarkdown::html_vignette
+desc: >
+ Quick examples showing what `nominatimlite` can do for you.
+vignette: >
+ %\VignetteIndexEntry{Get started with nominatimlite}
+ %\VignetteEngine{knitr::rmarkdown}
+ %\VignetteEncoding{UTF-8}
+bibliography: references.bib
+link-citations: true
+---
+
+
+
+
+
+The goal of `nominatimlite` is to provide a light interface for geocoding
+addresses, based on the [Nominatim
+API](https://nominatim.org/release-docs/latest/). **Nominatim** is a tool to
+search [OpenStreetMap](https://www.openstreetmap.org/) data by name and address
+([geocoding](https://wiki.openstreetmap.org/wiki/Geocoding "Geocoding")) and to
+generate synthetic addresses of OSM points (reverse geocoding).
+
+It also allows to load spatial objects using the `sf` package.
+
+Full site with examples and vignettes on
+
+
+## Why `nominatimlite`?
+
+The main goal of `nominatimlite` is to access the Nominatim API avoiding the
+dependency on `curl`. In some situations, `curl` may not be available or
+accessible, so `nominatimlite` uses base functions to overcome this limitation.
+
+## Recommended packages
+
+There are other packages much more complete and mature than `nominatimlite`,
+that presents similar features:
+
+- [`tidygeocoder`](https://jessecambon.github.io/tidygeocoder/)
+ [@R-tidygeocoder]. Allows to interface with Nominatim, Google, TomTom,
+ Mapbox, etc. for geocoding and reverse geocoding.
+- [`osmdata`](https://docs.ropensci.org/osmdata/) [@R-osmdata]. Great for
+ downloading spatial data from OpenStreetMap, via the [Overpass
+ API](https://wiki.openstreetmap.org/wiki/Overpass_API).
+
+## Usage
+
+### `sf` objects
+
+With `nominatimlite` you can extract spatial objects easily:
+
+
+```r
+library(nominatimlite)
+
+# Extract some points - Pizza Hut in California
+
+CA <- geo_lite_sf("California", points_only = FALSE)
+
+pizzahut <- geo_lite_sf("Pizza Hut, California",
+ limit = 50,
+ custom_query = list(countrycodes = "us")
+)
+
+library(ggplot2)
+
+ggplot(CA) +
+ geom_sf() +
+ geom_sf(data = pizzahut, col = "red")
+```
+
+{width="100%"}
+
+You can also extract polygon and line objects (if available) using the option
+`points_only = FALSE`:
+
+
+```r
+sol_poly <- geo_lite_sf("Statue of Liberty, NY, USA", points_only = FALSE)
+
+ggplot(sol_poly) +
+ geom_sf()
+```
+
+{width="100%"}
+
+### Geocoding and reverse geocoding
+
+*Note: examples adapted from `tidygeocoder` package*
+
+In this first example we will geocode a few addresses using the `geo_lite()`
+function:
+
+
+```r
+library(tibble)
+
+# create a dataframe with addresses
+some_addresses <- tribble(
+ ~name, ~addr,
+ "White House", "1600 Pennsylvania Ave NW, Washington, DC",
+ "Transamerica Pyramid", "600 Montgomery St, San Francisco, CA 94111",
+ "Willis Tower", "233 S Wacker Dr, Chicago, IL 60606"
+)
+
+# geocode the addresses
+lat_longs <- geo_lite(some_addresses$addr, lat = "latitude", long = "longitude")
+#>
|
| | 0%
|
|================= | 33% (1/3)
|
|================================= | 67% (2/3)
|
|==================================================| 100% (3/3)
+```
+
+Only latitude and longitude are returned from the geocoder service in this
+example, but `full_results = TRUE` can be used to return all of the data from
+the geocoder service.
+
+
+
+|query | latitude| longitude|address |
+|:------------------------------------------|--------:|----------:|:-----------------------------------------------------------------------------------------------------------------|
+|1600 Pennsylvania Ave NW, Washington, DC | 38.89770| -77.03655|White House, 1600, Pennsylvania Avenue Northwest, Ward 2, Washington, District of Columbia, 20500, United States |
+|600 Montgomery St, San Francisco, CA 94111 | 37.79520| -122.40279|Transamerica Pyramid, 600, Montgomery Street, Financial District, San Francisco, California, 94111, United States |
+|233 S Wacker Dr, Chicago, IL 60606 | 41.87874| -87.63596|Willis Tower, 233, South Wacker Drive, Printer's Row, Loop, Chicago, Cook County, Illinois, 60606, United States |
+
+
+
+To perform reverse geocoding (obtaining addresses from geographic coordinates),
+we can use the `reverse_geo_lite()` function. The arguments are similar to the
+`geo_lite()` function, but now we specify the input data columns with the `lat`
+and `long` arguments. The dataset used here is from the geocoder query above.
+The single line address is returned in a column named by the `address`.
+
+
+```r
+reverse <- reverse_geo_lite(
+ lat = lat_longs$latitude, long = lat_longs$longitude,
+ address = "address_found"
+)
+#>
|
| | 0%
|
|================= | 33% (1/3)
|
|================================= | 67% (2/3)
|
|==================================================| 100% (3/3)
+```
+
+
+
+|address_found | lat| lon|
+|:-----------------------------------------------------------------------------------------------------------------|--------:|----------:|
+|White House, 1600, Pennsylvania Avenue Northwest, Ward 2, Washington, District of Columbia, 20500, United States | 38.89770| -77.03655|
+|Transamerica Pyramid, 600, Montgomery Street, Financial District, San Francisco, California, 94111, United States | 37.79520| -122.40279|
+|Willis Tower, 233, South Wacker Drive, Printer's Row, Loop, Chicago, Cook County, Illinois, 60606, United States | 41.87874| -87.63596|
+
+
+
+For more advance users, see [Nominatim
+docs](https://nominatim.org/release-docs/latest/api/Search/) to check the
+parameters available.
+
+## References