-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.R
115 lines (85 loc) · 2.78 KB
/
app.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# Map of aeronautical obstacles
#
# https://www.ais.pansa.pl/en/publications/etod/
#
# file 252 dated 2022-06-16
library(dplyr)
library(DT)
library(leaflet)
library(readr)
library(shiny)
library(shinyjs)
library(stringr)
load("data/Obstacles_2024-02-22.rda")
do$latitude <- round(do$latitude, 6)
do$longitude <- round(do$longitude, 6)
# reference points of Polish borders
n_point <- 54.835778
s_point <- 49.0025
e_point <- 24.15
w_point <- 14.11
# obstacle list
obstacle_list <- sort(unique(do$Obstacle_type))
# Define UI for application that draws a histogram
ui <- fluidPage(
theme = bslib::bs_theme(version = 5, bootswatch = "superhero"),
shinyjs::useShinyjs(),
br(),
fluidRow(
column(3),
column(6, htmlOutput("about")),
column(3)
),
hr(),
fluidRow(
column(1),
column(3, align = "bottom",
selectInput("obstacle", "Obstacle type:",
choices = obstacle_list,
selected = c("Measuring mast"),
multiple = FALSE)),
column(8, align = "center", leafletOutput("mastobstacles", height=1000, width = 1000)),
),
hr(),
fluidRow(
column(1),
column(10,
dataTableOutput("doobstacles")),
column(1)
)
)
server <- function(input, output, session) {
dos <- reactiveValues(data = NULL)
observeEvent(input$obstacle, {
req(input$obstacle)
dos$data <- do %>% filter(input$obstacle == Obstacle_type)
})
# dos$data <- reactive({
# req(input$obstacle)
# do %>% filter(input$obstacle == Obstacle_type)
# })
output$mastobstacles <- renderLeaflet({
fpopup <- paste0("E ", round(dos$data$longitude, 6), "<br> N ", round(dos$data$latitude, 6), "<br>",
"Height: ", dos$data$Height, " ", dos$data$Height_Uom, "<br>",
"Location: ", dos$data$Location, "<br>",
"Obstacle type: ", dos$data$Obstacle_type)
leaflet(dos$data) %>%
fitBounds(lng1 = e_point, lat1 = n_point, lng2 = w_point, lat2 = s_point) %>%
addCircleMarkers(radius = 4, color = "red", popup = ~fpopup) %>%
addProviderTiles(providers$OpenStreetMap)
})
output$doobstacles <- renderDT({
datatable(dos$data, style = "bootstrap5",
options = list(paging = TRUE, pageLength = 25))
}, server = FALSE)
output$about <- renderText({
paste0('<center><h3>Measurement masts in Poland</h3></center><br>
<p><u>Information about the source of data:</u> file 02/24 dated 2024-02-22 from
PANSA <a href="https://www.ais.pansa.pl/en/publications/etod/">
https://www.ais.pansa.pl/en/publications/etod/</a><br>
')
})
# End application when a window or a tab is closed
session$onSessionEnded(stopApp)
}
shinyApp(ui = ui, server = server)