Showing 1 of 5 files from the diff.
Other files ignored by Codecov
NEWS.md has changed.
DESCRIPTION has changed.
man/geocode.Rd has changed.

@@ -6,6 +6,7 @@
Loading
6 6
#' \href{https://developer.here.com/documentation/geocoding-search-api/dev_guide/topics/endpoint-geocode-brief.html}{HERE Geocoder API: Geocode}
7 7
#'
8 8
#' @param address character, addresses to geocode.
9 +
#' @param alternatives boolean, return also alternative results (\code{default = FALSE})?
9 10
#' @param sf boolean, return an \code{sf} object (\code{default = TRUE}) or a
10 11
#'   \code{data.frame}?
11 12
#' @param url_only boolean, only return the generated URLs (\code{default =
@@ -25,7 +26,7 @@
Loading
25 26
#' set_key("<YOUR API KEY>")
26 27
#'
27 28
#' locs <- geocode(address = poi$city, url_only = TRUE)
28 -
geocode <- function(address, sf = TRUE, url_only = FALSE, addresses) {
29 +
geocode <- function(address, alternatives = FALSE, sf = TRUE, url_only = FALSE, addresses) {
29 30
30 31
  if (!missing("addresses")) {
31 32
    warning("'addresses' is deprecated, use 'address' instead.")
@@ -34,6 +35,7 @@
Loading
34 35
35 36
  # Input checks
36 37
  .check_addresses(address)
38 +
  .check_boolean(alternatives)
37 39
  .check_boolean(sf)
38 40
  .check_boolean(url_only)
39 41
@@ -59,7 +61,7 @@
Loading
59 61
  if (length(data) == 0) return(NULL)
60 62
61 63
  # Extract information
62 -
  geocoded <- .extract_geocoded(data, address)
64 +
  geocoded <- .extract_geocoded(data, address, alternatives)
63 65
64 66
  # Create sf object
65 67
  if (nrow(geocoded) > 0) {
@@ -87,9 +89,10 @@
Loading
87 89
  }
88 90
}
89 91
90 -
.extract_geocoded <- function(data, address) {
92 +
.extract_geocoded <- function(data, address, alternatives) {
91 93
  template <- data.table::data.table(
92 94
    id = numeric(),
95 +
    rank = numeric(),
93 96
    address = character(),
94 97
    type = character(),
95 98
    street = character(),
@@ -119,6 +122,7 @@
Loading
119 122
             }
120 123
             result <- data.table::data.table(
121 124
               id = ids[count],
125 +
               rank = seq_len(nrow(df$items)),
122 126
               address = df$items$address$label,
123 127
               type = df$items$resultType,
124 128
               street = df$items$address$street,
@@ -134,7 +138,11 @@
Loading
134 138
               lng_position = df$items$position$lng,
135 139
               lat_position = df$items$position$lat
136 140
             )
137 -
             result[1, ]
141 +
             if (alternatives) {
142 +
               return(result)
143 +
             } else {
144 +
               return(result[1, ])
145 +
             }
138 146
           })
139 147
    ), fill = TRUE
140 148
  )
Files Coverage
R 92.80%
Project Totals (16 files) 92.80%
1
comment: false
2

3
coverage:
4
  status:
5
    project:
6
      default:
7
        target: auto
8
        threshold: 1%
9
    patch:
10
      default:
11
        target: auto
12
        threshold: 1%
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading