add preliminary nta support

This commit is contained in:
Nicholas Orlowsky 2026-01-12 22:46:53 -05:00
parent a7d323056a
commit 1d66553398
No known key found for this signature in database
GPG key ID: A9F3BA4C0AA7A70B
21 changed files with 3318 additions and 257 deletions

View file

@ -20,7 +20,7 @@ pub struct ContentTemplate<T: askama::Template> {
pub struct RouteTemplate {
pub route: libseptastic::route::Route,
pub timetables: Vec<TimetableDirection>,
pub filter_stops: Option<Vec<i64>>
pub filter_stops: Option<Vec<String>>
}
#[derive(askama::Template)]
@ -32,6 +32,12 @@ pub struct RoutesTemplate {
pub bus_routes: Vec<libseptastic::route::Route>
}
#[derive(askama::Template)]
#[template(path = "stops.html")]
pub struct StopsTemplate {
pub tc_stops: Vec<libseptastic::stop::Stop>,
}
#[derive(askama::Template)]
#[template(path = "index.html")]
pub struct IndexTemplate {
@ -39,7 +45,7 @@ pub struct IndexTemplate {
#[derive(Debug, Serialize)]
pub struct TimetableStopRow {
pub stop_id: i64,
pub stop_id: String,
pub stop_name: String,
pub stop_sequence: i64,
pub times: Vec<Option<i64>>
@ -55,6 +61,21 @@ pub struct TimetableDirection {
pub next_id: Option<String>
}
pub struct TripPerspective {
pub trip:libseptastic::stop_schedule::Trip,
pub perspective_stop: libseptastic::stop_schedule::StopSchedule,
pub est_arrival_time: i64,
pub is_tracked: bool
}
#[derive(askama::Template)]
#[template(path = "stop.html")]
pub struct StopTemplate {
pub stop: libseptastic::stop::Stop,
pub routes: Vec<libseptastic::route::Route>,
pub trips: Vec<TripPerspective>,
pub current_time: i64
}
pub fn build_timetables(
directions: Vec<Direction>,
@ -120,7 +141,7 @@ pub fn build_timetables(
let mut rows: Vec<TimetableStopRow> = stop_map
.into_iter()
.map(|(stop_id, (stop_sequence, stop_name, times))| TimetableStopRow {
stop_id: stop_id.parse().unwrap(),
stop_id,
stop_sequence,
stop_name,
times,