-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a new rule forbidding negative stop_time #200
Add a new rule forbidding negative stop_time #200
Conversation
f4c8e1a
to
ad1f691
Compare
.values() | ||
.map(|trip| { | ||
trip.stop_times.iter().filter_map(move |st| { | ||
match (st.arrival_time, st.departure_time) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wondering if this is safe to compare with this rust-transit/gtfs-structure#122 (comment) in mind?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::time::Duration
also implements Ord
, so I believe if the type of arrival_time
& departure_time
were changed this comparison would still work the same way (and if not the test will fail).
@stuebinm Hi, thanks a lot for your contribution, much appreciated! In which context do you use this library if you're willing to share? |
* Add a warning if a stop_time as an arrival_time that is later than its departure_time * Add a corresponding test and test data
ad1f691
to
5682cc7
Compare
I use it for Ilztalbahn (a small volunteer-association operated railway line) as an automated check before publishing a new gtfs version (hence my earlier PR about making daemon support optional #197). Since we only have the one line and only a couple trains per week there's little automation in how the gtfs is generated, and sometimes people edit it by hand, so it's very useful to run this validator as a sanity check on it. (btw, thanks a lot for this project! It's very cool to have open-source tools for handling gtfs which we can use, and sometimes even contribute back to!) |
short note on the last force-push: I have added the new validation to the readme file as requested, and have also downgraded it from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great, thanks!
Will merge after adding the required error messages and translations on transport.data.gouv.fr Thanks for your contribution @stuebinm, much appreciated 🙏🥳 |
This adds an error if a
stop_time
has itsarrival_time
later than itsdeparture_time
(i.e. a vehicle would remain at the stop for a negative period of time), along with a corresponding test for this error.As test data I have added a minimised version of the actual gtfs in which this issue just bit me ;)
(note that the MobilityData gtfs-validator has a more general check which also catches this issue: https://gtfs-validator.mobilitydata.org/rules.html#start_and_end_range_out_of_order-rule)