feat: Add shapes.txt validator#2123
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new validator intended to warn when shapes.txt is missing unless the feed appears to use zone-based or fixed-stop DRT (per #1792).
Changes:
- Introduces
MissingShapesFileValidatorand a corresponding test class. - Adds unit tests covering shapes present + DRT present scenarios (and a no-shapes/no-DRT scenario).
- Adds an extra import in
ShapeUsageValidator.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 9 comments.
| File | Description |
|---|---|
| main/src/main/java/org/mobilitydata/gtfsvalidator/validator/MissingShapesFileValidator.java | New multi-file validator for warning on missing shapes.txt unless DRT indicators are present. |
| main/src/test/java/org/mobilitydata/gtfsvalidator/validator/MissingShapesFileValidatorTest.java | New unit tests for the validator behavior. |
| main/src/main/java/org/mobilitydata/gtfsvalidator/validator/ShapeUsageValidator.java | Adds an import for a nested notice type. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
i'm a bit stuck as to why the test failure is happening |
| } | ||
|
|
||
| @Override | ||
| public void validate(NoticeContainer noticeContainer) { |
There was a problem hiding this comment.
[Suggestion] Reuse FeedMetadata logic instead of re-implementing it
The DRT detection logic already exists in FeedMetadata:
- hasAtLeastOneTripWithOnlyLocationId(), zone-based DRT check
- hasAtLeastOneTripWithOnlyLocationGroupId() + hasAtLeastOneRecordInFile(), fixed-stops DRT check (mirrors loadFixedStopsDemandResponseTransit)
To reuse them in MissingShapesFileValidator, these three methods need to be made public static and their signatures updated to accept the individual table containers directly (e.g. GtfsStopTimeTableContainer and GtfsLocationGroupsTableContainer).
This avoids duplicating the DRT detection logic and ensures the validator stays consistent with how features are detected elsewhere in the codebase. It would also make the validate() method read clearly:
boolean hasZoneBasedDrt = FeedMetadata.hasAtLeastOneTripWithOnlyLocationId(stopTimeTable);
boolean hasFixedStopsDrt = FeedMetadata.hasAtLeastOneRecordInFile(locationGroupsTable)
&& FeedMetadata.hasAtLeastOneTripWithOnlyLocationGroupId(stopTimeTable);
if (shapeTable.isMissingFile() && !hasZoneBasedDrt && !hasFixedStopsDrt) {
noticeContainer.addValidationNotice(new MissingRecommendedFileNotice("shapes.txt"));
}
Alternative: add hasZoneBasedDemandResponseService and hasFixedStopsDemandResponseService to FeedMetadata
There was a problem hiding this comment.
in order to update the signatures to accept table containers directly, do I extend GtfsEntityContainer or GtfsTableContainer? i'm unclear on how much abstraction is in play here
There was a problem hiding this comment.
There is no need to raise the abstraction level. Most of the changes involve visibility (private -> public) and making some methods static. I quickly went through your latest commit, and it seems you are on the right track.
There was a problem hiding this comment.
what I meant to say is that I'm not exactly clear on what the method signatures should be updated to.. :(
Summary:
Add validator that checks if either a shapes.txt and/or a fixed or zone-based DRT service is present (as per #1792)
DRT functionality added as per this reference
Fixes #1792
Expected behavior:
Validator will print WARNING if shapes.txt and signs of a DRT feature are not found.
Please make sure these boxes are checked before submitting your pull request - thanks!
gradle testto make sure you didn't break anything