diff --git a/dev/tag-message b/dev/tag-message index 3a6fee2b4e2f70343948a0235fea32b931e8a42b..da25973d44ef238d8cb97f5c6f276532d4dea28d 100644 --- a/dev/tag-message +++ b/dev/tag-message @@ -1,17 +1,16 @@ -so.ii Version: 1.0.23.0 +so.ii Version: 1.0.24.0 0 errors ✔ | 0 warnings ✔ | 0 notes ✔ **Note de version** - * ajout de la fonction kable - * ajout de la fonction linesep + * modification de map_so_ii **Détails** - * kable masque knitr::kable en ajoutant des options très souvent utilisées - dans l'équipe (rapport ou présentation). - * linesep permet de créer facilement des vecteurs pour ajouter des - séparation avec l'option (non documentée) linesep de kable. + * map_so_ii charge dorénavant sf si besoin, modifie le parmètre sf_use_s2 à + FALSE (de façon momentanée). Il gère aussi le format de dataset. Il cherche + à le transformer en objet de classe sfc, s'il n'y arrive pas il renvoie un + warning et n'affiche pas dataset. -# git tag -a v1.0.23.0 -F dev/tag-message +# git tag -a v1.0.24.0 -F dev/tag-message # git push --tags diff --git a/so.ii/.Rbuildignore b/so.ii/.Rbuildignore index e829056f3500fd5448759fffa24480bacbeb6c6d..2c5b50b35c1c74405739e14963853cd6c87e1dca 100644 --- a/so.ii/.Rbuildignore +++ b/so.ii/.Rbuildignore @@ -1,4 +1,6 @@ +^data-common$ ^data-raw$ +^data-raw/data-common$$ ^dev$ ^doc$ ^Meta$ diff --git a/so.ii/DESCRIPTION b/so.ii/DESCRIPTION index bd222632a40e724316716e302466b116cd4e6e10..aee78c71fea435e827a7eb0647ac9de37b9a896f 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.23.0 +Version: 1.0.24.0 Authors@R: c( person(given = "Frédéric", @@ -23,6 +23,7 @@ LazyData: true Imports: kableExtra, knitr, + methods, readODS, rio, scales, diff --git a/so.ii/R/map_so_ii.r b/so.ii/R/map_so_ii.r index 43bb68552845c81c5b4002d5d26f21791df475b0..656fc2fbea90b00f1422a390dda132650c9fe54d 100644 --- a/so.ii/R/map_so_ii.r +++ b/so.ii/R/map_so_ii.r @@ -151,6 +151,10 @@ map_so_ii = function( add = FALSE, ... ) { + requireNamespace("sf") + osf = suppressMessages(sf::sf_use_s2(FALSE)) + on.exit(suppressMessages(sf::sf_use_s2(osf))) + theme = match.arg(theme) if (!is.null(path)) { @@ -185,7 +189,7 @@ map_so_ii = function( ), stop(sprintf("%s not recognized", tolower(tools::file_ext(path)))) ) - on.exit(grDevices::dev.off()) + on.exit(grDevices::dev.off(), add = TRUE, after = TRUE) } else { on.exit( switch( @@ -219,7 +223,8 @@ map_so_ii = function( height = height / 2.54 ), stop(sprintf("%s not recognized", tolower(tools::file_ext(path)))) - ) + ), + add = TRUE, after = TRUE ) on.exit(grDevices::dev.off(), add = TRUE, after = TRUE) } @@ -265,7 +270,16 @@ map_so_ii = function( ) ## Plot dataset if any - if (!missing(dataset)) plot(dataset[["geometry"]], add = TRUE, ...) + if (!missing(dataset)) { + if (methods::is(dataset, "sf")) { + dataset = dataset[["geometry"]] + } + if (! methods::is(dataset, "sfc")) { + warning("'dataset' is not a sf or sfc object. It is not plotted.") + } else { + plot(dataset, add = TRUE, ...) + } + } ## Make scope visible if (limit == TRUE) {