diff --git a/NAMESPACE b/NAMESPACE index 4bb0942..39d1106 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -14,11 +14,16 @@ export(data_get_regions_in_bassin) export(data_get_roe_in_region) export(data_get_station_hubeau) export(db_con) +export(lg_add_trace) +export(lg_annotations_layout) export(lg_profile_empty) export(lg_profile_main) export(lg_profile_second) export(lg_profile_update_main) +export(lg_roe_vertical_line) export(lg_vertical_line) +export(lg_xaxis_layout) +export(lg_yaxis_layout) export(map_add_basemaps) export(map_add_regions_in_bassin) export(map_add_wms_overlayers) @@ -56,6 +61,7 @@ importFrom(dplyr,arrange) importFrom(dplyr,filter) importFrom(dplyr,if_else) importFrom(dplyr,mutate) +importFrom(dplyr,pull) importFrom(glue,glue) importFrom(golem,activate_js) importFrom(golem,add_resource_path) diff --git a/R/fct_data.R b/R/fct_data.R index 7742be3..d2441d5 100644 --- a/R/fct_data.R +++ b/R/fct_data.R @@ -153,7 +153,7 @@ data_get_min_max_metric <- function(selected_region_id, selected_metric) { data_get_roe_in_region <- function(selected_region_id) { query <- glue::glue(" SELECT - roe.gid, nomprincip, lbtypeouvr, lbhautchut, gid_region, roe.geom + roe.gid, axis, distance_axis, nomprincip, lbtypeouvr, lbhautchut, gid_region, roe.geom FROM roe WHERE gid_region = {selected_region_id} AND (roe.cdetouvrag LIKE '2') diff --git a/R/fct_lg_profile.R b/R/fct_lg_profile.R index 736d496..0677a2a 100644 --- a/R/fct_lg_profile.R +++ b/R/fct_lg_profile.R @@ -16,12 +16,19 @@ lg_profile_empty <- function() { temp <- data.frame() plot <- plot_ly(data = temp, source = "plot_pg") %>% - layout(title = list( - text = "Sélectionnez un cours d'eau sur la carte et une métrique pour afficher le graphique", - y = 0.80, # y title position - x = 0.3, # x title position - font = list(size = 15) - )) + layout( + title = list( + text = "Sélectionnez un cours d'eau sur la carte et une métrique pour afficher le graphique", + y = 0.80, # y title position + x = 0.3, # x title position + font = list(size = 15) + ), + xaxis = list( + zeroline = FALSE + ), + yaxis = list( + zeroline = FALSE + )) return(plot) } @@ -54,16 +61,105 @@ lg_vertical_line <- function(x = 0, color = "green") { ) } +#' Create the ROE vertical lines for plotly shapes +#' +#' @param roe_distance_axis vector ROE distance on axis. +#' +#' @return list of each vertical lines +#' @export +lg_roe_vertical_line <- function(roe_distance_axis){ + shapes_list <- lapply(roe_distance_axis, function(x) { + lg_vertical_line(x = x/1000, color = "#323232") + }) + return (shapes_list) +} + +#' plotly xaxis layout. +#' +#' @param data data.frame dgo from axis. +#' +#' @return list +#' @export +lg_xaxis_layout <- function(data){ + xaxis <- list( + title = 'Distance depuis l\'exutoire (km)', + range = c(0, max(data$measure)), + zeroline = FALSE) + return(xaxis) +} + +#' plotly yaxis layout. +#' +#' @param y_label text name of the metric plotted. +#' @param y_label_category text metric category name. +#' +#' @return list +#' @export +lg_yaxis_layout <- function(y_label_category, y_label){ + yaxis <- list( + title = paste0(y_label_category, " - ", y_label), + side = 'left', + zeroline = FALSE + ) + return(yaxis) +} + +#' plotly annotations layout. +#' +#' @param data data.frame dgo from axis. +#' +#' @return list +#' @export +lg_annotations_layout <- function(data){ + annotations = list( + text = unique(data$toponyme), + x = 1, # x-coordinate (0 to 1, where 0 is left and 1 is right) + y = -0.18, # y-coordinate (0 to 1, where 0 is bottom and 1 is top) + xref = "paper", # "paper" to specify coordinates relative to the entire plot + yref = "paper", + showarrow = FALSE, # Don't show the arrow + font = list( + # family = "Open Sans", + size = 14, + # color = "black" + weight = "bold" + ) + ) + return(annotations) +} + +#' plotly add trace. +#' +#' @param data data frame containing the selected axis data. +#' @param y text metric to be plotted on the y-axis. +#' @param y_label text name of the metric plotted. +#' @param yaxis text axis id. +#' +#' @return list +#' @export +lg_add_trace <- function(data, y, y_label, yaxis = 'y1'){ + trace <- list( + x = data$measure, + y = y, + key = data$fid, # the "id" column for hover text + type = 'scatter', + mode = 'lines', + name = y_label, + yaxis = yaxis + ) + return(trace) +} + #' Create a longitudinal profile plot for selected axis data #' #' This function generates a longitudinal profile plot using the 'plot_ly' #' function from the 'plotly' package. It allows you to visualize a specific #' metric along the selected axis. #' -#' @param data A data frame containing the selected axis data. -#' @param y The metric to be plotted on the y-axis. -#' @param y_label The name of the metric plotted. -#' @param y_label_category The metric category name. +#' @param data data frame containing the selected axis data. +#' @param y text metric to be plotted on the y-axis. +#' @param y_label text name of the metric plotted. +#' @param y_label_category text metric category name. #' #' @return A longitudinal profile plot with the specified metric. #' @@ -84,26 +180,10 @@ lg_profile_main <- function(data, y, y_label, y_label_category) { key = data$fid, # the "id" column for hover text type = 'scatter', mode = 'lines', name = y_label) %>% layout( - xaxis = list(title = 'Distance depuis l\'exutoire (km)'), - yaxis = list( - title = paste0(y_label_category, " - ", y_label), - side = 'left' - ), + xaxis = lg_xaxis_layout(data), + yaxis = lg_yaxis_layout(y_label_category, y_label), # river name - annotations = list( - text = unique(data$toponyme), - x = 1, # x-coordinate (0 to 1, where 0 is left and 1 is right) - y = -0.18, # y-coordinate (0 to 1, where 0 is bottom and 1 is top) - xref = "paper", # Use "paper" to specify coordinates relative to the entire plot - yref = "paper", - showarrow = FALSE, # Don't show the arrow - font = list( - # family = "Open Sans", - size = 14, - # color = "black" - weight = "bold" - ) - ), + annotations = lg_annotations_layout(data), showlegend=TRUE, legend = list(orientation = 'h'), hovermode = "x unified", @@ -164,35 +244,14 @@ lg_profile_main <- function(data, y, y_label, y_label_category) { #' #' @export lg_profile_update_main <- function(data, y, y_label, y_label_category){ - proxy_trace <- list( - x = data$measure, - y = y, - key = data$fid, # the "id" column for hover text - type = 'scatter', - mode = 'lines', - name = y_label, - yaxis = 'y1' - ) + + proxy_trace <- lg_add_trace(data, y, y_label, yaxis = 'y1') proxy_layout <- list( - yaxis = list( - title = paste0(y_label_category, " - ", y_label), - side = 'left' - ), + xaxis = lg_xaxis_layout(data), + yaxis = lg_yaxis_layout(y_label_category, y_label), # put all the annotation options to replace the river name - annotations = list(list( - text = unique(data$toponyme), - x = 1, # x-coordinate (0 to 1, where 0 is left and 1 is right) - y = -0.18, # y-coordinate (0 to 1, where 0 is bottom and 1 is top) - xref = "paper", # Use "paper" to specify coordinates relative to the entire plot - yref = "paper", - showarrow = FALSE, # Don't show the arrow - font = list( - size = 14, - weight = "bold" - ) - ) - ) + annotations = lg_annotations_layout(data) ) proxy <- list("trace" = proxy_trace, "layout" = proxy_layout) @@ -219,15 +278,8 @@ lg_profile_update_main <- function(data, y, y_label, y_label_category){ #' #' @export lg_profile_second <- function(data, y, y_label, y_label_category){ - proxy_trace <- list( - x = data$measure, - y = y, - key = data$fid, # the "id" column for hover text - type = 'scatter', - mode = 'lines', - name = y_label, - yaxis = 'y2' - ) + + proxy_trace <- lg_add_trace(data, y, y_label, yaxis = 'y2') proxy_layout <- list( yaxis2 = list( diff --git a/R/fct_map.R b/R/fct_map.R index 4795ef3..5f270dd 100644 --- a/R/fct_map.R +++ b/R/fct_map.R @@ -145,6 +145,8 @@ map_add_regions_in_bassin <- function(map, bassins_data, #' @param region_click A vector containing information about the clicked region. #' @param selected_region_feature A sf data frame containing information about the selected region feature. #' @param regions_data A sf data.frame with the hydrographic regions of the bassin selected. +#' @param roe_region sf data.frame ROE in selected region. +#' @param hydro_station_region sf data.frame Hubeau hydrometric stations in selected region. #' #' @return An updated Leaflet map with relevant layers and information displayed. #' @@ -182,18 +184,27 @@ map_add_regions_in_bassin <- function(map, bassins_data, #' "lat" = Y) #' centre_region_coord$id <- 11 #' +#' # get ROE in region +#' roe_region <- data_get_roe_in_region(centre_region_coord$id) +#' # get hydro stations in region +#' hydro_station_region <- data_get_station_hubeau(centre_region_coord$id) +#' #' # map the element in the region clicked #' map <- map_region_clicked(map = map_region, #' region_click = centre_region_coord, #' selected_region_feature = selected_region, -#' regions_data = region_hydrographique) +#' regions_data = region_hydrographique, +#' roe_region = roe_region, +#' hydro_station_region = hydro_station_region) #' map #' #' @export map_region_clicked <- function(map, region_click, selected_region_feature, - regions_data) { + regions_data, + roe_region, + hydro_station_region) { map %>% setView(lng = region_click$lng , lat = region_click$lat, zoom = 7.5) %>% clearGroup(c(params_map_group()[["region"]], @@ -215,7 +226,7 @@ map_region_clicked <- function(map, group = params_map_group()[["region"]] ) %>% # add ROE overlayers from PostgreSQL - addCircleMarkers(data = data_get_roe_in_region(region_click$id), + addCircleMarkers(data = roe_region, radius = 3, weight = 0.5, opacity = 0.9, @@ -227,7 +238,7 @@ map_region_clicked <- function(map, ) %>% # hydrometric stations layer hidden by default hideGroup(params_map_group()[["roe"]]) %>% - addCircleMarkers(data = data_get_station_hubeau(region_click$id), + addCircleMarkers(data = hydro_station_region, radius = 3, weight = 0.5, opacity = 0.9, @@ -368,11 +379,18 @@ map_axis <- function(map, data_axis) { #' "lat" = Y) #' centre_region_coord$id <- 11 #' +#' # get ROE in region +#' roe_region <- data_get_roe_in_region(centre_region_coord$id) +#' # get hydro stations in region +#' hydro_station_region <- data_get_station_hubeau(centre_region_coord$id) +#' #' # map the element in the region clicked #' map <- map_region_clicked(map = map_region, #' region_click = centre_region_coord, #' selected_region_feature = selected_region, -#' regions = region_hydrographique) +#' regions_data = region_hydrographique, +#' roe_region = roe_region, +#' hydro_station_region = hydro_station_region) #' map #' #' # build geoserver WMS filter diff --git a/R/mod_explore.R b/R/mod_explore.R index 057b8a9..e357a8c 100644 --- a/R/mod_explore.R +++ b/R/mod_explore.R @@ -66,7 +66,9 @@ mod_explore_ui <- function(id){ uiOutput(ns("profileareaUI")), uiOutput(ns("profileradiobuttonUI")), uiOutput(ns("removeprofileaxeUI"), - style = "margin-top: 10px;") # more space above button + style = "margin-top: 10px;"), # more space above button + uiOutput(ns("profileroeUI"), + style = "margin-top: 10px;") ) ) ) @@ -88,7 +90,7 @@ mod_explore_ui <- function(id){ #' @import shiny #' @importFrom leaflet leafletProxy clearGroup leafletOutput renderLeaflet #' @importFrom htmltools HTML div img -#' @importFrom dplyr filter mutate if_else +#' @importFrom dplyr filter mutate if_else pull #' @importFrom plotly event_register event_data plotlyProxy plotlyProxyInvoke renderPlotly plotlyOutput #' @importFrom bslib popover update_popover #' @importFrom bsicons bs_icon @@ -142,24 +144,32 @@ mod_explore_server <- function(id){ selected_profile_metric_name = NULL, selected_profile_metric_type = NULL, strahler = NULL, + min_max_metric = NULL, + # UI generator ui_strahler_filter = NULL, ui_metric_type = NULL, ui_metric = NULL, ui_unit_area = NULL, - min_max_metric = NULL, ui_metric_filter = NULL, ui_profile_metric_type = NULL, ui_profile_metric = NULL, ui_profile_unit_area = NULL, ui_remove_profile_axe = NULL, + ui_roe_profile = NULL, ui_download = NULL, cql_filter = NULL, # WMS filter sld_body = NULL, # WMS SLD symbology selected_axis_df = NULL, # dgo_axis dataframe to plot graph profile_display = FALSE, # controle if metric and axis is selected = display the profile plot = lg_profile_empty(), + leaflet_hover_measure = 2.5, # measure field from mesure to add vertical line on longitudinal profile + leaflet_hover_shapes = list(shapes = list(lg_vertical_line(2.5))), # list to store vertical lines to display on longitudinal profile + roe_vertical_line = NULL, # list with verticale line to plot on longitudinal profile plotly_hover = NULL, - region_name = NULL + region_name = NULL, + roe_region = NULL, + roe_axis = NULL, + hydro_station_region = NULL ) ### INIT MAP & PROFILE #### @@ -205,6 +215,11 @@ mod_explore_server <- function(id){ r_val$ui_remove_profile_axe }) + # checkbox display ROE + output$profileroeUI <- renderUI({ + r_val$ui_roe_profile + }) + #### metric #### # UI create choose metric @@ -360,6 +375,10 @@ mod_explore_server <- function(id){ r_val$region_name = utile_normalize_string(r_val$selected_region_feature$lbregionhy) # get the axis in the region r_val$network_region_axis = data_get_axis(selected_region_id = r_val$region_click$id) + # get ROE in region + r_val$roe_region = data_get_roe_in_region(r_val$region_click$id) + # get hydro stations in region + r_val$hydro_station_region = data_get_station_hubeau(r_val$region_click$id) # get strahler data r_val$strahler = isolate(data_get_min_max_strahler(selected_region_id = r_val$region_click$id)) # build strahler slider @@ -375,7 +394,9 @@ mod_explore_server <- function(id){ leafletProxy("exploremap") %>% map_region_clicked(region_click = input$exploremap_shape_click, selected_region_feature = r_val$selected_region_feature, - regions_data = r_val$regions_in_bassin) + regions_data = r_val$regions_in_bassin, + roe_region = r_val$roe_region, + hydro_station_region = r_val$hydro_station_region) # run only once, control with region_already_clicked if (r_val$region_already_clicked == FALSE){ @@ -406,6 +427,9 @@ mod_explore_server <- function(id){ mutate(measure = measure/1000) # extract axis start end point r_val$axis_start_end = data_get_axis_start_end(dgo_axis = r_val$dgo_axis) + # get ROE in axis clicked + r_val$roe_axis = r_val$roe_region %>% + filter(axis == r_val$axis_click$id) # map dgo axis when axis clicked and metric selected leafletProxy("exploremap") %>% @@ -432,6 +456,29 @@ mod_explore_server <- function(id){ plotlyProxyInvoke("addTraces", proxy_main_axe$trace, 0) %>% plotlyProxyInvoke("relayout", proxy_main_axe$layout) + # update ROE vertical lines + if (input$roe_profile == TRUE){ + if (!is.null(r_val$roe_vertical_line)){ + # remove the previous ROE vertical lines if exist + r_val$leaflet_hover_shapes$shapes <- list(r_val$leaflet_hover_shapes$shapes[[1]]) + } + # create the vertical line from ROE distance_axis + r_val$roe_vertical_line <- lg_roe_vertical_line(r_val$roe_axis$distance_axis) + # increment the vertical list shape to keep the hover map vertical line + r_val$leaflet_hover_shapes$shapes <- c(r_val$leaflet_hover_shapes$shapes, + r_val$roe_vertical_line) + # update profile + plotlyProxy("long_profile") %>% + plotlyProxyInvoke("relayout", r_val$leaflet_hover_shapes) + }else{ + # remove the previous ROE vertical lines if exist + r_val$leaflet_hover_shapes$shapes <- list(r_val$leaflet_hover_shapes$shapes[[1]]) + # update profile + plotlyProxy("long_profile") %>% + plotlyProxyInvoke("relayout", r_val$leaflet_hover_shapes) + } + + if(!is.null(input$profile_metric)){ # second metric selected = update second metric profile # create the list to add trace and layout to change second axe plot proxy_second_axe <- lg_profile_second(data = r_val$selected_axis_df, @@ -539,6 +586,9 @@ mod_explore_server <- function(id){ choices = utile_get_metric_type(params_metrics_choice()), selected = utile_get_metric_type(params_metrics_choice())[1]) + # built ROE checkboxInput and input + r_val$ui_roe_profile = checkboxInput(ns("roe_profile"), label = "ROE", value = FALSE) + # update dgo on axis to reset tooltip leafletProxy("exploremap") %>% map_dgo_axis(selected_axis = r_val$dgo_axis, region_axis = r_val$network_region_axis, @@ -637,6 +687,31 @@ mod_explore_server <- function(id){ }) + #### profile metric add ROE #### + + observeEvent(input$roe_profile, { + if (input$roe_profile == TRUE){ + if (!is.null(r_val$roe_vertical_line)){ + # remove the previous ROE vertical lines if exist + r_val$leaflet_hover_shapes$shapes <- list(r_val$leaflet_hover_shapes$shapes[[1]]) + } + # create the vertical line from ROE distance_axis + r_val$roe_vertical_line <- lg_roe_vertical_line(r_val$roe_axis$distance_axis) + # increment the vertical list shape to keep the hover map vertical line + r_val$leaflet_hover_shapes$shapes <- c(r_val$leaflet_hover_shapes$shapes, + r_val$roe_vertical_line) + # update profile + plotlyProxy("long_profile") %>% + plotlyProxyInvoke("relayout", r_val$leaflet_hover_shapes) + }else{ + # remove the previous ROE vertical lines if exist + r_val$leaflet_hover_shapes$shapes <- list(r_val$leaflet_hover_shapes$shapes[[1]]) + # update profile + plotlyProxy("long_profile") %>% + plotlyProxyInvoke("relayout", r_val$leaflet_hover_shapes) + } + }) + ### EVENT FILTER #### observeEvent(c(input$strahler, input$metricfilter, r_val$ui_strahler_filter), { @@ -710,11 +785,16 @@ mod_explore_server <- function(id){ observeEvent(input$exploremap_shape_mouseover, { if (input$exploremap_shape_mouseover$group == params_map_group()$dgo_axis && !is.null(input$exploremap_shape_mouseover)){ # extract dgo axis fid from map - select_measure <- r_val$dgo_axis %>% - filter(fid == input$exploremap_shape_mouseover$id) - # change profile layout with vertial line + r_val$leaflet_hover_measure <- r_val$dgo_axis %>% + filter(fid == input$exploremap_shape_mouseover$id) %>% + pull(measure) + # remove the first element (hover dgo vertical line) + r_val$leaflet_hover_shapes <- list(shapes = r_val$leaflet_hover_shapes$shapes[-1]) + # add the new hover dgo vertical line + r_val$leaflet_hover_shapes$shapes <- c(list(lg_vertical_line(r_val$leaflet_hover_measure)), r_val$leaflet_hover_shapes$shapes) + # change profile layout with vertical line plotlyProxy("long_profile") %>% - plotlyProxyInvoke("relayout", list(shapes = list(lg_vertical_line(select_measure$measure)))) + plotlyProxyInvoke("relayout", r_val$leaflet_hover_shapes) } }) }) diff --git a/man/lg_add_trace.Rd b/man/lg_add_trace.Rd new file mode 100644 index 0000000..c5bd678 --- /dev/null +++ b/man/lg_add_trace.Rd @@ -0,0 +1,23 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/fct_lg_profile.R +\name{lg_add_trace} +\alias{lg_add_trace} +\title{plotly add trace.} +\usage{ +lg_add_trace(data, y, y_label, yaxis = "y1") +} +\arguments{ +\item{data}{data frame containing the selected axis data.} + +\item{y}{text metric to be plotted on the y-axis.} + +\item{y_label}{text name of the metric plotted.} + +\item{yaxis}{text axis id.} +} +\value{ +list +} +\description{ +plotly add trace. +} diff --git a/man/lg_annotations_layout.Rd b/man/lg_annotations_layout.Rd new file mode 100644 index 0000000..b678bde --- /dev/null +++ b/man/lg_annotations_layout.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/fct_lg_profile.R +\name{lg_annotations_layout} +\alias{lg_annotations_layout} +\title{plotly annotations layout.} +\usage{ +lg_annotations_layout(data) +} +\arguments{ +\item{data}{data.frame dgo from axis.} +} +\value{ +list +} +\description{ +plotly annotations layout. +} diff --git a/man/lg_profile_main.Rd b/man/lg_profile_main.Rd index 073ef1b..569deef 100644 --- a/man/lg_profile_main.Rd +++ b/man/lg_profile_main.Rd @@ -7,13 +7,13 @@ lg_profile_main(data, y, y_label, y_label_category) } \arguments{ -\item{data}{A data frame containing the selected axis data.} +\item{data}{data frame containing the selected axis data.} -\item{y}{The metric to be plotted on the y-axis.} +\item{y}{text metric to be plotted on the y-axis.} -\item{y_label}{The name of the metric plotted.} +\item{y_label}{text name of the metric plotted.} -\item{y_label_category}{The metric category name.} +\item{y_label_category}{text metric category name.} } \value{ A longitudinal profile plot with the specified metric. diff --git a/man/lg_roe_vertical_line.Rd b/man/lg_roe_vertical_line.Rd new file mode 100644 index 0000000..abdbeec --- /dev/null +++ b/man/lg_roe_vertical_line.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/fct_lg_profile.R +\name{lg_roe_vertical_line} +\alias{lg_roe_vertical_line} +\title{Create the ROE vertical lines for plotly shapes} +\usage{ +lg_roe_vertical_line(roe_distance_axis) +} +\arguments{ +\item{roe_distance_axis}{vector ROE distance on axis.} +} +\value{ +list of each vertical lines +} +\description{ +Create the ROE vertical lines for plotly shapes +} diff --git a/man/lg_xaxis_layout.Rd b/man/lg_xaxis_layout.Rd new file mode 100644 index 0000000..8130299 --- /dev/null +++ b/man/lg_xaxis_layout.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/fct_lg_profile.R +\name{lg_xaxis_layout} +\alias{lg_xaxis_layout} +\title{plotly xaxis layout.} +\usage{ +lg_xaxis_layout(data) +} +\arguments{ +\item{data}{data.frame dgo from axis.} +} +\value{ +list +} +\description{ +plotly xaxis layout. +} diff --git a/man/lg_yaxis_layout.Rd b/man/lg_yaxis_layout.Rd new file mode 100644 index 0000000..b904c8e --- /dev/null +++ b/man/lg_yaxis_layout.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/fct_lg_profile.R +\name{lg_yaxis_layout} +\alias{lg_yaxis_layout} +\title{plotly yaxis layout.} +\usage{ +lg_yaxis_layout(y_label_category, y_label) +} +\arguments{ +\item{y_label_category}{text metric category name.} + +\item{y_label}{text name of the metric plotted.} +} +\value{ +list +} +\description{ +plotly yaxis layout. +} diff --git a/man/map_metric.Rd b/man/map_metric.Rd index e7551d6..6409436 100644 --- a/man/map_metric.Rd +++ b/man/map_metric.Rd @@ -62,11 +62,18 @@ centre_region_coord <- as.data.frame(st_coordinates(centre_region)) \%>\% "lat" = Y) centre_region_coord$id <- 11 +# get ROE in region +roe_region <- data_get_roe_in_region(centre_region_coord$id) +# get hydro stations in region +hydro_station_region <- data_get_station_hubeau(centre_region_coord$id) + # map the element in the region clicked map <- map_region_clicked(map = map_region, region_click = centre_region_coord, selected_region_feature = selected_region, - regions = region_hydrographique) + regions_data = region_hydrographique, + roe_region = roe_region, + hydro_station_region = hydro_station_region) map # build geoserver WMS filter diff --git a/man/map_region_clicked.Rd b/man/map_region_clicked.Rd index fdcc244..e3ba0d8 100644 --- a/man/map_region_clicked.Rd +++ b/man/map_region_clicked.Rd @@ -4,7 +4,14 @@ \alias{map_region_clicked} \title{Update Leaflet Map for a Clicked Region} \usage{ -map_region_clicked(map, region_click, selected_region_feature, regions_data) +map_region_clicked( + map, + region_click, + selected_region_feature, + regions_data, + roe_region, + hydro_station_region +) } \arguments{ \item{map}{An existing Leaflet map to be updated.} @@ -14,6 +21,10 @@ map_region_clicked(map, region_click, selected_region_feature, regions_data) \item{selected_region_feature}{A sf data frame containing information about the selected region feature.} \item{regions_data}{A sf data.frame with the hydrographic regions of the bassin selected.} + +\item{roe_region}{sf data.frame ROE in selected region.} + +\item{hydro_station_region}{sf data.frame Hubeau hydrometric stations in selected region.} } \value{ An updated Leaflet map with relevant layers and information displayed. @@ -53,11 +64,18 @@ centre_region_coord <- as.data.frame(st_coordinates(centre_region)) \%>\% "lat" = Y) centre_region_coord$id <- 11 +# get ROE in region +roe_region <- data_get_roe_in_region(centre_region_coord$id) +# get hydro stations in region +hydro_station_region <- data_get_station_hubeau(centre_region_coord$id) + # map the element in the region clicked map <- map_region_clicked(map = map_region, region_click = centre_region_coord, selected_region_feature = selected_region, - regions_data = region_hydrographique) + regions_data = region_hydrographique, + roe_region = roe_region, + hydro_station_region = hydro_station_region) map }