add lfs and lat/lon to calc

This commit is contained in:
2025-08-02 21:31:53 -04:00
parent 013937bfb2
commit d302d2c59d
2 changed files with 109 additions and 60 deletions
+107 -59
View File
@@ -1022,7 +1022,20 @@ Storm Fatalities {data-navmenu="Storm Details"}
Normalization Calculator {data-navmenu="Compute"}
===
Column {data-width=700 .tabset}
```{r}
# Calculator - Setup Code
calculator_storm_selection <- reactiveValues(
storm_year = NULL,
storm_name = NULL,
storm_basin = NULL,
full_lf_id = NULL,
)
```
Column {data-width=700}
---
### Impact Map {.no-padding}
@@ -1031,35 +1044,30 @@ Column {data-width=700 .tabset}
output$impact_analysis_map <- renderLeaflet({
leaflet() %>%
addProviderTiles("Stadia.AlidadeSmooth") %>%
setView(lng = -80.3, lat = 25.6, zoom = 10) %>%
addCircles(
lng = -80.3,
lat = 25.6,
radius = 37040,
color = "blue",
weight = 2,
opacity = 0.3
) %>%
addCircleMarkers(
lng = -80.3,
lat = 25.6,
radius = 5,
weight = 0,
color = "blue",
fillColor = "blue",
fillOpacity = 0.6
)
addProviderTiles("Stadia.AlidadeSmooth") #%>%
#setView(lng = -80.3, lat = 25.6, zoom = 10) %>%
#addCircles(
# lng = -80.3,
# lat = 25.6,
# radius = 37040,
# color = "blue",
# weight = 2,
# opacity = 0.3
#) %>%
#addCircleMarkers(
# lng = -80.3,
# lat = 25.6,
# radius = 5,
# weight = 0,
# color = "blue",
# fillColor = "blue",
# fillOpacity = 0.6
#)
})
leafletOutput("impact_analysis_map", height = "100%")
```
### Impact Data {.no-padding}
```{r}
# Calculator - Impact Data
```
Column {data-width=300}
---
@@ -1067,18 +1075,7 @@ Column {data-width=300}
```{r}
# Calculator - Input
# TODO: add data population and compute
#observeEvent(input$stormYear, {
# stormsByChosenYear <- loss_storms[loss_storms$storm_year == input$stormYear, ]
#
# stormsByYear <- loss_storms %>% filter(storm_year == input$stormYear)
#
# updateSelectInput(
# session,
# "stormName",
# choices = stormsByYear$storm_name,
# selected = NULL
# )
#})
observeEvent(input$impact_storm_year, {
stormsByChosenYear <- all_lf_type_storms[all_lf_type_storms$storm_year == input$impact_storm_year, ]
@@ -1092,41 +1089,92 @@ observeEvent(input$impact_storm_year, {
)
})
observeEvent(input$impact_storm_name, {
uniqueLfs <- all_lf_type_storms %>%
filter(
storm_basin == input$impact_storm_basin,
storm_year == input$impact_storm_year,
storm_name == input$impact_storm_name
)
updateSelectInput(
session,
"impact_storm_full_lf_id",
choices = uniqueLfs$full_lf_id
)
})
observe({
req(
input$impact_lat,
input$impact_lon
)
new_lat <- as.numeric(input$impact_lat)
new_lon <- as.numeric(input$impact_lon)
if(new_lat >= -90 & new_lat <= 90 & new_lon >= -180 & new_lon <= 180) {
leafletProxy("impact_analysis_map") %>%
clearShapes() %>%
clearMarkers() %>%
addCircleMarkers(
lng = new_lon,
lat = new_lat,
radius = 2,
weight = 0,
color = "blue",
fillColor = "blue",
fillOpacity = 0.5
) %>%
addCircles(
lng = new_lon,
lat = new_lat,
radius = 18000,
weight = 1,
color = "blue",
fillColor = "blue",
fillOpacity = 0.05
)
}
})
div(
h6("Storm Selector"),
selectInput(
"impact_storm_basin",
label = NULL,
choices = "AL",
width = "100%"
),
selectInput(
"impact_storm_year",
label = NULL,
choices = all_lf_type_storms$storm_year,
width = "100%"
),
selectInput(
"impact_storm_name",
label = NULL,
choices = NULL,
width = "100%"
),
fluidRow(
column(
6,
selectInput(
"impact_storm_lf_type",
"impact_storm_basin",
label = NULL,
choices = "LF",
choices = "AL",
width = "100%"
)
),
),
column(
6,
selectInput(
"impact_storm_lf_id",
"impact_storm_year",
label = NULL,
choices = all_lf_type_storms$storm_year,
width = "100%"
),
)
),
fluidRow(
column(
6,
selectInput(
"impact_storm_name",
label = NULL,
choices = NULL,
width = "100%"
),
),
column(
6,
selectInput(
"impact_storm_full_lf_id",
label = NULL,
choices = "1",
width = "100%"