diff --git a/CITATION.cff b/CITATION.cff index 6882e12e..901e369e 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -8,7 +8,7 @@ message: 'To cite package "mapsf" in publications use:' type: software license: GPL-3.0-or-later title: 'mapsf: Thematic Cartography' -version: 0.10.0 +version: 0.10.1 abstract: Create and integrate thematic maps in your workflow. This package helps to design various cartographic representations such as proportional symbols, choropleth or typology maps. It also offers several functions to display layout elements that diff --git a/DESCRIPTION b/DESCRIPTION index 648f0d26..80140693 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: mapsf Title: Thematic Cartography -Version: 0.10.0 +Version: 0.10.1 Authors@R: c(person(given = "Timothée", family = "Giraud", diff --git a/NEWS.md b/NEWS.md index aec5acf6..2e4d1f71 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,10 @@ +# mapsf 0.10.1 + +## Fix +- revert previous remove "export" and "theme" args from mf_export() to accommodate dependencies +- revert previous remove "theme" from mf_init() to accommodate dependencies + + # mapsf 0.10.0 ## Fix diff --git a/R/mf_export.R b/R/mf_export.R index aec06415..b5efeca7 100644 --- a/R/mf_export.R +++ b/R/mf_export.R @@ -11,9 +11,11 @@ #' @param x object of class \code{sf}, \code{sfc} or \code{SpatRaster} #' @param expandBB fractional values to expand the bounding box with, in each #' direction (bottom, left, top, right) +#' @param theme apply a theme (deprecated) #' @param filename path to the exported file. If the file extention is ".png" a #' png graphic device is opened, if the file extension is ".svg" a svg graphic #' device is opened. +#' @param export deprecated #' @param width width of the figure (pixels for png, inches for svg) #' @param height height of the figure (pixels for png, inches for svg) #' @param res resolution (for png) @@ -34,7 +36,25 @@ mf_export <- function(x, height, res = 96, ..., - expandBB = rep(0, 4)) { + expandBB = rep(0, 4), + theme, + export = "png") { + # deprecated args mgmt + if (!missing(theme)) { + warning( + paste0( + "'theme' is deprecated.\n", + "In the next version of mapsf the current theme ", + "will be applied to the export." + ), + call. = FALSE + ) + mf_theme(theme) + } + if (!missing(export)) { + message('"export" is deprecated.') + } + # input test if (!inherits(x, c("bbox", "SpatVector", "SpatRaster", "sf", "sfc", "sfg"))) { stop( diff --git a/R/mf_init.R b/R/mf_init.R index 69802bc9..e246e062 100644 --- a/R/mf_init.R +++ b/R/mf_init.R @@ -7,6 +7,7 @@ #' @param x object of class \code{sf}, \code{sfc} or \code{SpatRaster} #' @param expandBB fractional values to expand the bounding box with, in each #' direction (bottom, left, top, right) +#' @param theme apply a theme (deprecated) #' @export #' @importFrom sf st_bbox st_as_sfc st_geometry st_crs<- #' @return No return value, a map is initiated. @@ -15,8 +16,18 @@ #' target <- mtq[30, ] #' mf_init(target) #' mf_map(mtq, add = TRUE) -mf_init <- function(x, expandBB = rep(0, 4)) { - +mf_init <- function(x, expandBB = rep(0, 4), theme) { + if (!missing(theme)) { + warning( + paste0( + "'theme' is deprecated.\n", + "In the next version of mapsf the current theme ", + "will be applied." + ), + call. = FALSE + ) + mf_theme(theme) + } bgmap <- getOption("mapsf.bg") if (inherits(x, "SpatRaster")) { diff --git a/codemeta.json b/codemeta.json index a967e73e..1b681205 100644 --- a/codemeta.json +++ b/codemeta.json @@ -7,7 +7,7 @@ "codeRepository": "https://riatelab.github.io/mapsf/", "issueTracker": "https://github.com/riatelab/mapsf/issues/", "license": "https://spdx.org/licenses/GPL-3.0", - "version": "0.10.0", + "version": "0.10.1", "programmingLanguage": { "@type": "ComputerLanguage", "name": "R", @@ -239,5 +239,5 @@ }, "SystemRequirements": null }, - "fileSize": "3252.531KB" + "fileSize": "3253.942KB" } diff --git a/inst/tinytest/test_export.R b/inst/tinytest/test_export.R index 87033f0f..2881aaab 100644 --- a/inst/tinytest/test_export.R +++ b/inst/tinytest/test_export.R @@ -16,6 +16,9 @@ dev.off() expect_silent(mf_export(mtq, filename = paste0(tempfile(), ".svg"), width = 6, height = 6)) dev.off() +expect_warning(mf_export(mtq, theme = "darkula", + filename = paste0(tempfile(), ".svg"))) +dev.off() expect_silent(mf_export(mtq, filename = paste0(tempfile(), ".svg"))) dev.off() @@ -34,6 +37,10 @@ expect_silent(mf_export(r)) mf_raster(r, add = TRUE) dev.off() +expect_message(mf_export(mtq, height = 600, export = "png", + filename = paste0(tempfile(), ".png"))) +dev.off() + expect_silent(mf_export(st_transform(mtq, "epsg:4326"), filename = paste0(tempfile(), ".png"))) dev.off() diff --git a/inst/tinytest/test_init.R b/inst/tinytest/test_init.R index d26e2372..8362b339 100644 --- a/inst/tinytest/test_init.R +++ b/inst/tinytest/test_init.R @@ -2,6 +2,7 @@ mtq <- mf_get_mtq() expect_silent(mf_init(mtq)) expect_silent(mf_init(mtq, expandBB = c(0, 0, 0, .4))) +expect_warning(mf_init(mtq, theme = "darkula")) b <- terra::rast(system.file("ex/elev.tif", package = "terra")) expect_silent(mf_init(b)) mf_raster(b, add = TRUE) diff --git a/man/mf_export.Rd b/man/mf_export.Rd index e20566f4..79b306ff 100644 --- a/man/mf_export.Rd +++ b/man/mf_export.Rd @@ -11,7 +11,9 @@ mf_export( height, res = 96, ..., - expandBB = rep(0, 4) + expandBB = rep(0, 4), + theme, + export = "png" ) } \arguments{ @@ -31,6 +33,10 @@ device is opened.} \item{expandBB}{fractional values to expand the bounding box with, in each direction (bottom, left, top, right)} + +\item{theme}{apply a theme (deprecated)} + +\item{export}{deprecated} } \value{ No return value, a map file is initiated (in PNG or SVG format). diff --git a/man/mf_init.Rd b/man/mf_init.Rd index 8f1f9d28..a3cee195 100644 --- a/man/mf_init.Rd +++ b/man/mf_init.Rd @@ -4,13 +4,15 @@ \alias{mf_init} \title{Initialize a map with a specific extent} \usage{ -mf_init(x, expandBB = rep(0, 4)) +mf_init(x, expandBB = rep(0, 4), theme) } \arguments{ \item{x}{object of class \code{sf}, \code{sfc} or \code{SpatRaster}} \item{expandBB}{fractional values to expand the bounding box with, in each direction (bottom, left, top, right)} + +\item{theme}{apply a theme (deprecated)} } \value{ No return value, a map is initiated.