From 8d09935252ea27cf3165718028552dc4b1bba93e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Grelot?= <frederic.grelot@irstea.fr> Date: Wed, 26 Jul 2023 16:56:14 +0200 Subject: [PATCH] =?UTF-8?q?Pr=C3=A9paration=20de=20la=20version=201.0.29.0?= =?UTF-8?q?=20de=20so.ii?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dev/tag-message | 12 ++++++++---- so.ii/R/add_bar.R | 26 +++++++++++++------------- so.ii/R/map_so_ii.R | 13 +++++++------ so.ii/man/add_bar.Rd | 14 +++++++------- so.ii/man/map_so_ii.Rd | 3 ++- 5 files changed, 37 insertions(+), 31 deletions(-) diff --git a/dev/tag-message b/dev/tag-message index a05446c..88fecd1 100644 --- a/dev/tag-message +++ b/dev/tag-message @@ -1,13 +1,17 @@ -so.ii Version: 1.0.28.0 +so.ii Version: 1.0.29.0 0 errors ✔ | 0 warnings ✔ | 0 notes ✔ **Note de version** - * ajout de add_bar + * MAJ de map_so_ii + * MAJ de add_bar **Détails** - * add_bar permet d'ajouter une barre d'échelle à des cartes. + * map_so_ii ajustement de l'appel de add_bar pour permettre de définir + directement depuis l'appel les paramètres de add_bar + * add_bar: changement des noms des paramètres pour plus de clarté dans appel + dans map_so_ii -# git tag -a v1.0.28.0 -F dev/tag-message +# git tag -a v1.0.29.0 -F dev/tag-message # git push --tags diff --git a/so.ii/R/add_bar.R b/so.ii/R/add_bar.R index 2fdcfc8..5f94c95 100644 --- a/so.ii/R/add_bar.R +++ b/so.ii/R/add_bar.R @@ -3,11 +3,11 @@ #' @details #' Correct some things in sbar from terra to add scale bar to plots. #' -#' @param d integer, size of the bar in km. -#' @param xy either a character or a vector giving the position of the bar in +#' @param bar_d integer, size of the bar in km. +#' @param bar_xy either a character or a vector giving the position of the bar in #' the plot. -#' @param adj numeric of length 2, adjustment for text placement. -#' @param lon numeric of length 1, may be adjusted for some plots with +#' @param bar_adj numeric of length 2, adjustment for text placement. +#' @param bar_lon numeric of length 1, may be adjusted for some plots with #' trial-and-error strategy. #' #' @return NULL. @@ -22,25 +22,25 @@ #' \dontrun{ #' library(sf) #' plot(so_ii_collectivity[0]) -#' add_bar(d = 10, xy = c(3.55, 43.47), adj = c(0.5, -1)) +#' add_bar(bar_d = 10, bar_xy = c(3.55, 43.47), bar_adj = c(0.5, -1)) #' } - add_bar = function( - d = NULL, - xy = NULL, - adj = NULL, - lon = 0.4788987 + bar_d = NULL, + bar_xy = NULL, + bar_adj = NULL, + bar_lon = 0.4788987 ) { - d = adjust_terra_scale(d) - xy = calculate_terra_xy(xy) + d = adjust_terra_scale(bar_d) + xy = calculate_terra_xy(bar_xy) + adj = bar_adj if (is.null(adj)) { # Magical adjustment when scope vary to have text readable # 0.4788987 should correspond to longitude range for so.ii scope adj = diff(graphics::par()$usr[3:4]) adj = c( 0.5, - -1 * exp(lon / adj - 1)^.024 + -1 * exp(bar_lon / adj - 1)^.024 ) } diff --git a/so.ii/R/map_so_ii.R b/so.ii/R/map_so_ii.R index 4e5783b..303e127 100644 --- a/so.ii/R/map_so_ii.R +++ b/so.ii/R/map_so_ii.R @@ -120,7 +120,8 @@ #' device is chosen depending on extension. See details. #' @param add logical, should the plot be added to an existing one. Default to #' FALSE. -#' @param ... some parameters that will be used by plot (from sf) +#' @param ... some parameters that will be used by plot (from sf) or by +#' add_bar (so.ii). #' #' @return Nothing useful. #' @@ -291,13 +292,13 @@ map_so_ii = function( if (identical(scope, so.ii::so_ii_limit)) { # Parameters fitted for so_ii scope add_bar( - d = 10, - xy = c(3.55, 43.47), - adj = c(0.5, -1), - lon = 0.4788987 + bar_d = 10, + bar_xy = c(3.55, 43.47), + bar_adj = c(0.5, -1), + bar_lon = 0.4788987 ) } else { - add_bar() + add_bar(...) } } diff --git a/so.ii/man/add_bar.Rd b/so.ii/man/add_bar.Rd index d8abd09..6762b08 100644 --- a/so.ii/man/add_bar.Rd +++ b/so.ii/man/add_bar.Rd @@ -1,21 +1,21 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/adjust_terra_scale.R +% Please edit documentation in R/add_bar.R \encoding{UTF-8} \name{add_bar} \alias{add_bar} \title{Add a bar to a map} \usage{ -add_bar(d = NULL, xy = NULL, adj = NULL, lon = 0.4788987) +add_bar(bar_d = NULL, bar_xy = NULL, bar_adj = NULL, bar_lon = 0.4788987) } \arguments{ -\item{d}{integer, size of the bar in km.} +\item{bar_d}{integer, size of the bar in km.} -\item{xy}{either a character or a vector giving the position of the bar in +\item{bar_xy}{either a character or a vector giving the position of the bar in the plot.} -\item{adj}{numeric of length 2, adjustment for text placement.} +\item{bar_adj}{numeric of length 2, adjustment for text placement.} -\item{lon}{numeric of length 1, may be adjusted for some plots with +\item{bar_lon}{numeric of length 1, may be adjusted for some plots with trial-and-error strategy.} } \value{ @@ -32,7 +32,7 @@ Correct some things in sbar from terra to add scale bar to plots. \dontrun{ library(sf) plot(so_ii_collectivity[0]) -add_bar(d = 10, xy = c(3.55, 43.47), adj = c(0.5, -1)) +add_bar(bar_d = 10, bar_xy = c(3.55, 43.47), bar_adj = c(0.5, -1)) } } \author{ diff --git a/so.ii/man/map_so_ii.Rd b/so.ii/man/map_so_ii.Rd index 3db0d77..9b3a992 100644 --- a/so.ii/man/map_so_ii.Rd +++ b/so.ii/man/map_so_ii.Rd @@ -50,7 +50,8 @@ device is chosen depending on extension. See details.} \item{add}{logical, should the plot be added to an existing one. Default to FALSE.} -\item{...}{some parameters that will be used by plot (from sf)} +\item{...}{some parameters that will be used by plot (from sf) or by +add_bar (so.ii).} } \value{ Nothing useful. -- GitLab