Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
Fixed issue related to centerline with route attributes.
Added loading spinner.
  • Loading branch information
cmerikson committed Sep 8, 2023
1 parent 4b521fe commit 7c4c118
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions Transport Shiny.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
library(shiny)
library(shinythemes)
library(shinycssloaders)

ui <- fluidPage(
theme=shinytheme('cosmo'),
Expand All @@ -21,10 +22,10 @@ ui <- fluidPage(
mainPanel(
tabsetPanel(
# Tab for displaying the output table
tabPanel("Output Table", tableOutput("table")),
tabPanel("Output Table", withSpinner(tableOutput("table"))),

# Tab for displaying the plot
tabPanel("Plot", plotlyOutput("plot"))
tabPanel("Plot", withSpinner(plotlyOutput("plot")))
)
)
)
Expand All @@ -35,6 +36,7 @@ server <- function(input, output) {
plotly_obj <- reactiveVal(NULL)

observeEvent(input$process_data, {

# Get user inputs
folder_path <- input$folder_path
crs_string <- input$crs
Expand All @@ -60,7 +62,7 @@ server <- function(input, output) {

# Function to read files in a folder
files = lapply(csv_files, fread)
Data = rbindlist(files)
Data = rbindlist(files,fill=T)

# Include Excel files
if (length(xlsx_files)>0) {
Expand Down Expand Up @@ -108,7 +110,7 @@ server <- function(input, output) {
sf_Data = st_as_sf(Data,coords = c('Easting','Northing'),crs=crs_string)

# Snap tracers to centerline
Data = Data[,Location:=(st_snap(sf_Data$geometry,centerline,2))]
Data = Data[,Location:=(st_snap(sf_Data$geometry,st_zm(centerline),2))]

# Adjust table to output format
adjust_table = function(data) {
Expand Down Expand Up @@ -174,6 +176,7 @@ server <- function(input, output) {
plotly_obj(ggplotly(river_map, width = 800, height = 600))

})

# For rendering a table, you can use:
output$table <- renderTable({
transport_data()
Expand Down

0 comments on commit 7c4c118

Please sign in to comment.