Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ public void validate(NoticeContainer noticeContainer) {
}

double maxShapeDist = maxShape.shapeDistTraveled();

if (maxShapeDist == 0) {
return;
}

double distanceInMeters =
getDistanceMeters(maxShape.shapePtLatLon(), stop.stopLatLon());
if (maxStopTimeDist > maxShapeDist) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,24 @@ public void testTripDistanceExceedsShapeDistance() {
assertThat(found).isTrue();
}

@Test
public void testTripDistanceExceedsShapeDistanceNoShapeDistance() {
List<ValidationNotice> notices =
generateNotices(
createTripTable(2),
createStopTimesTable(1, 10.0),
Copy link
Contributor

@jcpitre jcpitre Apr 22, 2025

Choose a reason for hiding this comment

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

I think this will not really test your change. You want to set test data that would normally create a notice but will not because shapeTable.shapeDistTraveled is 0 (please correct me if I am wrong).
But to generate a notice you need the distance to be at least 11.1 meters. And this test sets the distance to 10 meters. So the test as it is now will not generate notices, because the distance falls below the threshold.

I believe that if you set createStopTimesTable(1, 100.0) (for example), it will test properly, meaning the distance is above the 11.1 meter threshold, but it will still not generate a notice because shapeTable.shapeDistTraveled is 0.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What I wanted to implement: "if ShapeDistTraveled is zero, then it does not generate notice nor warning" (because it returns early on line 89).

That's why I've tried setShapeDistTraveled(shapeDistTraveled * i) , so when shapeDistTraveled is 0, shapeDistTraveled * i is also 0 too.

I'm a bit lost about which tests currently fail. I do see job https://github.com/MobilityData/gtfs-validator/actions/runs/14531693846/job/40961320600?pr=2020 failed, but can't find where.

I'll revert my change to set shapeDistTraveled + i back, but I suspect the test I've introduced will raise a notice, instead of returning without any notice/warning.

Feel free to push changes on my PR to fix it! I don't mind at all (and will learn a bit about Java :-)

createShapeTable(1, 0.0, 10.0),
createStopTable(1));
boolean found =
notices.stream()
.anyMatch(
notice ->
notice
instanceof
TripAndShapeDistanceValidator.TripDistanceExceedsShapeDistanceNotice);
assertThat(found).isFalse();
}

@Test
public void testTripDistanceExceedsShapeDistanceWarning() {
List<ValidationNotice> notices =
Expand Down
Loading