Skip to content

Commit c1b3b23

Browse files
committed
fix(validator): add missing stop_times validation items
Check that timepoints have times and that a stop time without pickup/drop off is a timepoint (otherwise it has no purpose) re #167
1 parent 60124ee commit c1b3b23

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/main/java/com/conveyal/gtfs/error/NewGTFSErrorType.java

+2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ public enum NewGTFSErrorType {
5050
STOP_LOW_POPULATION_DENSITY(Priority.HIGH, "A stop is located in a geographic area with very low human population density."),
5151
STOP_NAME_MISSING(Priority.MEDIUM, "A stop does not have a name."),
5252
STOP_GEOGRAPHIC_OUTLIER(Priority.HIGH, "This stop is located very far from the middle 90% of stops in this feed."),
53+
STOP_TIME_UNUSED(Priority.LOW, "This stop time allows neither pickup nor drop off and is not a timepoint, so it serves no purpose and should be removed from trip."),
5354
STOP_UNUSED(Priority.MEDIUM, "This stop is not referenced by any trips."),
55+
TIMEPOINT_MISSING_TIMES(Priority.MEDIUM, "This stop time is marked as a timepoint, but is missing both arrival and departure times."),
5456
TRIP_EMPTY(Priority.HIGH, "This trip is defined but has no stop times."),
5557
TRIP_HEADSIGN_CONTAINS_ROUTE_NAME(Priority.LOW, "A trip headsign contains the route name, but should only contain information to distinguish it from other trips for the route."),
5658
TRIP_HEADSIGN_SHOULD_DESCRIBE_DESTINATION_OR_WAYPOINTS(Priority.LOW, "A trip headsign begins with 'to' or 'towards', but should begin with destination or direction and optionally include waypoints with 'via'"),

src/main/java/com/conveyal/gtfs/validator/SpeedTripValidator.java

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.conveyal.gtfs.validator;
22

33
import com.conveyal.gtfs.error.NewGTFSError;
4+
import com.conveyal.gtfs.error.NewGTFSErrorType;
45
import com.conveyal.gtfs.error.SQLErrorStorage;
56
import com.conveyal.gtfs.loader.Feed;
67
import com.conveyal.gtfs.model.Entity;
@@ -47,14 +48,20 @@ public void validateTrip(Trip trip, Route route, List<StopTime> stopTimes, List<
4748
double distanceMeters = 0;
4849
for (int i = beginIndex + 1; i < stopTimes.size(); i++) {
4950
StopTime currStopTime = stopTimes.get(i);
51+
if (currStopTime.pickup_type == 1 && currStopTime.drop_off_type == 1 && currStopTime.timepoint == 0) {
52+
// stop_time allows neither pickup or drop off and is not a timepoint, so it serves no purpose.
53+
registerError(currStopTime, NewGTFSErrorType.STOP_TIME_UNUSED);
54+
}
5055
Stop currStop = stops.get(i);
5156
// Distance is accumulated in case times are not provided for some StopTimes.
5257
distanceMeters += fastDistance(currStop.stop_lat, currStop.stop_lon, prevStop.stop_lat, prevStop.stop_lon);
5358
// Check that shape_dist_traveled is increasing.
5459
checkShapeDistTraveled(prevStopTime, currStopTime);
5560
if (missingBothTimes(currStopTime)) {
5661
// FixMissingTimes has already been called, so both arrival and departure time are missing.
57-
// The spec allows this. Other than accumulating distance, skip this StopTime.
62+
// The spec allows this. Other than accumulating distance, skip this StopTime. If this stop_time serves
63+
// as a timepoint; however, this is considered an error.
64+
if (currStopTime.timepoint == 1) registerError(currStopTime, NewGTFSErrorType.TIMEPOINT_MISSING_TIMES);
5865
continue;
5966
}
6067
if (currStopTime.departure_time < currStopTime.arrival_time) {

0 commit comments

Comments
 (0)