Skip to content

Commit

Permalink
Merge branch 'master' into feat/traj-ggspatial
Browse files Browse the repository at this point in the history
  • Loading branch information
jack-davison committed May 13, 2024
2 parents a046652 + 7e1f5d9 commit ddb780d
Show file tree
Hide file tree
Showing 20 changed files with 291 additions and 80 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

* Popups for the dynamic `polarMap()` family will now be near the top of the plot rather than the centre. This will obscure less of the plot itself while the marker is visible.

* `quickTextHTML()`'s lookup table has gained new pollutants and units, and ignores the input case of `text` more consistently.

* Two examples of the use of `{openairmaps}` with `{shiny}` have been added to the package. Run `shiny::runExample(package = "openairmaps")` to view these.

## Bug fixes
Expand All @@ -40,6 +42,8 @@

* "illegal" file path characters can now be used in the columns provided to the `type` argument of the `polarMap()` family. Most relevant to most users is that this will allow them to provide their own custom HTML tags - e.g., for formatting superscripts, subscripts, and so on.

* The colours in the legend of `networkMap()` now better align with the actual colours of the markers, and the layer control menu when `control = "variable"` is now presented in a nicer order with clearer labels.

# openairmaps 0.8.1

This is a minor release of `{openairmaps}`, released mainly to fix an issue with `{ggmap}` but also adding some new functionality for polar marker maps.
Expand Down
32 changes: 23 additions & 9 deletions R/network_networkMap.R
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,19 @@ networkMap <-
"lightgray",
"black",
"pink"
),
realcolour = c(
"#d33d29",
"#f49630",
"#36a5d7",
"#70ad25",
"#cf51b6",
"#a3a3a3",
"#303030",
"#ff8ee9"
)
) %>%
dplyr::mutate(colour2 = ifelse(.data$colour == "white", "gray", "white"))
dplyr::mutate(colour2 = ifelse(.data$colour == "#FFFFFF", "#303030", "#FFFFFF"))

# read in data
meta <-
Expand Down Expand Up @@ -305,9 +315,10 @@ networkMap <-
label = dat[["site"]],
clusterOptions = clusteropts,
icon = leaflet::makeAwesomeIcon(
library = "fa",
icon = "info-circle",
markerColor = dat$colour,
iconColor = dat$colour2,
icon = "info-sign"
iconColor = dat$colour2
)
)
}
Expand All @@ -319,7 +330,7 @@ networkMap <-
map,
position = control.position,
options = leaflet::layersControlOptions(collapsed = control.collapsed, autoZIndex = FALSE),
baseGroups = quickTextHTML(sort(control_vars)),
baseGroups = sort(quickTextHTML(control_vars)),
overlayGroups = names(provider)
) %>%
leaflet::hideGroup(group = names(provider)[[-1]])
Expand Down Expand Up @@ -368,9 +379,10 @@ networkMap <-
label = dat[["site"]],
clusterOptions = clusteropts,
icon = leaflet::makeAwesomeIcon(
library = "fa",
icon = "info-circle",
markerColor = dat$colour,
iconColor = dat$colour2,
icon = "info-sign"
iconColor = dat$colour2
)
)

Expand All @@ -391,10 +403,11 @@ networkMap <-
map <-
leaflet::addLegend(
map,
opacity = 1,
position = check_legendposition(legend.position, static = FALSE),
title = "Network",
colors = cols$colour,
labels = cols$network
colors = cols$realcolour,
labels = paste0("<span style='line-height:1.6'>", cols$network, "</span>")
)
}

Expand Down Expand Up @@ -464,7 +477,8 @@ prepNetworkData <- function(source, year) {
"135TMB",
"c2PENTEN",
"MEPENT",
"3MEPENT"
"3MEPENT",
"NAPHTH"
)

