minimal routing code

This commit is contained in:
Nicholas Orlowsky 2025-11-19 18:32:06 -05:00
parent 2d8f131b91
commit a7d323056a
No known key found for this signature in database
GPG key ID: A9F3BA4C0AA7A70B
6 changed files with 151 additions and 20 deletions

View file

@ -39,7 +39,7 @@ pub struct IndexTemplate {
#[derive(Debug, Serialize)]
pub struct TimetableStopRow {
pub stop_id: i64,
pub stop_id: i64,
pub stop_name: String,
pub stop_sequence: i64,
pub times: Vec<Option<i64>>
@ -102,12 +102,12 @@ pub fn build_timetables(
.collect();
let mut stop_map: BTreeMap<i64, (i64, String, Vec<Option<i64>>)> = BTreeMap::new();
let mut stop_map: BTreeMap<String, (i64, String, Vec<Option<i64>>)> = BTreeMap::new();
for (trip_index, trip) in direction_trips.iter().enumerate() {
for stop in &trip.schedule {
let entry = stop_map
.entry(stop.stop.id)
.entry(stop.stop.id.clone())
.or_insert((stop.stop_sequence, stop.stop.name.clone(), vec![None; direction_trips.len()]));
// If this stop_id appears in multiple trips with different sequences, keep the lowest
@ -120,7 +120,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: stop_id.parse().unwrap(),
stop_sequence,
stop_name,
times,