Skip to content

Commit

Permalink
added internal exports
Browse files Browse the repository at this point in the history
  • Loading branch information
mtennekes committed Jun 14, 2024
1 parent fd83478 commit 2d6d261
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 8 deletions.
12 changes: 12 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ export(tm_compass)
export(tm_const)
export(tm_credits)
export(tm_dots)
export(tm_element)
export(tm_element_list)
export(tm_extra_innner_margin)
export(tm_facets)
export(tm_facets_flip)
Expand Down Expand Up @@ -205,6 +207,7 @@ export(tm_scale_asis)
export(tm_scale_bar)
export(tm_scale_bivariate)
export(tm_scale_categorical)
export(tm_scale_composition)
export(tm_scale_continuous)
export(tm_scale_continuous_log)
export(tm_scale_continuous_log10)
Expand Down Expand Up @@ -235,12 +238,21 @@ export(tm_ylab)
export(tmapAddLayerOptions)
export(tmapGetShapeMeta1)
export(tmapGetShapeMeta2)
export(tmapGpar)
export(tmapMode)
export(tmapOutput)
export(tmapProxy)
export(tmapScale)
export(tmapShape)
export(tmapSplitShp)
export(tmapSubsetShp)
export(tmapTpar)
export(tmapTransCartogram)
export(tmapTransCentroid)
export(tmapTransLines)
export(tmapTransPolygons)
export(tmapTransRaster)
export(tmapUsrCls)
export(tmap_animation)
export(tmap_arrange)
export(tmap_design_mode)
Expand Down
14 changes: 14 additions & 0 deletions R/tm_element.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
#' Internal methods for tmap extensions
#'
#' Internal methods for tmap extensions
#'
#' @param ... arguments
#' @param subclass subclass
#' @export
#' @name tm_element
#' @rdname tmap_internal
#' @keywords internal
tm_element = function(..., subclass = NULL) {
structure(list(...), class = c(subclass, "tm_element", "list"))
}

#' @export
#' @name tm_element_list
#' @rdname tmap_internal
#' @keywords internal
tm_element_list = function(...) {
structure(list(...), class = "tmap")
}
Expand Down
10 changes: 10 additions & 0 deletions R/tmapGpar.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
#' @param fill,col,shape,size,fill_alpha,col_alpha,lty,lwd,linejoin,lineend visual variables
#' @param ... args
#' @export
#' @name tmapGpar
#' @rdname tmap_internal
#' @keywords internal
tmapGpar = function(fill = NULL,
col = NULL,
shape = NULL,
Expand All @@ -14,6 +20,10 @@ tmapGpar = function(fill = NULL,
structure(args, class = "tmapGpar")
}

#' @export
#' @name tmapTpar
#' @rdname tmap_internal
#' @keywords internal
tmapTpar = function(...) {
args = c(as.list(environment()), list(...))
structure(args, class = "tmapTpar")
Expand Down
15 changes: 15 additions & 0 deletions R/tmapScale_.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ tmapVars = function(x) {
structure(x, class = cls)
}

#' @param x x
#' @export
#' @name tmapUsrCls
#' @rdname tmap_internal
#' @keywords internal
tmapUsrCls = function(x) {
structure(x, class = "tmapUsrCls")
}
Expand Down Expand Up @@ -155,6 +160,16 @@ data_class = function(x, check_for_color_class = FALSE) {
}


#' @param aes aes
#' @param value value
#' @param scale scale
#' @param legend legend
#' @param chart chart
#' @param free free
#' @export
#' @name tmapScale
#' @rdname tmap_internal
#' @keywords internal
tmapScale = function(aes, value, scale, legend, chart, free) {
structure(list(aes = aes, value = tmapVars(value), scale = scale, legend = legend, chart = chart, free = free), class = c("tmapScale", "list"))
}
Expand Down
42 changes: 34 additions & 8 deletions R/tmapTrans.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,16 @@ get_midpoint_angle = function(shp) {
list(shp = sf::st_geometry(pShp), angles = angles)
}

# args:
# - points.only: "yes", "no", "ifany"
#
# prop_ vectors, e.g. prop_angle can be added to shpTM. These are later put into dt (and used in step 4 (plotting))
#' @param shpTM shpTM
#' @param xmod,ymod xmod and ymod
#' @param ord__ ord
#' @param plot.order plot.order
#' @param args args
#' @param scale scale
#' @export
#' @name tmapTransCentroid
#' @rdname tmap_internal
#' @keywords internal
tmapTransCentroid = function(shpTM, xmod = NULL, ymod = NULL, ord__, plot.order, args, scale) {
within(shpTM, {
is_stars = inherits(shp, "dimensions")
Expand Down Expand Up @@ -131,16 +137,26 @@ tmapTransCentroid = function(shpTM, xmod = NULL, ymod = NULL, ord__, plot.order,
}
})
}
# args:
# - points.only: "yes", "no", "ifany"
#
# prop_ vectors, e.g. prop_angle can be added to shpTM. These are later put into dt (and used in step 4 (plotting))


#' @export
#' @name tmapTransRaster
#' @rdname tmap_internal
#' @keywords internal
tmapTransRaster = function(shpTM, ord__, plot.order, args) {
if (!inherits(shpTM$shp, "dimensions")) stop("Stars object (of class dimensions) expected for tm_raster", call. = FALSE)
shpTM
}


# args:
# - polygons.only: "yes", "no", "ifany"
#' @export
#' @name tmapTransPolygons
#' @rdname tmap_internal
#' @keywords internal
tmapTransPolygons = function(shpTM, ord__, plot.order, args, scale) {
within(shpTM, {
is_stars = inherits(shp, "dimensions")
Expand Down Expand Up @@ -189,9 +205,13 @@ tmapTransPolygons = function(shpTM, ord__, plot.order, args, scale) {
}
})
}

# args:
# - lines.only: "yes", "no", "ifany"
# - polygons.only: "yes", "no", "ifany"

#' @export
#' @name tmapTransLines
#' @rdname tmap_internal
#' @keywords internal
tmapTransLines = function(shpTM, ord__, plot.order, args, scale) {
within(shpTM, {
is_stars = inherits(shp, "dimensions")
Expand Down Expand Up @@ -237,7 +257,13 @@ tmapTransLines = function(shpTM, ord__, plot.order, args, scale) {
}
})
}
# args:
# - lines.only: "yes", "no", "ifany"

#' @export
#' @name tmapTransCartogram
#' @rdname tmap_internal
#' @keywords internal
tmapTransCartogram = function(shpTM, size, ord__, plot.order, args, scale) {
s = shpTM$shp

Expand Down

0 comments on commit 2d6d261

Please sign in to comment.