Skip to content

Commit

Permalink
fixed #957, working on #950
Browse files Browse the repository at this point in the history
  • Loading branch information
mtennekes committed Nov 7, 2024
1 parent 6ccd06d commit 4b754be
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
1 change: 1 addition & 0 deletions R/step1_rearrange.R
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ get_main_ids = function(tmo) {


get_crs = function(tms, is_auto) {
if (is.na(sf::st_crs(tms$shp))) return(sf::st_crs(NA))
if (is.null(tms$crs)) {
crs = sf::st_crs(tms$shp)
is_ll = sf::st_is_longlat(crs)
Expand Down
8 changes: 5 additions & 3 deletions R/tm_shape.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,19 @@ tm_shape = function(shp,
unit = NULL,
filter = NULL,
...) {
args = as.list(match.call(expand.dots = TRUE)[-1])

args_called = names(rlang::call_match()[-1])
args = lapply(as.list(rlang::call_match(defaults = TRUE)[-1]), eval, envir = parent.frame())

if ("projection" %in% names(args)) {
v3_instead_message(arg_old = "projection", arg_new = "crs", fun = "tm_shape")
crs = args$projection
}

bbox_list = c(list(x = bbox), args[intersect(names(args), c("ext", "cx", "cy", "width", "height", "xlim", "ylim", "relative", "asp.limit"))])
bbox_list = c(list(x = bbox), args[intersect(args_called, c("ext", "cx", "cy", "width", "height", "xlim", "ylim", "relative", "asp.limit"))])

if (missing(shp)) {
do.call(tm_options, args[intersect(names(args), c("bbox", "crs", "set.bounds", "set.view", "set.zoom.limits"))])
do.call(tm_options, args[intersect(args_called, c("bbox", "crs", "set.bounds", "set.view", "set.zoom.limits"))])
} else {
tm_element_list(tm_element(shp = shp,
is.main = is.main,
Expand Down
13 changes: 11 additions & 2 deletions R/tmapLeaflet_layers.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impute_webgl = function(use.WebGL, dt, supported, checkif = NULL) {

if (!is.null(checkif)) {
checks = vapply(seq_along(checkif), function(i) {
dt[[names(checkif)[i]]][1] == checkif[[i]]
dt[[names(checkif)[i]]][1] %in% checkif[[i]]
}, FUN.VALUE = logical(1))
} else {
checks = TRUE
Expand All @@ -49,6 +49,15 @@ impute_webgl = function(use.WebGL, dt, supported, checkif = NULL) {
if (is.character(x)) paste0("\"", x, "\"") else x
})

checkif = lapply(checkif, function(x) {
if (length(x) == 1) {
x
} else {
k = length(x)
paste(paste(head(x, -1), collapse = ", "), tail(x, 1), sep = " or ")
}
})

warning("WegGL enabled, but the following visual variable only accept one value ", paste(paste(names(checkif)[!checks], checkif[!checks], sep = " = "), collapse = ", "), ". Set use.WebGL to FALSE to support them.", call. = FALSE)
}
} else {
Expand Down Expand Up @@ -255,7 +264,7 @@ tmapLeafletSymbols = function(shpTM, dt, pdt, popup.format, hdt, idt, gp, bbx, f

#po(sort(gp2$width, decreasing = T))

o$use.WebGL = impute_webgl(o$use.WebGL, dt, supported = c("fill", "size"), checkif = list(shape = 21))
o$use.WebGL = impute_webgl(o$use.WebGL, dt, supported = c("fill", "size"), checkif = list(shape = c(1,16,19,20,21)))


if (o$use.WebGL) {
Expand Down

0 comments on commit 4b754be

Please sign in to comment.