feat: warn when trip_headsign matches intermediate stop name#2139
feat: warn when trip_headsign matches intermediate stop name#2139davidgamez merged 7 commits intoMobilityData:masterfrom
Conversation
|
Thanks for opening this pull request! You're awesome. We use semantic commit messages to streamline the release process. Before your pull request can be merged, you should update your pull request title to start with a semantic prefix. Examples of titles with semantic prefixes:
|
|
In this PR patrickbr/gtfstidy#41, i posted the same example but with a screenshot of the trip's route, as well as implementing a fix by overwriting the |
|
Thanks @PatrickSteil for this great rule addition! There are some cases where the trip headsign changes mid-trip. In this situation, the best practices recommend that feeds set trip.headsign to an intermediate stop and then override it using stop_times.stop_headsign for the later portion.
Due to this case, we'd like to proceed with downgrading this rule from a WARNING to INFO severity, since there are some cases where the trip_headsign matching an intermediate stop name is valid behavior. cc @tzujenchanmbd @skalexch |
davidgamez
left a comment
There was a problem hiding this comment.
Great contribution! I just added a comment regarding the method's performance easy to fix.
Thanks!
| } | ||
|
|
||
| // Sort by stop_sequence to find the true last stop | ||
| List<GtfsStopTime> sorted = |
There was a problem hiding this comment.
The stopTimes list is already sorted by sequence. This is specified in the schema, link. In your local generated code GtfsStopTimeTableContainer, you can find the generated method with the following comment:
/**
* @return List of org.mobilitydata.gtfsvalidator.table.GtfsStopTime sorted by stop_sequence
*/
Even though the list is already sorted, and that helps the sorting algorithm, stop times tend to be a large file; having a stream and sorting will impact performance for larger feeds.
There was a problem hiding this comment.
I realize this may not be well-documented for developers, and I apologize for that.
There was a problem hiding this comment.
Thanks for the feedback! Yes, I was not sure whether i could assume the stop times to be sorted :) I am going to rewrite this


Adds a new validation rule
TripHeadsignValidatorthat warns when a trip'strip_headsignmatches thestop_nameof an intermediate stop (i.e., any stop that is not the last stop of the trip). This can cause confusion for passengers boarding after that stop, as the headsign suggests the vehicle is heading somewhere it has already passed.The notice
TripHeadsignMatchesIntermediateStopNoticeis emitted as aWARNINGand includes:trip_idand its row number intrips.txttrip_headsignvaluestop_idandstop_sequenceof the intermediate stop matching thetrip_headsignstop_idof the actual last stop of the tripNoticeFieldsTesthas been updated to register a new notice field name introduced:tripHeadsign.Note that if a trip visits the last stop multiple times, then no warning is shown.
The following screenshot shows a real-world example of the official Swiss GTFS feed, where a trip passed through St. Gallen, and continues to Winterthur. But the
trip_headsignshowsSt. Gallen.