Skip to content

Commit

Permalink
Use historical data for departures
Browse files Browse the repository at this point in the history
  • Loading branch information
kylerchin committed May 14, 2024
1 parent 1e00646 commit b973f41
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "amtrak-gtfs-rt"
version = "0.2.5"
version = "0.2.6"
license = "AGPL-3.0"
description = "Converts Amtrak Track-A-Train to valid GTFS-rt vehicle and trip information"
edition = "2021"
Expand Down
28 changes: 22 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ pub struct AmtrakArrivalJson {
estarr: Option<String>,
//"estdep":"12/11/2023 17:36:00",
estdep: Option<String>,
//same format as estimate but it's actual historical time
postarr: Option<String>,
postdep: Option<String>,
//"estarrcmnt":"ON TIME",
estarrcmnt: Option<String>,
//"estdepcmnt":"ON TIME"
Expand Down Expand Up @@ -255,22 +258,35 @@ fn feature_to_gtfs_unified(gtfs: &Gtfs, feature: &geojson::Feature) -> gtfs_rt::
.map(|feature| gtfs_rt::trip_update::StopTimeUpdate {
stop_sequence: None,
stop_id: Some(feature.code.clone()),
arrival: match &feature.estarr {
Some(estarr) => Some(gtfs_rt::trip_update::StopTimeEvent {
arrival: match &feature.postarr {
Some(postarr) => Some(gtfs_rt::trip_update::StopTimeEvent {
delay: None,
time: Some(time_and_tz_to_unix(&estarr, feature.tz)),
time: Some(time_and_tz_to_unix(postarr, feature.tz)),
uncertainty: None,
}),
None => None,
None => match &feature.estarr {
Some(estarr) => Some(gtfs_rt::trip_update::StopTimeEvent {
delay: None,
time: Some(time_and_tz_to_unix(&estarr, feature.tz)),
uncertainty: None,
}),
None => None,
}
},
departure: match &feature.estdep {
departure: match &feature.postdep {
Some(postdep) => Some(gtfs_rt::trip_update::StopTimeEvent {
delay: None,
time: Some(time_and_tz_to_unix(postdep, feature.tz)),
uncertainty: None,
}),
None => match &feature.estdep {
Some(estdep) => Some(gtfs_rt::trip_update::StopTimeEvent {
delay: None,
time: Some(time_and_tz_to_unix(&estdep, feature.tz)),
uncertainty: None,
}),
None => None,
},
}},
departure_occupancy_status: None,
schedule_relationship: None,
stop_time_properties: None,
Expand Down

0 comments on commit b973f41

Please sign in to comment.