.forEach(tripUpdate -> { Collection<Frequency> frequencies = feed.getFrequencies(tripUpdate.getTrip().getTripId()); int timeOffset = (tripUpdate.getTrip().hasStartTime() && !frequencies.isEmpty()) ? LocalTime.parse(tripUpdate.getTrip().getStartTime()).toSecondOfDay() : 0; String key = GtfsStorage.tripKey(tripUpdate.getTrip(), !frequencies.isEmpty()); final int[] boardEdges = staticGtfs.getBoardEdgesForTrip().get(key);
int time = TimeToStringConverter.parseHH_MM_SS(trip.getStartTime()); ServiceDate date; try {
/** * Checks rule E023 - "start_time does not match GTFS initial arrival_time", and adds any errors that are found to the provided error list * * @param entity The VehiclePosition or TripUpdate that contains the data to be evaluated for rule E023 * @param trip The TripDescriptor be evaluated for rule E023 * @param errors list to add any errors for E023 to */ private void checkE023(Object entity, GtfsRealtime.TripDescriptor trip, GtfsMetadata gtfsMetadata, List<OccurrenceModel> errors) { String startTime = trip.getStartTime(); String tripId = trip.getTripId(); if (tripId != null && !gtfsMetadata.getExactTimesZeroTripIds().contains(tripId) && !gtfsMetadata.getExactTimesOneTrips().containsKey(tripId)) { // Trip is a normal (not frequencies.txt) trip List<StopTime> stopTimes = gtfsMetadata.getTripStopTimes().get(tripId); if (stopTimes == null || stopTimes.isEmpty()) { // There isn't a trip in GTFS trips.txt for this trip, or it doesn't have any records in GTFS stop_times.txt return; } int firstArrivalTime = stopTimes.get(0).getArrivalTime(); String formattedArrivalTime = TimestampUtils.secondsAfterMidnightToClock(firstArrivalTime); if (!startTime.equals(formattedArrivalTime)) { String prefix = "GTFS-rt " + GtfsUtils.getVehicleAndTripIdText(entity) + " start_time is " + startTime + " and GTFS initial arrival_time is " + formattedArrivalTime; RuleUtils.addOccurrence(E023, prefix, errors, _log); } } }
_log.debug("start time = " + startTime); _log.debug("formatted start time = " + gtfsStartTimeString); if (tripUpdate.getTrip().getStartTime().equals(gtfsStartTimeString)) { " has start_time of " + tripUpdate.getTrip().getStartTime() + " and GTFS frequencies.txt start_time is " + gtfsStartTimeString + " with a headway of " + headwaySecs + " seconds "; RuleUtils.addOccurrence(E019, prefix, errorListE019, _log); _log.debug("start time = " + startTime); _log.debug("formatted start time = " + gtfsStartTimeString); if (vehiclePosition.hasTrip() && vehiclePosition.getTrip().getStartTime().equals(gtfsStartTimeString)) { " has start_time of " + vehiclePosition.getTrip().getStartTime() + " and GTFS frequencies.txt start_time is " + gtfsStartTimeString + " with a headway of " + headwaySecs + " seconds "; RuleUtils.addOccurrence(E019, prefix, errorListE019, _log);
vpm.setTripStart(GtfsRealtimeConversionLibrary.parseDate(td.getStartDate(), td.getStartTime()));
if (trip.hasStartTime() && !"0".equals(trip.getStartTime())) { try { tripStartTime = StopTimeFieldMappingFactory.getStringAsSeconds(trip.getStartTime()); } catch (InvalidStopTimeException iste) { _log.error("invalid stopTime of " + trip.getStartTime() + " for trip " + trip);
tu.setTripStart(GtfsRealtimeConversionLibrary.parseDate(t.getStartDate(), t.getStartTime()));
esm.setTripStartTime(t.getStartTime());
/** * <code>optional string start_time = 2;</code> * * <pre> * The initially scheduled start time of this trip instance. * When the trip_id corresponds to a non-frequency-based trip, this field * should either be omitted or be equal to the value in the GTFS feed. When * the trip_id correponds to a frequency-based trip, the start_time must be * specified for trip updates and vehicle positions. If the trip corresponds * to exact_times=1 GTFS record, then start_time must be some multiple * (including zero) of headway_secs later than frequencies.txt start_time for * the corresponding time period. If the trip corresponds to exact_times=0, * then its start_time may be arbitrary, and is initially expected to be the * first departure of the trip. Once established, the start_time of this * frequency-based trip should be considered immutable, even if the first * departure time changes -- that time change may instead be reflected in a * StopTimeUpdate. * Format and semantics of the field is same as that of * GTFS/frequencies.txt/start_time, e.g., 11:15:35 or 25:15:35. * </pre> */ public Builder clearStartTime() { bitField0_ = (bitField0_ & ~0x00000008); startTime_ = getDefaultInstance().getStartTime(); onChanged(); return this; } /**
/** * Checks rule E020 - "Invalid start_time format", and adds any errors that are found to the provided error list * * @param entity The VehiclePosition or TripUpdate that contains the data to be evaluated for rule E020 * @param trip The TripDescriptor be evaluated for rule E020 * @param errors list to add any errors for E020 to */ private void checkE020(Object entity, GtfsRealtime.TripDescriptor trip, List<OccurrenceModel> errors) { String startTime = trip.getStartTime(); if (!TimestampUtils.isValidTimeFormat(startTime)) { RuleUtils.addOccurrence(E020, GtfsUtils.getVehicleAndTripIdText(entity) + " start_time is " + startTime, errors, _log); } }
/** * <code>optional string start_time = 2;</code> * * <pre> * The initially scheduled start time of this trip instance. * When the trip_id corresponds to a non-frequency-based trip, this field * should either be omitted or be equal to the value in the GTFS feed. When * the trip_id correponds to a frequency-based trip, the start_time must be * specified for trip updates and vehicle positions. If the trip corresponds * to exact_times=1 GTFS record, then start_time must be some multiple * (including zero) of headway_secs later than frequencies.txt start_time for * the corresponding time period. If the trip corresponds to exact_times=0, * then its start_time may be arbitrary, and is initially expected to be the * first departure of the trip. Once established, the start_time of this * frequency-based trip should be considered immutable, even if the first * departure time changes -- that time change may instead be reflected in a * StopTimeUpdate. * Format and semantics of the field is same as that of * GTFS/frequencies.txt/start_time, e.g., 11:15:35 or 25:15:35. * </pre> */ public Builder clearStartTime() { bitField0_ = (bitField0_ & ~0x00000008); startTime_ = getDefaultInstance().getStartTime(); onChanged(); return this; } /**
static String tripKey(GtfsRealtime.TripDescriptor tripDescriptor, boolean isFrequencyBased) { if (isFrequencyBased) { return tripDescriptor.getTripId()+tripDescriptor.getStartTime(); } else { return tripDescriptor.getTripId(); } }