Skip to content

Commit

Permalink
changed opt names set.view to set_view, updated webGL checks
Browse files Browse the repository at this point in the history
  • Loading branch information
mtennekes committed Nov 21, 2024
1 parent fc82420 commit 243c0c0
Show file tree
Hide file tree
Showing 19 changed files with 207 additions and 145 deletions.
2 changes: 1 addition & 1 deletion R/global-variables.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ utils::globalVariables(c(
"outer.margins", "pages", "panel.label.height",
"panel.labels", "panel.type", "panel.wrap.pos", "panel.xtab.pos", "pos.h",
"pos.h.id", "pos.v", "pos.v.id", "red", "rows", "s1", "s2", "s3", "s4",
"scale.factor", "set.bounds",
"scale.factor", "set_bounds",
"split_geometry_collection", "stack_auto", "t1",
"t2", "t3", "t4", "text.fontface", "text.fontfamily", "title.bg.alpha",
"tmapID__", "vneutral",
Expand Down
19 changes: 19 additions & 0 deletions R/messages.R
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,22 @@ error_dimvalues = function() {
)
}

message_webgl_vars = function(supported, vary) {
sup_text = paste(supported, collapse = ", ")
var_text = paste(names(vary)[vary], collapse = ", ")
var_sel = names(vary)[vary]

cli::cli_inform("{.field [view mode]} WegGL enabled, but the only supported visual variables are: {.val {supported}}. The visual variable(s) {.val {var_sel}} are not supported. Set {.code use_WebGL = FALSE} to support them.")

}

message_webgl_hover = function(type) {
cli::cli_inform("{.field [view mode]} WegGL enabled, but it does not support hover labels for layer type {.val {type}}. Set {.code use_WebGL = FALSE} to support them.")
}


message_webgl_checks = function(checks, checkif) {
vals = paste(paste(names(checkif)[!checks], checkif[!checks], sep = " = "), collapse = ", ")
cli::cli_inform("{.field [view mode]} WegGL enabled, but the following visual variable only accept one value {.arg {vals}}. Set {.code use_WebGL = FALSE} to support them.")

}
28 changes: 14 additions & 14 deletions R/process_meta.R
Original file line number Diff line number Diff line change
Expand Up @@ -578,28 +578,28 @@ process_meta = function(o, d, cdt, aux) {

legend.position = NA

if (!is.logical(set.bounds)) if (length(set.bounds) !=4 || !is.numeric(set.bounds)) stop("Incorrect set_bounds argument", call.=FALSE)
if (!is.logical(set_bounds)) if (length(set_bounds) !=4 || !is.numeric(set_bounds)) stop("Incorrect set_bounds argument", call.=FALSE)


if (!is.na(set.view[1])) {
if (!is.numeric(set.view)) stop("set.view is not numeric")
if (!length(set.view) %in% c(1, 3)) stop("set.view does not have length 1 or 3")
if (!is.na(set_view[1])) {
if (!is.numeric(set_view)) stop("set_view is not numeric")
if (!length(set_view) %in% c(1, 3)) stop("set_view does not have length 1 or 3")
}
if (!is.na(set.zoom.limits[1])) {
if (!is.numeric(set.zoom.limits)) stop("set.zoom.limits is not numeric")
if (!length(set.zoom.limits)==2) stop("set.zoom.limits does not have length 2")
if (set.zoom.limits[1] >= set.zoom.limits[2]) stop("incorrect set.zoom.limits")
if (!is.na(set_zoom_limits[1])) {
if (!is.numeric(set_zoom_limits)) stop("set_zoom_limits is not numeric")
if (!length(set_zoom_limits)==2) stop("set_zoom_limits does not have length 2")
if (set_zoom_limits[1] >= set_zoom_limits[2]) stop("incorrect set_zoom_limits")
} else {
set.zoom.limits <- c(NA, NA)
set_zoom_limits <- c(NA, NA)
}
if (!is.na(set.view[1]) && !is.na(set.zoom.limits[1])) {
if (set.view[length(set.view)] < set.zoom.limits[1]) {
if (!is.na(set_view[1]) && !is.na(set_zoom_limits[1])) {
if (set_view[length(set_view)] < set_zoom_limits[1]) {
if (show.warnings) warning("default zoom smaller than minimum zoom, now it is set to the minimum zoom")
set.view[length(set.view)] <- set.zoom.limits[1]
set_view[length(set_view)] <- set_zoom_limits[1]
}
if (set.view[length(set.view)] > set.zoom.limits[2]) {
if (set_view[length(set_view)] > set_zoom_limits[2]) {
if (show.warnings) warning("default zoom larger than maximum zoom, now it is set to the maximum zoom")
set.view[length(set.view)] <- set.zoom.limits[2]
set_view[length(set_view)] <- set_zoom_limits[2]
}
}

Expand Down
4 changes: 2 additions & 2 deletions R/step2_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ step2_data = function(tm) {
hover.data = if (tml$hover == "") {
NULL
} else {
as.character(dt[[tml$hover]])
data.table(hover = as.character(dt[[tml$hover]]), tmapID__ = dt$tmapID__)
}
id.data = if (tml$id == "") {
NULL
} else {
as.character(dt[[tml$id]])
data.table(id = as.character(dt[[tml$id]]), tmapID__ = dt$tmapID__)
}

format_called = attr(tml$popup.format, "called")
Expand Down
31 changes: 14 additions & 17 deletions R/tm_layout.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#' @name tm_layout
#' @export
tm_layout = function(
scale, asp, bg.color, outer.bg.color, frame, frame.lwd, frame.r, frame.double_line, outer.margins, inner.margins, inner.margins.extra, meta.margins, meta.auto_margins, between_margin, panel.margin, component.offset, component.stack_margin, grid.mark.height, xylab.height, coords.height, xlab.show, xlab.text, xlab.size, xlab.color, xlab.rotation, xlab.space, xlab.fontface, xlab.fontfamily, xlab.side, ylab.show, ylab.text, ylab.size, ylab.color, ylab.rotation, ylab.space, ylab.fontface, ylab.fontfamily, ylab.side, panel.type, panel.wrap.pos, panel.xtab.pos, unit, color.sepia_intensity, color.saturation, color_vision_deficiency_sim, text.fontface, text.fontfamily, component.position, component.autoscale, legend.show, legend.design, legend.orientation, legend.position, legend.width, legend.height, legend.stack, legend.group.frame, legend.resize_as_group, legend.reverse, legend.na.show, legend.title.color, legend.title.size, legend.title.fontface, legend.title.fontfamily, legend.xlab.color, legend.xlab.size, legend.xlab.fontface, legend.xlab.fontfamily, legend.ylab.color, legend.ylab.size, legend.ylab.fontface, legend.ylab.fontfamily, legend.text.color, legend.text.size, legend.text.fontface, legend.text.fontfamily, legend.frame, legend.frame.lwd, legend.frame.r, legend.bg.color, legend.bg.alpha, legend.only, legend.settings.standard.portrait, legend.settings.standard.landscape, chart.show, chart.plot.axis.x, chart.plot.axis.y, chart.position, chart.width, chart.height, chart.stack, chart.group.frame, chart.resize_as_group, chart.reverse, chart.na.show, chart.title.color, chart.title.size, chart.title.fontface, chart.title.fontfamily, chart.xlab.color, chart.xlab.size, chart.xlab.fontface, chart.xlab.fontfamily, chart.ylab.color, chart.ylab.size, chart.ylab.fontface, chart.ylab.fontfamily, chart.text.color, chart.text.size, chart.text.fontface, chart.text.fontfamily, chart.frame, chart.frame.lwd, chart.frame.r, chart.bg.color, chart.bg.alpha, chart.object.color, title.show, title.size, title.color, title.fontface, title.fontfamily, title.bg.color, title.bg.alpha, title.padding, title.frame, title.frame.lwd, title.frame.r, title.stack, title.position, title.width, title.group.frame, title.resize_as_group, credits.show, credits.size, credits.color, credits.fontface, credits.fontfamily, credits.bg.color, credits.bg.alpha, credits.padding, credits.frame, credits.frame.lwd, credits.frame.r, credits.stack, credits.position, credits.width, credits.height, credits.group.frame, credits.resize_as_group, compass.north, compass.type, compass.text.size, compass.size, compass.show.labels, compass.cardinal.directions, compass.text.color, compass.color.dark, compass.color.light, compass.lwd, compass.bg.color, compass.bg.alpha, compass.margins, compass.show, compass.stack, compass.position, compass.frame, compass.frame.lwd, compass.frame.r, compass.group.frame, compass.resize_as_group, logo.height, logo.margins, logo.between_margin, logo.show, logo.stack, logo.position, logo.frame, logo.frame.lwd, logo.frame.r, logo.group.frame, logo.resize_as_group, scalebar.show, scalebar.breaks, scalebar.width, scalebar.text.size, scalebar.text.color, scalebar.color.dark, scalebar.color.light, scalebar.lwd, scalebar.bg.color, scalebar.bg.alpha, scalebar.size, scalebar.margins, scalebar.stack, scalebar.position, scalebar.frame, scalebar.frame.lwd, scalebar.frame.r, scalebar.group.frame, scalebar.resize_as_group, grid.show, grid.labels.pos, grid.x, grid.y, grid.n.x, grid.n.y, grid.crs, grid.col, grid.lwd, grid.alpha, grid.labels.show, grid.labels.size, grid.labels.col, grid.labels.rot, grid.labels.format, grid.labels.cardinal, grid.labels.margin.x, grid.labels.margin.y, grid.labels.space.x, grid.labels.space.y, grid.labels.inside_frame, grid.ticks, grid.lines, grid.ndiscr, mouse_coordinates.stack, mouse_coordinates.position, mouse_coordinates.show, minimap.server, minimap.toggle, minimap.stack, minimap.position, minimap.show, panel.show, panel.labels, panel.label.size, panel.label.color, panel.label.fontface, panel.label.fontfamily, panel.label.bg.color, panel.label.frame, panel.label.frame.lwd, panel.label.frame.r, panel.label.height, panel.label.rot, bbox, set.bounds, set.view, set.zoom.limits, qtm.scalebar, qtm.minimap, qtm.mouse_coordinates, earth_boundary, earth_boundary.color, earth_boundary.lwd, earth_datum, space.color, check_and_fix, basemap.show, basemap.server, basemap.alpha, basemap.zoom, tiles.show, tiles.server, tiles.alpha, tiles.zoom, attr.color,
scale, asp, bg.color, outer.bg.color, frame, frame.lwd, frame.r, frame.double_line, outer.margins, inner.margins, inner.margins.extra, meta.margins, meta.auto_margins, between_margin, panel.margin, component.offset, component.stack_margin, grid.mark.height, xylab.height, coords.height, xlab.show, xlab.text, xlab.size, xlab.color, xlab.rotation, xlab.space, xlab.fontface, xlab.fontfamily, xlab.side, ylab.show, ylab.text, ylab.size, ylab.color, ylab.rotation, ylab.space, ylab.fontface, ylab.fontfamily, ylab.side, panel.type, panel.wrap.pos, panel.xtab.pos, unit, color.sepia_intensity, color.saturation, color_vision_deficiency_sim, text.fontface, text.fontfamily, component.position, component.autoscale, legend.show, legend.design, legend.orientation, legend.position, legend.width, legend.height, legend.stack, legend.group.frame, legend.resize_as_group, legend.reverse, legend.na.show, legend.title.color, legend.title.size, legend.title.fontface, legend.title.fontfamily, legend.xlab.color, legend.xlab.size, legend.xlab.fontface, legend.xlab.fontfamily, legend.ylab.color, legend.ylab.size, legend.ylab.fontface, legend.ylab.fontfamily, legend.text.color, legend.text.size, legend.text.fontface, legend.text.fontfamily, legend.frame, legend.frame.lwd, legend.frame.r, legend.bg.color, legend.bg.alpha, legend.only, legend.settings.standard.portrait, legend.settings.standard.landscape, chart.show, chart.plot.axis.x, chart.plot.axis.y, chart.position, chart.width, chart.height, chart.stack, chart.group.frame, chart.resize_as_group, chart.reverse, chart.na.show, chart.title.color, chart.title.size, chart.title.fontface, chart.title.fontfamily, chart.xlab.color, chart.xlab.size, chart.xlab.fontface, chart.xlab.fontfamily, chart.ylab.color, chart.ylab.size, chart.ylab.fontface, chart.ylab.fontfamily, chart.text.color, chart.text.size, chart.text.fontface, chart.text.fontfamily, chart.frame, chart.frame.lwd, chart.frame.r, chart.bg.color, chart.bg.alpha, chart.object.color, title.show, title.size, title.color, title.fontface, title.fontfamily, title.bg.color, title.bg.alpha, title.padding, title.frame, title.frame.lwd, title.frame.r, title.stack, title.position, title.width, title.group.frame, title.resize_as_group, credits.show, credits.size, credits.color, credits.fontface, credits.fontfamily, credits.bg.color, credits.bg.alpha, credits.padding, credits.frame, credits.frame.lwd, credits.frame.r, credits.stack, credits.position, credits.width, credits.height, credits.group.frame, credits.resize_as_group, compass.north, compass.type, compass.text.size, compass.size, compass.show.labels, compass.cardinal.directions, compass.text.color, compass.color.dark, compass.color.light, compass.lwd, compass.bg.color, compass.bg.alpha, compass.margins, compass.show, compass.stack, compass.position, compass.frame, compass.frame.lwd, compass.frame.r, compass.group.frame, compass.resize_as_group, logo.height, logo.margins, logo.between_margin, logo.show, logo.stack, logo.position, logo.frame, logo.frame.lwd, logo.frame.r, logo.group.frame, logo.resize_as_group, scalebar.show, scalebar.breaks, scalebar.width, scalebar.text.size, scalebar.text.color, scalebar.color.dark, scalebar.color.light, scalebar.lwd, scalebar.bg.color, scalebar.bg.alpha, scalebar.size, scalebar.margins, scalebar.stack, scalebar.position, scalebar.frame, scalebar.frame.lwd, scalebar.frame.r, scalebar.group.frame, scalebar.resize_as_group, grid.show, grid.labels.pos, grid.x, grid.y, grid.n.x, grid.n.y, grid.crs, grid.col, grid.lwd, grid.alpha, grid.labels.show, grid.labels.size, grid.labels.col, grid.labels.rot, grid.labels.format, grid.labels.cardinal, grid.labels.margin.x, grid.labels.margin.y, grid.labels.space.x, grid.labels.space.y, grid.labels.inside_frame, grid.ticks, grid.lines, grid.ndiscr, mouse_coordinates.stack, mouse_coordinates.position, mouse_coordinates.show, minimap.server, minimap.toggle, minimap.stack, minimap.position, minimap.show, panel.show, panel.labels, panel.label.size, panel.label.color, panel.label.fontface, panel.label.fontfamily, panel.label.bg.color, panel.label.frame, panel.label.frame.lwd, panel.label.frame.r, panel.label.height, panel.label.rot, bbox, set_bounds, set_view, set_zoom_limits, qtm.scalebar, qtm.minimap, qtm.mouse_coordinates, earth_boundary, earth_boundary.color, earth_boundary.lwd, earth_datum, space.color, check_and_fix, basemap.show, basemap.server, basemap.alpha, basemap.zoom, tiles.show, tiles.server, tiles.alpha, tiles.zoom, attr.color,
title = NULL,
...

Expand All @@ -26,40 +26,37 @@ tm_layout = function(
#'
#' View mode options. These options are specific to the view mode.
#'
#' @param use.WebGL use webGL for points, lines, and polygons. This is much faster than the standard leaflet layer functions, but the number of visual variables are limited; only fill, size, and color (for lines) are supported. By default `TRUE` if no other visual variables are used.
#' @param use_WebGL use webGL for points, lines, and polygons. This is much faster than the standard leaflet layer functions, but the number of visual variables are limited; only fill, size, and color (for lines) are supported. By default `TRUE` if no other visual variables are used.
#' @param control.position position of the control attribute
#' @param control.bases base layers
#' @param control.overlays overlay layers
#' @param set.bounds logical that determines whether maximum bounds are set,
#' @param set_bounds logical that determines whether maximum bounds are set,
#' or a bounding box. Not applicable in plot mode.
#' In view mode, this is passed on to [setMaxBounds()][leaflet::setMaxBounds()]
#' @param set.view numeric vector that determines the view.
#' @param set_view numeric vector that determines the view.
#' Either a vector of three: `lng`, `lat`, and `zoom`, or a single value:
#' `zoom`. See [setView()][leaflet::setView()].
#' Only applicable if `bbox` is not specified
#' @param set.zoom.limits numeric vector of two that set the minimum and maximum
#' @param set_zoom_limits numeric vector of two that set the minimum and maximum
#' zoom levels (see [tileOptions()][leaflet::tileOptions()]).
#' @param leaflet.options options passed on to
#' [leafletOptions()][leaflet::leafletOptions()]
#' @param view.legend.position deprecated. Use `legend.position`from `tm_layout()` instead.
#' @param ... to catch deprecated arguments
#' @export
tm_view = function(use.WebGL,
tm_view = function(use_WebGL,
control.position,
control.bases,
control.overlays,
set.bounds,
set.view,
set.zoom.limits,
set_bounds,
set_view,
set_zoom_limits,
leaflet.options,
view.legend.position = NULL) {
args = lapply(as.list(rlang::call_match()[-1]), eval, envir = parent.frame())

if (!is.null(view.legend.position)) {
args$legend.position = view.legend.position
args$view.legend.position = NULL
}
...) {

args = lapply(as.list(rlang::call_match(dots_expand = TRUE)[-1]), eval, envir = parent.frame())
args$called_from = "tm_view"
do.call(tm_options, args)

}

#' Plot mode options
Expand Down
Loading

0 comments on commit 243c0c0

Please sign in to comment.