georust / transitfeed

Public transit serializer/deserializer and manipulation library for Rust
Apache License 2.0
16 stars 4 forks source link

StopTime Aggregator #7

Open medwards opened 7 years ago

medwards commented 7 years ago

StopTime structs are not meaningful individually but only when they're grouped by trip. The stop_times.txt file is also not guaranteed to be sorted. It is very useful to have a helper that does this automatically.

I propose a struct Run and a supporting iterator whose constructor groups and sorts the stoptimes for you:

#[derive(Debug, PartialEq)]
pub struct Run
{
    pub trip: &Trip,  // or just trip_id String
    // StopTime is verbose, maybe create a new struct with less fields?
    pub sequence: Vec<StopTime>
}
teburd commented 7 years ago

I agree, stop times by themselves are pretty useless. This seems like a nice way of doing it!