Skip to content

Commit

Permalink
fix: revert "remove export and theme args from mf_init() and mf_expor…
Browse files Browse the repository at this point in the history
…t()"

This reverts commit 2454035.
  • Loading branch information
rCarto committed Apr 26, 2024
1 parent 17a3057 commit b05f7e8
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 9 deletions.
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
7 changes: 7 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
22 changes: 21 additions & 1 deletion R/mf_export.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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(
Expand Down
15 changes: 13 additions & 2 deletions R/mf_init.R
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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")) {
Expand Down
4 changes: 2 additions & 2 deletions codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -239,5 +239,5 @@
},
"SystemRequirements": null
},
"fileSize": "3252.531KB"
"fileSize": "3253.942KB"
}
7 changes: 7 additions & 0 deletions inst/tinytest/test_export.R
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
1 change: 1 addition & 0 deletions inst/tinytest/test_init.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
8 changes: 7 additions & 1 deletion man/mf_export.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion man/mf_init.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b05f7e8

Please sign in to comment.