diff --git a/NEWS.md b/NEWS.md index 09e6806..991ffbb 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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 diff --git a/R/polar_annulusMap.R b/R/polar_annulusMap.R index e8c9488..4ddb2bb 100644 --- a/R/polar_annulusMap.R +++ b/R/polar_annulusMap.R @@ -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) { diff --git a/R/polar_diffMap.R b/R/polar_diffMap.R index d23d69c..bce3b19 100644 --- a/R/polar_diffMap.R +++ b/R/polar_diffMap.R @@ -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 <- diff --git a/R/polar_freqMap.R b/R/polar_freqMap.R index 2a38070..9fadb3f 100644 --- a/R/polar_freqMap.R +++ b/R/polar_freqMap.R @@ -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) { diff --git a/R/polar_percentileMap.R b/R/polar_percentileMap.R index 8d8b36c..a05609c 100644 --- a/R/polar_percentileMap.R +++ b/R/polar_percentileMap.R @@ -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) { diff --git a/R/polar_polarMap.R b/R/polar_polarMap.R index 041866a..21894e4 100644 --- a/R/polar_polarMap.R +++ b/R/polar_polarMap.R @@ -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")) { diff --git a/R/polar_pollroseMap.R b/R/polar_pollroseMap.R index 540c34d..f767339 100644 --- a/R/polar_pollroseMap.R +++ b/R/polar_pollroseMap.R @@ -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) { diff --git a/R/polar_windroseMap.R b/R/polar_windroseMap.R index 260109d..cda3cb5 100644 --- a/R/polar_windroseMap.R +++ b/R/polar_windroseMap.R @@ -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) { diff --git a/R/traj_trajMap.R b/R/traj_trajMap.R index 13c3607..4b34535 100644 --- a/R/traj_trajMap.R +++ b/R/traj_trajMap.R @@ -110,6 +110,8 @@ #' #' @param control Deprecated. Please use `type`. #' +#' @inheritDotParams openair::cutData -x -type +#' #' @returns A leaflet object. #' @export #' @@ -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( @@ -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() %>% @@ -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 @@ -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 <- @@ -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 ) } diff --git a/R/utils-map.R b/R/utils-map.R index 2a1984e..8fa614b 100644 --- a/R/utils-map.R +++ b/R/utils-map.R @@ -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) { diff --git a/man/trajMap.Rd b/man/trajMap.Rd index 2e4d657..93a22ba 100644 --- a/man/trajMap.Rd +++ b/man/trajMap.Rd @@ -19,7 +19,8 @@ trajMap( legend.title.autotext = TRUE, control.collapsed = FALSE, control.position = "topright", - control = NULL + control = NULL, + ... ) } \arguments{ @@ -124,6 +125,28 @@ Where should the "layer control" interface be placed? One of "topleft", argument of \code{\link[leaflet:addLayersControl]{leaflet::addLayersControl()}}.} \item{control}{Deprecated. Please use \code{type}.} + +\item{...}{ + Arguments passed on to \code{\link[openair:cutData]{openair::cutData}} + \describe{ + \item{\code{hemisphere}}{Can be \code{"northern"} or \code{"southern"}, used to +split data into seasons.} + \item{\code{n.levels}}{Number of quantiles to split numeric data into.} + \item{\code{start.day}}{What day of the week should the \code{type = "weekday"} +start on? The user can change the start day by supplying an integer +between 0 and 6. Sunday = 0, Monday = 1, \ldots For example to start the +weekday plots on a Saturday, choose \code{start.day = 6}.} + \item{\code{is.axis}}{A logical (\code{TRUE}/\code{FALSE}), used to request +shortened cut labels for axes.} + \item{\code{local.tz}}{Used for identifying whether a date has daylight savings time +(DST) applied or not. Examples include \code{local.tz = "Europe/London"}, +\code{local.tz = "America/New_York"} i.e. time zones that assume DST. +\url{https://en.wikipedia.org/wiki/List_of_zoneinfo_time_zones} shows time +zones that should be valid for most systems. It is important that the +original data are in GMT (UTC) or a fixed offset from GMT. See +\code{import} and the openair manual for information on how to import data +and ensure no DST is applied.} + }} } \value{ A leaflet object. diff --git a/man/trajMapStatic.Rd b/man/trajMapStatic.Rd index 0dac89d..2a53c14 100644 --- a/man/trajMapStatic.Rd +++ b/man/trajMapStatic.Rd @@ -142,66 +142,25 @@ draws solid lines.} \item{facet}{Deprecated. Please use \code{type}.} \item{...}{ - Arguments passed on to \code{\link[ggplot2:ggsf]{ggplot2::coord_sf}} + Arguments passed on to \code{\link[openair:cutData]{openair::cutData}} \describe{ - \item{\code{expand}}{If \code{TRUE}, the default, adds a small expansion factor to -the limits to ensure that data and axes don't overlap. If \code{FALSE}, -limits are taken exactly from the data or \code{xlim}/\code{ylim}.} - \item{\code{datum}}{CRS that provides datum to use when generating graticules.} - \item{\code{label_graticule}}{Character vector indicating which graticule lines should be labeled -where. Meridians run north-south, and the letters \code{"N"} and \code{"S"} indicate that -they should be labeled on their north or south end points, respectively. -Parallels run east-west, and the letters \code{"E"} and \code{"W"} indicate that they -should be labeled on their east or west end points, respectively. Thus, -\code{label_graticule = "SW"} would label meridians at their south end and parallels at -their west end, whereas \code{label_graticule = "EW"} would label parallels at both -ends and meridians not at all. Because meridians and parallels can in general -intersect with any side of the plot panel, for any choice of \code{label_graticule} labels -are not guaranteed to reside on only one particular side of the plot panel. Also, -\code{label_graticule} can cause labeling artifacts, in particular if a graticule line -coincides with the edge of the plot panel. In such circumstances, \code{label_axes} will -generally yield better results and should be used instead. - -This parameter can be used alone or in combination with \code{label_axes}.} - \item{\code{label_axes}}{Character vector or named list of character values -specifying which graticule lines (meridians or parallels) should be labeled on -which side of the plot. Meridians are indicated by \code{"E"} (for East) and -parallels by \code{"N"} (for North). Default is \code{"--EN"}, which specifies -(clockwise from the top) no labels on the top, none on the right, meridians -on the bottom, and parallels on the left. Alternatively, this setting could have been -specified with \code{list(bottom = "E", left = "N")}. - -This parameter can be used alone or in combination with \code{label_graticule}.} - \item{\code{lims_method}}{Method specifying how scale limits are converted into -limits on the plot region. Has no effect when \code{default_crs = NULL}. -For a very non-linear CRS (e.g., a perspective centered -around the North pole), the available methods yield widely differing results, and -you may want to try various options. Methods currently implemented include \code{"cross"} -(the default), \code{"box"}, \code{"orthogonal"}, and \code{"geometry_bbox"}. For method \code{"cross"}, -limits along one direction (e.g., longitude) are applied at the midpoint of the -other direction (e.g., latitude). This method avoids excessively large limits for -rotated coordinate systems but means that sometimes limits need to be expanded a -little further if extreme data points are to be included in the final plot region. -By contrast, for method \code{"box"}, a box is generated out of the limits along both directions, -and then limits in projected coordinates are chosen such that the entire box is -visible. This method can yield plot regions that are too large. Finally, method -\code{"orthogonal"} applies limits separately along each axis, and method -\code{"geometry_bbox"} ignores all limit information except the bounding boxes of any -objects in the \code{geometry} aesthetic.} - \item{\code{ndiscr}}{Number of segments to use for discretising graticule lines; -try increasing this number when graticules look incorrect.} - \item{\code{default}}{Is this the default coordinate system? If \code{FALSE} (the default), -then replacing this coordinate system with another one creates a message alerting -the user that the coordinate system is being replaced. If \code{TRUE}, that warning -is suppressed.} - \item{\code{clip}}{Should drawing be clipped to the extent of the plot panel? A -setting of \code{"on"} (the default) means yes, and a setting of \code{"off"} -means no. In most cases, the default of \code{"on"} should not be changed, -as setting \code{clip = "off"} can cause unexpected results. It allows -drawing of data points anywhere on the plot, including in the plot margins. If -limits are set via \code{xlim} and \code{ylim} and some data points fall outside those -limits, then those data points may show up in places such as the axes, the -legend, the plot title, or the plot margins.} + \item{\code{hemisphere}}{Can be \code{"northern"} or \code{"southern"}, used to +split data into seasons.} + \item{\code{n.levels}}{Number of quantiles to split numeric data into.} + \item{\code{start.day}}{What day of the week should the \code{type = "weekday"} +start on? The user can change the start day by supplying an integer +between 0 and 6. Sunday = 0, Monday = 1, \ldots For example to start the +weekday plots on a Saturday, choose \code{start.day = 6}.} + \item{\code{is.axis}}{A logical (\code{TRUE}/\code{FALSE}), used to request +shortened cut labels for axes.} + \item{\code{local.tz}}{Used for identifying whether a date has daylight savings time +(DST) applied or not. Examples include \code{local.tz = "Europe/London"}, +\code{local.tz = "America/New_York"} i.e. time zones that assume DST. +\url{https://en.wikipedia.org/wiki/List_of_zoneinfo_time_zones} shows time +zones that should be valid for most systems. It is important that the +original data are in GMT (UTC) or a fixed offset from GMT. See +\code{import} and the openair manual for information on how to import data +and ensure no DST is applied.} }} } \value{