meta <- dplyr::filter(
Expand Down
6 changes: 4 additions & 2 deletions R/polar_annulusMap.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ annulusMap <- function(data,
type = NULL,
popup = NULL,
label = NULL,
provider = NULL,
provider = "OpenStreetMap",
cols = "turbo",
alpha = 1,
key = FALSE,
Expand All @@ -56,6 +56,7 @@ annulusMap <- function(data,
legend.title.autotext = TRUE,
control.collapsed = FALSE,
control.position = "topright",
control.autotext = TRUE,
d.icon = 200,
d.fig = 3.5,
static = FALSE,
Expand Down Expand Up @@ -253,7 +254,8 @@ annulusMap <- function(data,
label,
split_col,
control.collapsed,
control.position
control.position,
control.autotext
)

# add legend if limits are set
Expand Down
6 changes: 4 additions & 2 deletions R/polar_diffMap.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ diffMap <- function(before,
type = NULL,
popup = NULL,
label = NULL,
provider = NULL,
provider = "OpenStreetMap",
cols = "RdBu",
alpha = 1,
key = FALSE,
Expand All @@ -75,6 +75,7 @@ diffMap <- function(before,
legend.title.autotext = TRUE,
control.collapsed = FALSE,
control.position = "topright",
control.autotext = TRUE,
d.icon = 200,
d.fig = 3.5,
static = FALSE,
Expand Down Expand Up @@ -278,7 +279,8 @@ diffMap <- function(before,
label,
split_col,
control.collapsed,
control.position
control.position,
control.autotext
)

# add legend if limits are set
Expand Down
6 changes: 4 additions & 2 deletions R/polar_freqMap.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ freqMap <- function(data,
type = NULL,
popup = NULL,
label = NULL,
provider = NULL,
provider = "OpenStreetMap",
cols = "turbo",
alpha = 1,
key = FALSE,
Expand All @@ -79,6 +79,7 @@ freqMap <- function(data,
legend.title.autotext = TRUE,
control.collapsed = FALSE,
control.position = "topright",
control.autotext = TRUE,
d.icon = 200,
d.fig = 3.5,
static = FALSE,
Expand Down Expand Up @@ -285,7 +286,8 @@ freqMap <- function(data,
label,
split_col,
control.collapsed,
control.position
control.position,
control.autotext
)

# add legends if breaks are set
Expand Down
6 changes: 4 additions & 2 deletions R/polar_percentileMap.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ percentileMap <- function(data,
type = NULL,
popup = NULL,
label = NULL,
provider = NULL,
provider = "OpenStreetMap",
cols = "turbo",
alpha = 1,
key = FALSE,
Expand All @@ -65,6 +65,7 @@ percentileMap <- function(data,
legend.title.autotext = TRUE,
control.collapsed = FALSE,
control.position = "topright",
control.autotext = TRUE,
d.icon = 200,
d.fig = 3.5,
static = FALSE,
Expand Down Expand Up @@ -259,7 +260,8 @@ percentileMap <- function(data,
label,
split_col,
control.collapsed,
control.position
control.position,
control.autotext
)

legend.title <-
Expand Down
23 changes: 19 additions & 4 deletions R/polar_polarMap.R
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,10 @@
#'
#' @param provider *The basemap(s) to be used.*
#'
#' *default:* `NULL` | *scope:* dynamic & static
#' *default:* `"OpenStreetMap"` | *scope:* dynamic & static
#'
#' The base map(s) to be used beneath the polar markers. If not provided, will
#' default to OpenStreetMap for both dynamic and static maps.
#' default to `"OpenStreetMap"`/`"osm"` for both dynamic and static maps.
#'
#' - *Dynamic*: Any number of [leaflet::providers].
#' See <http://leaflet-extras.github.io/leaflet-providers/preview/> for a list
Expand All @@ -149,6 +149,11 @@
#'
#' - *Static*: One of [rosm::osm.types()].
#'
#' There is some overlap in static and dynamic providers. For example,
#' `{ggspatial}` uses "osm" to specify "OpenStreetMap". When static providers
#' are provided to dynamic maps or vice versa, `{openairmaps}` will attempt to
#' substitute the correct provider string.
#'
#' @param cols *Colours to use for plotting.*
#'
#' *default:* `"turbo"` | *scope:* dynamic & static
Expand Down Expand Up @@ -220,6 +225,14 @@
#' "bottomleft" or "bottomright". Passed to the `position` argument of
#' [leaflet::addLayersControl()].
#'
#' @param control.autotext *Automatically format the content of the layer
#' control menu?*
#'
#' *default:* `TRUE` | *scope:* dynamic
#'
#' When `control.autotext = TRUE`, the content of the "layer control"
#' interface will be first run through [quickTextHTML()].
#'
#' @param d.icon *The diameter of the plot on the map in pixels.*
#'
#' *default:* `200` | *scope:* dynamic & static
Expand Down Expand Up @@ -287,7 +300,7 @@ polarMap <- function(data,
type = NULL,
popup = NULL,
label = NULL,
provider = NULL,
provider = "OpenStreetMap",
cols = "turbo",
alpha = 1,
key = FALSE,
Expand All @@ -297,6 +310,7 @@ polarMap <- function(data,
legend.title.autotext = TRUE,
control.collapsed = FALSE,
control.position = "topright",
control.autotext = TRUE,
d.icon = 200,
d.fig = 3.5,
static = FALSE,
Expand Down Expand Up @@ -446,7 +460,8 @@ polarMap <- function(data,
label,
split_col,
control.collapsed,
control.position
control.position,
control.autotext
)

# add legend if limits are set
Expand Down
6 changes: 4 additions & 2 deletions R/polar_pollroseMap.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pollroseMap <- function(data,
type = NULL,
popup = NULL,
label = NULL,
provider = NULL,
provider = "OpenStreetMap",
cols = "turbo",
alpha = 1,
key = FALSE,
Expand All @@ -68,6 +68,7 @@ pollroseMap <- function(data,
legend.title.autotext = TRUE,
control.collapsed = FALSE,
control.position = "topright",
control.autotext = TRUE,
d.icon = 200,
d.fig = 3.5,
static = FALSE,
Expand Down Expand Up @@ -237,7 +238,8 @@ pollroseMap <- function(data,
label,
split_col,
control.collapsed,
control.position
control.position,
control.autotext
)

# add legend if breaks are defined
Expand Down
6 changes: 4 additions & 2 deletions R/polar_windroseMap.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ windroseMap <- function(data,
type = NULL,
popup = NULL,
label = NULL,
provider = NULL,
provider = "OpenStreetMap",
cols = "turbo",
alpha = 1,
key = FALSE,
Expand All @@ -72,6 +72,7 @@ windroseMap <- function(data,
legend.title.autotext = TRUE,
control.collapsed = FALSE,
control.position = "topright",
control.autotext = TRUE,
d.icon = 200,
d.fig = 3.5,
static = FALSE,
Expand Down Expand Up @@ -244,7 +245,8 @@ windroseMap <- function(data,
label,
split_col,
control.collapsed,
control.position
control.position,
control.autotext
)

# add legend
Expand Down
Loading

0 comments on commit ddb780d

Please sign in to comment.