Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mtennekes committed Dec 18, 2024
1 parent 00ecab7 commit 900f33d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
20 changes: 20 additions & 0 deletions R/step1_rearrange.R
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,26 @@ get_class = function(tms) {
class(tms$shp)
}

str2pos = function(x) {
if (length(x) == 1L) {
if (tolower(x) %in% c("left", "right")) {
args = list(pos.h = x)
} else if (tolower(x) %in% c("top", "bottom")) {
args = list(pos.v = x)
} else if (tolower(x) %in% c("center", "centre")) {
args = list(pos.h = "center", pos.v = "center")
} else {
stop("position: incorrect specification")
}
}
do.call(tm_pos_in, args)
}

num2pos = function(x) {
if (length(x) == 1L) stop("position: please provide two values: the horizontal and the vertical")
tm_pos_in(x[1], x[2])
}

process_position = function(position, o) {
if (is.null(position)) return(NULL)

Expand Down
6 changes: 0 additions & 6 deletions R/tm_pos.R
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,4 @@ tm_pos_auto_in = function(align.h, align.v, just.h, just.v) {
structure(args, class = "tm_pos")
}

str2pos = function(x) {
tm_pos_in(x[1], x[2])
}

num2pos = function(x) {
tm_pos_in(x[1], x[2])
}
8 changes: 6 additions & 2 deletions R/tmapGridComp.R
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,9 @@ tmapGridComp = function(comp, o, facet_row = NULL, facet_col = NULL, facet_page,
n = length(comp)
# rows and cols in main grid
rows = if (facet_row[1] == -2) g$meta_rows[1] else if (facet_row[1] == -1) g$meta_rows[2] else {
panel_rows = if (o$panel.type == "xtab") {
panel_rows = if (class == "in") {
NULL
} else if (o$panel.type == "xtab") {
c(g$cols_panel_row_id, g$rows_panel_row_ids)
} else if (o$panel.type == "wrap") {
g$rows_panel_ids[facet_row]
Expand All @@ -248,7 +250,9 @@ tmapGridComp = function(comp, o, facet_row = NULL, facet_col = NULL, facet_page,
c(g$rows_facet_ids[facet_row], panel_rows)
}
cols = if (facet_col[1] == -2) g$meta_cols[1] else if (facet_col[1] == -1) g$meta_cols[2] else {
panel_cols = if (o$panel.type == "xtab") {
panel_cols = if (class == "in") {
NULL
} else if (o$panel.type == "xtab") {
c(g$cols_panel_col_ids, g$rows_panel_col_id)
} else if (o$panel.type == "wrap") {
g$cols_panel_ids[facet_col]
Expand Down

0 comments on commit 900f33d

Please sign in to comment.