Skip to content
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

Merged
merged 1 commit into from
Jul 29, 2024

Conversation

stuebinm
Copy link
Contributor

This adds an error if a stop_time has its arrival_time later than its departure_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)

@stuebinm stuebinm requested review from Tristramg, antoine-de and a team as code owners July 24, 2024 20:12
@stuebinm stuebinm force-pushed the negative-stop-durations branch from f4c8e1a to ad1f691 Compare July 24, 2024 20:20
.values()
.map(|trip| {
trip.stop_times.iter().filter_map(move |st| {
match (st.arrival_time, st.departure_time) {
Copy link
Member

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?

Copy link
Contributor Author

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).

@AntoineAugusti
Copy link
Member

@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
@stuebinm stuebinm force-pushed the negative-stop-durations branch from ad1f691 to 5682cc7 Compare July 25, 2024 14:03
@stuebinm
Copy link
Contributor Author

@antoine-de

In which context do you use this library if you're willing to share?

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!)

@stuebinm
Copy link
Contributor Author

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 Severity::Error to Severity::Warning to be in line with e.g. NullDuration and NegativeTravelTime which are likewise warnings, not errors.

Copy link
Member

@antoine-de antoine-de left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great, thanks!

@AntoineAugusti
Copy link
Member

Will merge after adding the required error messages and translations on transport.data.gouv.fr

Thanks for your contribution @stuebinm, much appreciated 🙏🥳

@AntoineAugusti AntoineAugusti merged commit 0ad94ba into etalab:master Jul 29, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants