-
Notifications
You must be signed in to change notification settings - Fork 42
WIP - Fix #154 start time of freq based trip should be immutable. #336
base: master
Are you sure you want to change the base?
Changes from 3 commits
7f21b52
95f03b1
27623ef
1e05604
4761991
0eb5739
9b93487
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,8 @@ | |
| package edu.usf.cutr.gtfsrtvalidator.lib.validation.rules; | ||
|
|
||
| import com.google.transit.realtime.GtfsRealtime; | ||
| import com.google.transit.realtime.GtfsRealtime.TripUpdate; | ||
|
|
||
| import edu.usf.cutr.gtfsrtvalidator.lib.model.MessageLogModel; | ||
| import edu.usf.cutr.gtfsrtvalidator.lib.model.OccurrenceModel; | ||
| import edu.usf.cutr.gtfsrtvalidator.lib.model.helper.ErrorListHelperModel; | ||
|
|
@@ -27,6 +29,7 @@ | |
| import org.slf4j.LoggerFactory; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.HashMap; | ||
| import java.util.List; | ||
|
|
||
| import static edu.usf.cutr.gtfsrtvalidator.lib.validation.ValidationRules.*; | ||
|
|
@@ -41,17 +44,21 @@ | |
| public class FrequencyTypeZeroValidator implements FeedEntityValidator { | ||
|
|
||
| private static final org.slf4j.Logger _log = LoggerFactory.getLogger(FrequencyTypeZeroValidator.class); | ||
|
|
||
|
|
||
|
|
||
|
|
||
| @Override | ||
| public List<ErrorListHelperModel> validate(long currentTimeMillis, GtfsMutableDao gtfsData, GtfsMetadata gtfsMetadata, GtfsRealtime.FeedMessage feedMessage, GtfsRealtime.FeedMessage previousFeedMessage, GtfsRealtime.FeedMessage combinedFeedMessage) { | ||
| List<OccurrenceModel> errorListE006 = new ArrayList<>(); | ||
| List<OccurrenceModel> errorListE013 = new ArrayList<>(); | ||
| List<OccurrenceModel> errorListW005 = new ArrayList<>(); | ||
| List<OccurrenceModel> errorListE053 = new ArrayList<>(); | ||
|
|
||
| for (GtfsRealtime.FeedEntity entity : feedMessage.getEntityList()) { | ||
| if (entity.hasTripUpdate()) { | ||
|
|
||
| GtfsRealtime.TripUpdate tripUpdate = entity.getTripUpdate(); | ||
|
|
||
| if (gtfsMetadata.getExactTimesZeroTripIds().contains(tripUpdate.getTrip().getTripId())) { | ||
| /** | ||
| * NOTE - W006 checks for missing trip_ids, because we can't check for that here - we need the trip_id to know if it's exact_times=0 | ||
|
|
@@ -75,9 +82,34 @@ public List<ErrorListHelperModel> validate(long currentTimeMillis, GtfsMutableDa | |
| // W005 - Missing vehicle_id in trip_update for frequency-based exact_times = 0 | ||
| RuleUtils.addOccurrence(W005, "trip_id " + tripUpdate.getTrip().getTripId(), errorListW005, _log); | ||
| } | ||
| if(previousFeedMessage!=null) | ||
| { | ||
| for (GtfsRealtime.FeedEntity previousEntity : previousFeedMessage.getEntityList()) | ||
|
||
| { | ||
| if (previousEntity.hasTripUpdate()) | ||
| { | ||
| if(tripUpdate.getVehicle()!=null && previousEntity.getTripUpdate().getVehicle()!=null) | ||
scrudden marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| { | ||
| if(previousEntity.getTripUpdate().getVehicle().getId().equals(tripUpdate.getVehicle().getId())) | ||
| { | ||
| if(tripUpdate.getStopTimeUpdateCount()>0 && previousEntity.getTripUpdate().getStopTimeUpdateCount()>0) | ||
| { | ||
| if(tripUpdate.getStopTimeUpdate(tripUpdate.getStopTimeUpdateCount()-1).getStopSequence()>=previousEntity.getTripUpdate().getStopTimeUpdate(previousEntity.getTripUpdate().getStopTimeUpdateCount()-1).getStopSequence()) | ||
|
||
| { | ||
| // E053 - start time of trip not consistent for trip updates for frequency-based exact_times = 0 | ||
| if(!tripUpdate.getTrip().getStartTime().equals(previousEntity.getTripUpdate().getTrip().getStartTime())) | ||
| { | ||
| RuleUtils.addOccurrence(E053, "vehicle_id " + tripUpdate.getVehicle().getId(), errorListE053, _log); | ||
scrudden marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because a VehiclePositions feed can contain a TripDescriptor too, we should also check for this same rule within the below See There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thinking more, I think you'd need the |
||
| if (entity.hasVehicle()) { | ||
| GtfsRealtime.VehiclePosition vehiclePosition = entity.getVehicle(); | ||
| if (vehiclePosition.hasTrip() && | ||
|
|
@@ -119,6 +151,9 @@ public List<ErrorListHelperModel> validate(long currentTimeMillis, GtfsMutableDa | |
| if (!errorListW005.isEmpty()) { | ||
| errors.add(new ErrorListHelperModel(new MessageLogModel(W005), errorListW005)); | ||
| } | ||
| if (!errorListE053.isEmpty()) { | ||
| errors.add(new ErrorListHelperModel(new MessageLogModel(E053), errorListE053)); | ||
| } | ||
| return errors; | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.