diff --git a/dev/package.development.R b/dev/package.development.R index 5d5b08f227f35d2162d6b8ae9e353c100dd0683c..3043176bab4d6c449e4ce6f99ba78cd28c822626 100644 --- a/dev/package.development.R +++ b/dev/package.development.R @@ -8,11 +8,15 @@ devtools::build_vignettes(package) # devtools::run_examples(package) ### Checks -# system("rm so.ii/data-raw/data-common") -# system("mv ~/.Rprofile ~/.Rprofile-temp") -# devtools::check(package) -# system("mv ~/.Rprofile-temp ~/.Rprofile") -# system("cp -r data-common so.ii/data-raw") +if (FALSE) { + { + system("rm so.ii/data-raw/data-common") + system("mv ~/.Rprofile ~/.Rprofile-temp") + devtools::check(package) + system("mv ~/.Rprofile-temp ~/.Rprofile") + system("cp -r data-common so.ii/data-raw") + } +} ### Build devtools::build(package, path = "library", vignettes = TRUE) diff --git a/dev/tag-message b/dev/tag-message index 6cd1ee2ba703e6e542e90f5c5ba801e9ac9c5ba8..0947018d717d5020429a8b1f1c48080963c6365e 100644 --- a/dev/tag-message +++ b/dev/tag-message @@ -1,22 +1,25 @@ -so.ii Version: 1.0.20.0 +so.ii Version: 1.0.21.0 0 errors ✔ | 0 warnings ✔ | 0 notes ✔ **Note de version** - * ajout de so_ii_clc_crop - * ajout des sous-options "crop" & "poth" pour le theme "clc" de map_so_ii + * ajout des options add, limit à map_so_ii **Détails** - * so_ii_clc_crop est une version croppée de CLC sur une bouding box autour - de so_ii_limit qui permet de donner des informations autour de ce périmètre. - La mer a été ajoutée. - * map_so_ii permet la possibilité de choisir l'affichage pour le theme - "clc" via l'option "detail" : - - "so.ii" (valeur par défaut) donne le même résultat que précédemment, - seul les informations à l'intérieur de so_ii_limit sont affichées - - "crop" donne les informations dans le bounding box entier - - "borth" donnes les informations dans le bouding box en mettant en - exergue celles à l'intérieur du périmètre. + * l'option limit (logical) de map_so_ii permet de gérer le fait que la + limite du paramètre est effectivement affichée : + * si l'option est à TRUE (défaut), le périmètre est affiché une fois que + le thème ou le dataset le sont (mais plus avant). Donc si aucun theme ni + dataset n'est donné, rien n'est affiché ! + * si l'option est à FALSE, le périmètre n'est jamais affiché. + * l'option add (logical) permet d'utiliser map_so_ii pour ajouter des + informations à un carte existante : + * si l'option est à TRUE, les informations sont ajoutées. L'option "bar" + 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 diff --git a/so.ii/DESCRIPTION b/so.ii/DESCRIPTION index ff87870bc2a948da1cf84fe942bf3f2357d94a63..27af69c5f137b7c9c166d0e8b037cdbd4f32c0bf 100644 --- a/so.ii/DESCRIPTION +++ b/so.ii/DESCRIPTION @@ -1,6 +1,6 @@ Package: so.ii Title: Utilities very useful to share within so_ii team -Version: 1.0.20.0 +Version: 1.0.21.0 Authors@R: c( person(given = "Frédéric", diff --git a/so.ii/R/map_so_ii.r b/so.ii/R/map_so_ii.r index f0b28e1e7da4d8e74e6028e4ed37950c52d73027..44f0f76a34f232966d3d64dd04c308be923567cf 100644 --- a/so.ii/R/map_so_ii.r +++ b/so.ii/R/map_so_ii.r @@ -99,9 +99,13 @@ #' @param detail character, detail for theme, depends on theme. 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 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 #' 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) #' #' @return Nothing useful. @@ -126,8 +130,10 @@ map_so_ii = function( detail, year, bar = TRUE, + limit = TRUE, inset = NULL, path = NULL, + add = FALSE, ... ) { theme = match.arg(theme) @@ -135,20 +141,82 @@ map_so_ii = function( if (!is.null(path)) { width = 18 height = 18 - switch( - EXPR = tolower(tools::file_ext(path)), - "pdf" = grDevices::cairo_pdf(path, width = width / 2.54, height = height / 2.54), - "png" = grDevices::png(path, width = width, height = height, units = "cm", res = 144), - "jpg" = grDevices::jpeg(path, width = width, height = height, units = "cm", res = 144), - "svg" = grDevices::svg(path, width = width / 2.54, height = height / 2.54), - stop(sprintf("%s not recognized", tolower(tools::file_ext(path)))) - ) - on.exit(grDevices::dev.off()) + if (add != TRUE) { + switch( + EXPR = tolower(tools::file_ext(path)), + "pdf" = grDevices::cairo_pdf( + filename = path, + width = width / 2.54, + height = height / 2.54 + ), + "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 - graphics::par(mai = c(.65, .60, .50, .15)) - plot(so.ii::so_ii_limit, axes = TRUE, main = list(...)[["main"]], cex.main = 2.5) + if (add != TRUE) { + 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 theme_legend = switch( @@ -168,7 +236,9 @@ map_so_ii = function( if (!missing(dataset)) plot(dataset[["geometry"]], add = TRUE, ...) ## 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 if (bar == TRUE) { diff --git a/so.ii/man/map_so_ii.Rd b/so.ii/man/map_so_ii.Rd index 383fd5ff843741b08200bc734b8aad281890b214..1c6b609fe1f8e6be9c4f6bf335e93929a49fb63f 100644 --- a/so.ii/man/map_so_ii.Rd +++ b/so.ii/man/map_so_ii.Rd @@ -14,8 +14,10 @@ map_so_ii( detail, year, bar = TRUE, + limit = TRUE, inset = NULL, path = NULL, + add = FALSE, ... ) } @@ -34,11 +36,17 @@ map_so_ii( \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 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)} } \value{