Skip to content

Commit

Permalink
change enclosing arg for opq_enclosing for #199
Browse files Browse the repository at this point in the history
  • Loading branch information
mpadge committed Jun 8, 2020
1 parent 55f2345 commit 145b111
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: osmdata
Version: 0.1.3.008
Version: 0.1.3.009
Authors@R: c(
person("Mark", "Padgham", email="mark.padgham@email.com", role=c("aut", "cre")),
person("Bob", "Rudis", role="aut"),
Expand Down
14 changes: 10 additions & 4 deletions R/opq.R
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,9 @@ opq_osm_id <- function (id = NULL, type = NULL, open_url = FALSE)
#' @param lat Latitude of desired point
#' @param key (Optional) OSM key of enclosing data
#' @param value (Optional) OSM value matching 'key' of enclosing data
#' @param enclosing Either 'relation' or 'way' for whether to return enclosing
#' objects of those respective types (where generally 'relation' will correspond
#' to multipolygon objects, and 'way' to polygon objects).
#' @inheritParams opq
#'
#' @examples
Expand All @@ -325,7 +328,10 @@ opq_osm_id <- function (id = NULL, type = NULL, open_url = FALSE)
#' x <- osmdata_sf (q)
#' }
#' @export
opq_enclosing <- function (lon, lat, key = NULL, value = NULL, timeout = 25) {
opq_enclosing <- function (lon, lat, key = NULL, value = NULL,
enclosing = "relation", timeout = 25) {
enclosing <- match.arg (tolower (enclosing), c ("relation", "way"))

bbox <- bbox_to_string (c (lon, lat, lon, lat))
timeout <- format (timeout, scientific = FALSE)
prefix <- paste0 ("[out:xml][timeout:", timeout, "]")
Expand All @@ -339,7 +345,7 @@ opq_enclosing <- function (lon, lat, key = NULL, value = NULL, timeout = 25) {
class (res) <- c (class (res), "overpass_query")
attr (res, "datetime") <- attr (res, "datetime2") <- NULL
attr (res, "nodes_only") <- FALSE
attr (res, "enclosing") <- TRUE
attr (res, "enclosing") <- enclosing

return (res)
}
Expand Down Expand Up @@ -376,9 +382,9 @@ opq_string_intern <- function (opq, quiet = TRUE)
features <- paste0 (sprintf (' node %s (%s);\n',
features,
opq$bbox))
else if (attr (opq, "enclosing"))
else if (!is.null (attr (opq, "enclosing")))
features <- paste0 ("is_in(", lat, ",", lon, ")->.a;",
"relation(pivot.a)",
attr (opq, "enclosing"), "(pivot.a)",
features,
";")
else
Expand Down
2 changes: 1 addition & 1 deletion codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"codeRepository": "https://github.com/ropensci/osmdata",
"issueTracker": "https://github.com/ropensci/osmdata/issues",
"license": "https://spdx.org/licenses/GPL-3.0",
"version": "0.1.3.8",
"version": "0.1.3.9",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
Expand Down
13 changes: 12 additions & 1 deletion man/opq_enclosing.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 145b111

Please # to comment.