Commit 6e3ee764 authored by Grelot Frederic's avatar Grelot Frederic :swimmer_tone5:
Browse files

Ajout de la fonctionnalité add à map_so_ii

Showing with 119 additions and 34 deletions
+119 -34
...@@ -8,11 +8,15 @@ devtools::build_vignettes(package) ...@@ -8,11 +8,15 @@ devtools::build_vignettes(package)
# devtools::run_examples(package) # devtools::run_examples(package)
### Checks ### Checks
# system("rm so.ii/data-raw/data-common") if (FALSE) {
# system("mv ~/.Rprofile ~/.Rprofile-temp") {
# devtools::check(package) system("rm so.ii/data-raw/data-common")
# system("mv ~/.Rprofile-temp ~/.Rprofile") system("mv ~/.Rprofile ~/.Rprofile-temp")
# system("cp -r data-common so.ii/data-raw") devtools::check(package)
system("mv ~/.Rprofile-temp ~/.Rprofile")
system("cp -r data-common so.ii/data-raw")
}
}
### Build ### Build
devtools::build(package, path = "library", vignettes = TRUE) devtools::build(package, path = "library", vignettes = TRUE)
......
so.ii Version: 1.0.20.0 so.ii Version: 1.0.21.0
0 errors ✔ | 0 warnings ✔ | 0 notes ✔ 0 errors ✔ | 0 warnings ✔ | 0 notes ✔
**Note de version** **Note de version**
* ajout de so_ii_clc_crop * ajout des options add, limit à map_so_ii
* ajout des sous-options "crop" & "poth" pour le theme "clc" de map_so_ii
**Détails** **Détails**
* so_ii_clc_crop est une version croppée de CLC sur une bouding box autour * l'option limit (logical) de map_so_ii permet de gérer le fait que la
de so_ii_limit qui permet de donner des informations autour de ce périmètre. limite du paramètre est effectivement affichée :
La mer a été ajoutée. * si l'option est à TRUE (défaut), le périmètre est affiché une fois que
* map_so_ii permet la possibilité de choisir l'affichage pour le theme le thème ou le dataset le sont (mais plus avant). Donc si aucun theme ni
"clc" via l'option "detail" : dataset n'est donné, rien n'est affiché !
- "so.ii" (valeur par défaut) donne le même résultat que précédemment, * si l'option est à FALSE, le périmètre n'est jamais affiché.
seul les informations à l'intérieur de so_ii_limit sont affichées * l'option add (logical) permet d'utiliser map_so_ii pour ajouter des
- "crop" donne les informations dans le bounding box entier informations à un carte existante :
- "borth" donnes les informations dans le bouding box en mettant en * si l'option est à TRUE, les informations sont ajoutées. L'option "bar"
exergue celles à l'intérieur du périmètre. est mise à FALSE. Si l'option "path" donne un chemin de fichier, une
sauvegarde de la carte en cours de création est crée en utilisant
dev.copy juste avant de sortir de la fonction.
* si l'option est à FALSE, le comportement ne change pas avec ce qui
était précédemment donné.
# git tag -a v1.0.20.0 -F dev/tag-message # git tag -a v1.0.21.0 -F dev/tag-message
# git push --tags # git push --tags
Package: so.ii Package: so.ii
Title: Utilities very useful to share within so_ii team Title: Utilities very useful to share within so_ii team
Version: 1.0.20.0 Version: 1.0.21.0
Authors@R: Authors@R:
c( c(
person(given = "Frédéric", person(given = "Frédéric",
......
...@@ -99,9 +99,13 @@ ...@@ -99,9 +99,13 @@
#' @param detail character, detail for theme, depends on theme. See details. #' @param detail character, detail for theme, depends on theme. See details.
#' @param year character, the year chosen for some themes. See details. #' @param year character, the year chosen for some themes. See details.
#' @param bar logical, should a bar be plotted for the dataset. See details. #' @param bar logical, should a bar be plotted for the dataset. See details.
#' @param inset charecter, managing if an inset is plotted. #' @param limit logical, should the limit of so.ii be plotted for the dataset.
#' Default to TRUE.
#' @param inset character, managing if an inset is plotted.
#' @param path character, the name of the file to save the plot. Graphical #' @param path character, the name of the file to save the plot. Graphical
#' device is chosen depending on extension. See details. #' 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)
#' #'
#' @return Nothing useful. #' @return Nothing useful.
...@@ -126,8 +130,10 @@ map_so_ii = function( ...@@ -126,8 +130,10 @@ map_so_ii = function(
detail, detail,
year, year,
bar = TRUE, bar = TRUE,
limit = TRUE,
inset = NULL, inset = NULL,
path = NULL, path = NULL,
add = FALSE,
... ...
) { ) {
theme = match.arg(theme) theme = match.arg(theme)
...@@ -135,20 +141,82 @@ map_so_ii = function( ...@@ -135,20 +141,82 @@ map_so_ii = function(
if (!is.null(path)) { if (!is.null(path)) {
width = 18 width = 18
height = 18 height = 18
switch( if (add != TRUE) {
EXPR = tolower(tools::file_ext(path)), switch(
"pdf" = grDevices::cairo_pdf(path, width = width / 2.54, height = height / 2.54), EXPR = tolower(tools::file_ext(path)),
"png" = grDevices::png(path, width = width, height = height, units = "cm", res = 144), "pdf" = grDevices::cairo_pdf(
"jpg" = grDevices::jpeg(path, width = width, height = height, units = "cm", res = 144), filename = path,
"svg" = grDevices::svg(path, width = width / 2.54, height = height / 2.54), width = width / 2.54,
stop(sprintf("%s not recognized", tolower(tools::file_ext(path)))) height = height / 2.54
) ),
on.exit(grDevices::dev.off()) "png" = grDevices::png(
filename = path,
width = width,
height = height,
units = "cm",
res = 144
),
"jpg" = grDevices::jpeg(
filename = path,
width = width,
height = height,
units = "cm",
res = 144
),
"svg" = grDevices::svg(
filename = path,
width = width / 2.54,
height = height / 2.54
),
stop(sprintf("%s not recognized", tolower(tools::file_ext(path))))
)
on.exit(grDevices::dev.off())
} else {
on.exit(
switch(
EXPR = tolower(tools::file_ext(path)),
"pdf" = grDevices::dev.copy(
grDevices::cairo_pdf,
filename = path,
width = width / 2.54,
height = height / 2.54
),
"png" = grDevices::dev.copy(
grDevices::png,
filename = path,
width = width,
height = height,
units = "cm",
res = 144
),
"jpg" = grDevices::dev.copy(
grDevices::jpeg,
filename = path,
width = width,
height = height,
units = "cm",
res = 144
),
"svg" = grDevices::dev.copy(
grDevices::svg,
filename = path,
width = width / 2.54,
height = height / 2.54
),
stop(sprintf("%s not recognized", tolower(tools::file_ext(path))))
)
)
on.exit(grDevices::dev.off(), add = TRUE, after = TRUE)
}
} }
## Init map ## Init map
graphics::par(mai = c(.65, .60, .50, .15)) if (add != TRUE) {
plot(so.ii::so_ii_limit, axes = TRUE, main = list(...)[["main"]], cex.main = 2.5) graphics::par(mai = c(.65, .60, .50, .15))
plot(so.ii::so_ii_limit, border = NA, axes = TRUE, main = list(...)[["main"]], cex.main = 2.5)
} else {
bar = FALSE
}
## Plot theme if any, return theme_legend ## Plot theme if any, return theme_legend
theme_legend = switch( theme_legend = switch(
...@@ -168,7 +236,9 @@ map_so_ii = function( ...@@ -168,7 +236,9 @@ map_so_ii = function(
if (!missing(dataset)) plot(dataset[["geometry"]], add = TRUE, ...) if (!missing(dataset)) plot(dataset[["geometry"]], add = TRUE, ...)
## Make so_ii_limit visible ## Make so_ii_limit visible
plot(so.ii::so_ii_limit, lwd = 2, add = TRUE) if (limit == TRUE) {
plot(so.ii::so_ii_limit, lwd = 2, add = TRUE)
}
## Plot bar ## Plot bar
if (bar == TRUE) { if (bar == TRUE) {
......
...@@ -14,8 +14,10 @@ map_so_ii( ...@@ -14,8 +14,10 @@ map_so_ii(
detail, detail,
year, year,
bar = TRUE, bar = TRUE,
limit = TRUE,
inset = NULL, inset = NULL,
path = NULL, path = NULL,
add = FALSE,
... ...
) )
} }
...@@ -34,11 +36,17 @@ map_so_ii( ...@@ -34,11 +36,17 @@ map_so_ii(
\item{bar}{logical, should a bar be plotted for the dataset. See details.} \item{bar}{logical, should a bar be plotted for the dataset. See details.}
\item{inset}{charecter, managing if an inset is plotted.} \item{limit}{logical, should the limit of so.ii be plotted for the dataset.
Default to TRUE.}
\item{inset}{character, managing if an inset is plotted.}
\item{path}{character, the name of the file to save the plot. Graphical \item{path}{character, the name of the file to save the plot. Graphical
device is chosen depending on extension. See details.} 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)}
} }
\value{ \value{
......
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