wip: fix: trajectory stats for single aircraft

This commit is contained in:
eneller
2026-01-20 23:49:51 +01:00
parent 696f52eda3
commit ec51069f1d
2 changed files with 25 additions and 24 deletions

View File

@@ -39,7 +39,7 @@ ui <- fluidPage(
hr(),
h4("Batch Analysis"),
numericInput("batch_size", "Number of flights to analyze:", value = 10, min = 2, max = 50),
numericInput("batch_size", "Days of flights to analyze:", value = 5, min = 1, max = 30),
actionButton("batch_analyze", "Run Batch Analysis", class = "btn-warning"),
hr(),
@@ -144,6 +144,7 @@ server <- function(input, output, session) {
data.frame(
Index = i,
ICAO24 = dep[["ICAO24"]] %||% NA,
#FIXME Callsign, Origin, Destination
Callsign = dep[["callsign"]] %||% NA,
Origin = dep[["estDepartureAirport"]] %||% NA,
Destination = dep[["estArrivalAirport"]] %||% NA,
@@ -248,28 +249,9 @@ server <- function(input, output, session) {
status("Running batch analysis...")
tryCatch({
all_trajectories <- list()
n_departures <- min(length(rv$departures), input$batch_size)
withProgress(message = 'Analyzing flights', value = 0, {
for (i in 1:n_departures) {
dep <- rv$departures[[i]]
icao24 <- dep[["ICAO24"]]
dep_time <- dep[["departure_time"]]
incProgress(1/n_departures, detail = paste("Processing", icao24))
if (is.null(dep_time)) next
# Use calculate_trajectory_params from main.Rmd
params <- calculate_trajectory_params(icao24, dep_time, rv$creds)
if (!is.null(params)) {
all_trajectories[[length(all_trajectories) + 1]] <- params
}
Sys.sleep(0.3)
}
all_trajectories <- getAircraftTrajectories(rv$current_icao, time = Sys.time(), creds, days = input$batch_size)
})
if (length(all_trajectories) > 0) {