From 441eab38bfc653d9e70f3b02c9fd5b4e1c7242e4 Mon Sep 17 00:00:00 2001
From: David Nortes-Martinez <davidnortes@gmail.com>
Date: Wed, 19 Jan 2022 18:37:56 +0100
Subject: [PATCH] new map theme based on gaspar ddbb

---
 geau/R/map_so_ii.r | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/geau/R/map_so_ii.r b/geau/R/map_so_ii.r
index df6a9a2..cb3eed2 100644
--- a/geau/R/map_so_ii.r
+++ b/geau/R/map_so_ii.r
@@ -20,7 +20,7 @@
 #' # To be added (soon)
 #' }
 
-map_so_ii = function(dataset, dataset_legend = NULL, theme = "clc", bar = TRUE, path = NULL, ...) {
+map_so_ii = function(dataset, dataset_legend = NULL, theme = c("clc", "gaspar"), bar = TRUE, path = NULL, gaspar_year, ...) {
 
     if (!is.null(path)) {
         switch(
@@ -45,6 +45,23 @@ map_so_ii = function(dataset, dataset_legend = NULL, theme = "clc", bar = TRUE,
         )
     }
 
+    if ("gaspar" %in% theme) {
+        if (!missing(gaspar_year)) {
+            border = "grey80"
+            color = ifelse(geau::so_ii_gaspar[ , gaspar_year] > 0, scales::alpha("grey80", .5), NA)
+        } else {
+            border = NA
+            color = NA
+        }
+        
+        plot(
+            geau::so_ii_commune[["geometry"]],
+            border = border,
+            col = color,
+            add = TRUE
+        )
+    }
+
     plot(dataset[["geometry"]], add = TRUE, ...)
 
     if (bar == TRUE) {
@@ -62,4 +79,4 @@ map_so_ii = function(dataset, dataset_legend = NULL, theme = "clc", bar = TRUE,
     }
 
     if (!is.null(path)) invisible(grDevices::dev.off())
-}
\ No newline at end of file
+}
-- 
GitLab