Commit 8d099352 authored by Grelot Frederic's avatar Grelot Frederic :swimmer_tone5:
Browse files

Préparation de la version 1.0.29.0 de so.ii

No related merge requests found
Showing with 37 additions and 31 deletions
+37 -31
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
......@@ -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
)
}
......
......@@ -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(...)
}
}
......
% 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{
......
......@@ -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.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment