Skip to content

Commit 7077368

Browse files
fix: update TripAndShapeDistanceValidator to ignore shape with no shape_dist_traveled (#2018)
Some GTFS feeds do not provide shape_dist_traveled in shapes.txt In this case, the value is set to 0 in the code, so sorting shapes based on ShapeDistTraveled does not work and usually returns the first shape row. It leads to an error, the first shape of the shape is usually very far away from the last stop of the trips following the shape. We can assume the biggest shape_dist_traveled of a given shape should never be 0, otherwise it means the value is not set. In this case, we return early to ensure no validation error will be issued. Fixes #2018
1 parent f1174bd commit 7077368

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

main/src/main/java/org/mobilitydata/gtfsvalidator/validator/TripAndShapeDistanceValidator.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ public void validate(NoticeContainer noticeContainer) {
8484
}
8585

8686
double maxShapeDist = maxShape.shapeDistTraveled();
87+
88+
if (maxShapeDist == 0) {
89+
return;
90+
}
91+
8792
double distanceInMeters =
8893
getDistanceMeters(maxShape.shapePtLatLon(), stop.stopLatLon());
8994
if (maxStopTimeDist > maxShapeDist) {

0 commit comments

Comments
 (0)