feat: require shape_id when a trip has continuous pickup or drop-off - #2173
feat: require shape_id when a trip has continuous pickup or drop-off#2173vssinghh wants to merge 2 commits into
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:
|
The spec makes trips.shape_id conditionally required: it is required if the trip has continuous pickup or drop-off behavior defined in routes.txt or in stop_times.txt. GtfsTripSchema already annotates shapeId as @ConditionallyRequired, but nothing enforced it. Adds TripShapeIdConditionalValidator, which emits the existing MissingRequiredFieldNotice when such a trip has no shape_id. This follows TransferStopIdsConditionalValidator and StopTimesGeographyIdPresenceValidator, which raise the generic notice under a conditional rather than defining a new notice type. A value of 1 is treated like an empty value, since the reference defines both as no continuous stopping behavior. Values in stop_times.txt override those in routes.txt. Closes MobilityData#1785
71149cb to
58bcaef
Compare
There was a problem hiding this comment.
Looks good spec-wise. The tests cover all possible cases.
It would be nice to add one more granular overriding test: no shape_id + route.continuous_pickup = 0 + all stop_times have continuous_pickup=1 except for one stop_times.continuous_pickup = 2 or 3. All stop_times will override but the notice is still generated.
One dev review is also required to check the code.
Adds the case raised in review: the route defines continuous pickup, every stop time overrides it, and one of those overrides is itself a continuous value. The trip still needs a shape, so the notice is expected. This sits between the two existing override tests, which cover all stop times overriding to a non-continuous value and a stop time defining continuous behavior with nothing set on the route.
|
Added the required test case. Thank you for the review @skalexch |
Summary:
The spec makes
trips.shape_idconditionally required: required if the trip has continuous pickup or drop-off behavior defined either inroutes.txtor instop_times.txt, optional otherwise.GtfsTripSchemaalready annotatesshapeIdas@ConditionallyRequired, but nothing enforced it.Adds
TripShapeIdConditionalValidator, which raises the existingmissing_required_fieldnotice (ERROR) ontrips.shape_idwhen such a trip has no shape. This followsTransferStopIdsConditionalValidatorandStopTimesGeographyIdPresenceValidator, which raise the generic notice under a conditional rather than defining a new notice type.Two readings, both taken from the reference:
1and empty both mean no continuous stopping behavior, so only0,2and3makeshape_idrequired.stop_timesvalues overrideroutesvalues, so the effective value for each stop time is thestop_timesvalue where set, otherwise the route value.Expected behavior:
Running the CLI on four variants of the
Archive.zipfrom #1785:routes.continuous_pickupstop_times.continuous_pickup1(as attached)1(as attached)0110missing_required_fieldontrips.txtrow 20missing_required_fieldontrips.txtrow 2Worth noting that the archive attached to the issue has
continuous_pickup=1andcontinuous_drop_off=1in every row of both files, so as attached it does not exercise the rule.8 unit tests cover the four combinations plus the shape present, no continuous behavior, and no stop times cases.
Closes #1785
Please make sure these boxes are checked before submitting your pull request - thanks!
gradle testto make sure you didn't break anything