Skip to content

Commit

Permalink
fix: pass ... to openair::cutData() in polarMap() and trajMap()
Browse files Browse the repository at this point in the history
  • Loading branch information
jack-davison-ricardo committed May 23, 2024
1 parent 16db2ae commit d53eb09
Show file tree
Hide file tree
Showing 12 changed files with 61 additions and 84 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

* Vectors greater than length 1 passed to `popup` in the `polarMap()` argument will no longer error when `type = NULL`.

* `...` will successfully pass to `openair::cutData()` in the `polarMap()` and `trajMap()` families of functions.

# openairmaps 0.9.0

## Breaking changes
Expand Down
2 changes: 1 addition & 1 deletion R/polar_annulusMap.R
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ annulusMap <- function(data,
}

# cut data
data <- quick_cutdata(data = data, type = type)
data <- openair::cutData(x = data, type = type, ...)

# deal with popups
if (length(popup) > 1) {
Expand Down
4 changes: 2 additions & 2 deletions R/polar_diffMap.R
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ diffMap <- function(before,
}

# cut data
before <- quick_cutdata(data = before, type = type)
after <- quick_cutdata(data = after, type = type)
before <- openair::cutData(x = before, type = type %||% "default", ...)
after <- openair::cutData(x = after, type = type %||% "default", ...)

# prep data
before <-
Expand Down
2 changes: 1 addition & 1 deletion R/polar_freqMap.R
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ freqMap <- function(data,
}

# cut data
data <- quick_cutdata(data = data, type = type)
data <- openair::cutData(x = data, type = type %||% "default", ...)

# deal with popups
if (length(popup) > 1) {
Expand Down
2 changes: 1 addition & 1 deletion R/polar_percentileMap.R
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ percentileMap <- function(data,
}

# cut data
data <- quick_cutdata(data = data, type = type)
data <- openair::cutData(x = data, type = type %||% "default", ...)

# deal with popups
if (length(popup) > 1) {
Expand Down
2 changes: 1 addition & 1 deletion R/polar_polarMap.R
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ polarMap <- function(data,
}

# cut data
data <- quick_cutdata(data = data, type = type)
data <- openair::cutData(x = data, type = type %||% "default", ...)

# deal with upper
if (any(upper == "fixed")) {
Expand Down
2 changes: 1 addition & 1 deletion R/polar_pollroseMap.R
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ pollroseMap <- function(data,
longitude <- latlon$longitude

# cut data
data <- quick_cutdata(data = data, type = type)
data <- openair::cutData(x = data, type = type %||% "default", ...)

# deal with popups
if (length(popup) > 1) {
Expand Down
2 changes: 1 addition & 1 deletion R/polar_windroseMap.R
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ windroseMap <- function(data,
data$ws_dup <- data$ws

# cut data
data <- quick_cutdata(data = data, type = type)
data <- openair::cutData(x = data, type = type %||% "default", ...)

# deal with popups
if (length(popup) > 1) {
Expand Down
17 changes: 9 additions & 8 deletions R/traj_trajMap.R
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@
#'
#' @param control Deprecated. Please use `type`.
#'
#' @inheritDotParams openair::cutData -x -type
#'
#' @returns A leaflet object.
#' @export
#'
Expand All @@ -136,7 +138,8 @@ trajMap <-
legend.title.autotext = TRUE,
control.collapsed = FALSE,
control.position = "topright",
control = NULL) {
control = NULL,
...) {
# handle deprecated argument
if (!is.null(control)) {
lifecycle::deprecate_soft(
Expand All @@ -158,8 +161,8 @@ trajMap <-
data$datef <- factor(data$date)

# if no "type", get a fake column
data <- quick_cutdata(data, type)
type <- type %||% "default"
data <- openair::cutData(x = data, type = type, ...)

# initialise map
map <- leaflet::leaflet() %>%
Expand Down Expand Up @@ -406,7 +409,7 @@ trajMap <-
#'
#' @param facet Deprecated. Please use `type`.
#'
#' @inheritDotParams ggplot2::coord_sf -xlim -ylim -crs -default_crs
#' @inheritDotParams openair::cutData -x -type
#'
#' @returns a `ggplot2` plot
#' @export
Expand Down Expand Up @@ -462,7 +465,7 @@ trajMapStatic <-
type <- type %||% facet

# cut data
data <- quick_cutdata(data, type)
data <- openair::cutData(x = data, type = type, ...)

# make plot
plt <-
Expand Down Expand Up @@ -512,15 +515,13 @@ trajMapStatic <-
xlim = xlim,
ylim = ylim,
default_crs = sf::st_crs(4326),
crs = crs,
...
crs = crs
)
} else {
coords <-
ggplot2::coord_sf(
xlim = xlim,
ylim = ylim,
...
ylim = ylim
)
}

Expand Down
8 changes: 0 additions & 8 deletions R/utils-map.R
Original file line number Diff line number Diff line change
Expand Up @@ -625,14 +625,6 @@ quick_popup <- function(data, popup, latitude, longitude, control) {
)
}

#' does 'cutdata'
#' @param data,type inherited from parent function
#' @noRd
quick_cutdata <- function(data, type) {
if (is.null(type)) type <- "default"
openair::cutData(data, type = type)
}

#' checks if multiple pollutants have been provided with a "fixed" scale
#' @noRd
check_multipoll <- function(vec, pollutant) {
Expand Down
25 changes: 24 additions & 1 deletion man/trajMap.Rd

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

77 changes: 18 additions & 59 deletions man/trajMapStatic.Rd

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

0 comments on commit d53eb09

Please sign in to comment.