From a5719ace2c89ba4a84f1046ee48eb4a75ff3fa5e Mon Sep 17 00:00:00 2001
From: David Nortes-Martinez <davidnortes@gmail.com>
Date: Thu, 20 Jan 2022 19:28:53 +0100
Subject: [PATCH] New theme based on the hydrologic network dataset

---
 geau/R/map_so_ii.r | 31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/geau/R/map_so_ii.r b/geau/R/map_so_ii.r
index 21aec3d..d3c3162 100644
--- a/geau/R/map_so_ii.r
+++ b/geau/R/map_so_ii.r
@@ -6,10 +6,13 @@
 #' @param bar logical, should a bar be plotted
 #' @param path character, the name of the file to save the plot
 #' @param gaspar_year character, the year chosen for gaspar theme
+#' @param hydro_detail character, the niveau of detail in the representation of the hydrographic network
 #' @param ...  some parameters that will be used by plot (from sf)
 #'
 #' @return Nothing useful.
 #' 
+#' @details hydro_detail takes values "1", "2", "3" or "canal"
+#' 
 #' @export
 #'
 #' @encoding UTF-8
@@ -24,10 +27,11 @@
 map_so_ii = function(
     dataset,
     dataset_legend = NULL,
-    theme = c("clc", "gaspar"),
+    theme = c("clc", "gaspar", "hydro"),
     bar = TRUE,
     path = NULL,
     gaspar_year,
+    hydro_detail,
     ...
 ) {
 
@@ -74,6 +78,31 @@ map_so_ii = function(
         )
     }
 
+    if ("hydro" %in% theme) {
+        if(missing(hydro_detail)) {
+            hydro_detail = "0"
+        }
+
+        if(hydro_detail == "canal") {
+            color = scales::alpha("red", .3)
+            so_ii_hydro_toplot = geau::so_ii_hydro[["geometry"]][geau::so_ii_hydro[["degre"]] == hydro_detail]
+            lwd = 1
+        } else {
+            #color = "#dbe8f0"
+            color =  scales::alpha("blue", .3)
+            so_ii_hydro_toplot = geau::so_ii_hydro[["geometry"]][geau::so_ii_hydro[["degre"]] <= hydro_detail]
+            lwd = 4 - as.numeric(geau::so_ii_hydro[["degre"]][geau::so_ii_hydro[["degre"]] <= hydro_detail])
+
+        }
+
+        plot(
+            so_ii_hydro_toplot, 
+            col = color,
+            lwd = lwd, 
+            add=TRUE
+            ) 
+    }
+
     plot(dataset[["geometry"]], add = TRUE, ...)
 
     plot(geau::so_ii_limit, lwd = 2, add = TRUE)
-- 
GitLab