logger.trace("stop_sequence {} scheduled arrival {} updated arrival {}", stopTimeUpdate.getStopSequence(), originalStopTime.arrival_time, updatedStopTime.arrival_time); time = updatedStopTime.arrival_time; if (stopTimeUpdate.hasDeparture()) { delay = stopTimeUpdate.getDeparture().getDelay();
if (stopTimeUpdate.hasDeparture() && stopTimeUpdate.getDeparture().hasTime()) {
if (update.hasDeparture()) { StopTimeEvent departure = update.getDeparture(); if (departure.hasDelay()) {
if (stopTimeUpdate.hasDeparture()) { if (stopTimeUpdate.getDeparture().hasTime()) { departureTime = stopTimeUpdate.getDeparture().getTime();
for(StopTimeUpdate stopTime : stopTimes) if(stopTime.hasArrival()||stopTime.hasDeparture()) if(stopTime.hasDeparture())
/** * Checks E046 "GTFS-rt stop_time_update without time doesn't have arrival/departure_time in GTFS", and adds any errors to the provided error list. * * @param entity entity that the trip_update is from * @param tripUpdate the trip_update to examine * @param stopTimeUpdate the stop_time_update to examine * @param gtfsStopTime the entry from GTFS stop_times.txt that corresponds to the provided GTFS stopTimeUpdate * @param errors the list to add the errors to */ private void checkE046(GtfsRealtime.FeedEntity entity, GtfsRealtime.TripUpdate tripUpdate, GtfsRealtime.TripUpdate.StopTimeUpdate stopTimeUpdate, StopTime gtfsStopTime, List<OccurrenceModel> errors) { StringBuilder prefixBuilder = new StringBuilder(); prefixBuilder.append("GTFS-rt " + GtfsUtils.getTripId(entity, tripUpdate) + " "); prefixBuilder.append(GtfsUtils.getStopTimeUpdateId(stopTimeUpdate) + " "); if (stopTimeUpdate.hasArrival()) { if (!stopTimeUpdate.getArrival().hasTime() && !gtfsStopTime.isArrivalTimeSet()) { String prefix = prefixBuilder.toString() + "arrival.time"; RuleUtils.addOccurrence(ValidationRules.E046, prefix, errors, _log); } } if (stopTimeUpdate.hasDeparture()) { if (!stopTimeUpdate.getDeparture().hasTime() && !gtfsStopTime.isDepartureTimeSet()) { String prefix = prefixBuilder.toString() + "departure.time"; RuleUtils.addOccurrence(ValidationRules.E046, prefix, errors, _log); } } } }
private int getTimeForStopTimeUpdate(StopTimeUpdate stopTimeUpdate, long serviceDate) { long t = currentTime(); if (stopTimeUpdate.hasArrival()) { StopTimeEvent arrival = stopTimeUpdate.getArrival(); // note that we prefer time over delay if both are present if (arrival.hasTime()) { return (int) (arrival.getTime() - serviceDate / 1000); } if (arrival.hasDelay()) { return (int) ((t - serviceDate) / 1000 - arrival.getDelay()); } } if (stopTimeUpdate.hasDeparture()) { StopTimeEvent departure = stopTimeUpdate.getDeparture(); // again we prefer time over delay if both are present if (departure.hasTime()) return (int) (departure.getTime() - serviceDate / 1000); if (departure.hasDelay()) { return (int) ((t - serviceDate) / 1000 - departure.getDelay()); } } // instead of illegal state exception we return -1 to not corrupt the read _log.debug("expected at least an arrival or departure time or delay for update: " + stopTimeUpdate); return -1; }
public Builder mergeFrom(com.google.transit.realtime.GtfsRealtime.TripUpdate.StopTimeUpdate other) { if (other == com.google.transit.realtime.GtfsRealtime.TripUpdate.StopTimeUpdate.getDefaultInstance()) return this; if (other.hasStopSequence()) { setStopSequence(other.getStopSequence()); } if (other.hasStopId()) { bitField0_ |= 0x00000002; stopId_ = other.stopId_; onChanged(); } if (other.hasArrival()) { mergeArrival(other.getArrival()); } if (other.hasDeparture()) { mergeDeparture(other.getDeparture()); } if (other.hasScheduleRelationship()) { setScheduleRelationship(other.getScheduleRelationship()); } this.mergeExtensionFields(other); this.mergeUnknownFields(other.getUnknownFields()); return this; }
public final boolean isInitialized() { byte isInitialized = memoizedIsInitialized; if (isInitialized != -1) return isInitialized == 1; if (hasArrival()) { if (!getArrival().isInitialized()) { memoizedIsInitialized = 0; return false; } } if (hasDeparture()) { if (!getDeparture().isInitialized()) { memoizedIsInitialized = 0; return false; } } if (!extensionsAreInitialized()) { memoizedIsInitialized = 0; return false; } memoizedIsInitialized = 1; return true; }
/** * Checks E043 "stop_time_update doesn't have arrival or departure", and adds any errors to the provided error list. * * @param entity entity that the trip_update is from * @param tripUpdate the trip_update to examine * @param stopTimeUpdate the stop_time_update to examine * @param errors the list to add the errors to */ private void checkE043(GtfsRealtime.FeedEntity entity, GtfsRealtime.TripUpdate tripUpdate, GtfsRealtime.TripUpdate.StopTimeUpdate stopTimeUpdate, List<OccurrenceModel> errors) { if (!stopTimeUpdate.hasArrival() && !stopTimeUpdate.hasDeparture()) { if (stopTimeUpdate.hasScheduleRelationship() && (stopTimeUpdate.getScheduleRelationship().equals(SKIPPED) || stopTimeUpdate.getScheduleRelationship().equals(NO_DATA))) { // stop_time_updates with SKIPPED or NO_DATA aren't required to have arrival or departures - return return; } String id = GtfsUtils.getTripId(entity, tripUpdate) + " " + GtfsUtils.getStopTimeUpdateId(stopTimeUpdate); RuleUtils.addOccurrence(ValidationRules.E043, id, errors, _log); } }
private long closestTemporalUpdate(TripUpdate t) { long closest = Long.MAX_VALUE; for (StopTimeUpdate stu : t.getStopTimeUpdateList()) { if (stu.hasArrival()) { long delta = Math.abs(stu.getArrival().getTime() * 1000 - getCurrentTime()); if (delta < closest) { closest = delta; } } else if (stu.hasDeparture()) { long delta = Math.abs(stu.getDeparture().getTime() * 1000 - getCurrentTime()); if (delta < closest) { closest = delta; } } } return closest; }
/** * Checks E044 "stop_time_update arrival/departure doesn't have delay or time", and adds any errors to the provided error list. * * @param entity entity that the trip_update is from * @param tripUpdate the trip_update to examine * @param stopTimeUpdate the stop_time_update to examine * @param errors the list to add the errors to */ private void checkE044(GtfsRealtime.FeedEntity entity, GtfsRealtime.TripUpdate tripUpdate, GtfsRealtime.TripUpdate.StopTimeUpdate stopTimeUpdate, List<OccurrenceModel> errors) { if (stopTimeUpdate.hasScheduleRelationship() && stopTimeUpdate.getScheduleRelationship().equals(SKIPPED)) { // SKIPPED stop_time_updates aren't required to have delay or time (arrival/departure are optional) - see #243 return; } String id = GtfsUtils.getTripId(entity, tripUpdate) + " " + GtfsUtils.getStopTimeUpdateId(stopTimeUpdate); if (stopTimeUpdate.hasArrival()) { checkE044StopTimeEvent(stopTimeUpdate.getArrival(), id + " arrival", errors); } if (stopTimeUpdate.hasDeparture()) { checkE044StopTimeEvent(stopTimeUpdate.getDeparture(), id + " departure", errors); } }
/** * Checks E042 "arrival or departure provided for NO_DATA stop_time_update", and adds any errors to the provided error list. * * @param entity entity that the trip_update is from * @param tripUpdate the trip_update to examine * @param stopTimeUpdate the stop_time_update to examine * @param errors the list to add the errors to */ private void checkE042(GtfsRealtime.FeedEntity entity, GtfsRealtime.TripUpdate tripUpdate, GtfsRealtime.TripUpdate.StopTimeUpdate stopTimeUpdate, List<OccurrenceModel> errors) { if (stopTimeUpdate.hasScheduleRelationship() && stopTimeUpdate.getScheduleRelationship().equals(NO_DATA)) { String id = GtfsUtils.getTripId(entity, tripUpdate) + " " + GtfsUtils.getStopTimeUpdateId(stopTimeUpdate); if (stopTimeUpdate.hasArrival()) { RuleUtils.addOccurrence(ValidationRules.E042, id + " has arrival", errors, _log); } if (stopTimeUpdate.hasDeparture()) { RuleUtils.addOccurrence(ValidationRules.E042, id + " has departure", errors, _log); } } }
private int computeDepartureTime(StopTimeEntry stopTime, StopTimeUpdate stopTimeUpdate, long serviceDate) { if (!stopTimeUpdate.hasDeparture()) return -1; StopTimeEvent departure = stopTimeUpdate.getDeparture(); if (departure.hasDelay()) return stopTime.getDepartureTime() + departure.getDelay(); if (departure.hasTime()) return (int) (departure.getTime() - serviceDate / 1000); // instead of throwing an exception here, simply return -1 // so as to not stop the rest of the processing return -1; }
if (stopTimeUpdate.hasDeparture() && stopTimeUpdate.getDeparture().hasTime()) { final long departureTime = stopTimeUpdate.getDeparture().getTime() - midnightSecondsSinceEpoch; if (departureTime < 0 || departureTime > MAX_ARRIVAL_DEPARTURE_TIME) {
public Builder mergeFrom(com.google.transit.realtime.GtfsRealtime.TripUpdate.StopTimeUpdate other) { if (other == com.google.transit.realtime.GtfsRealtime.TripUpdate.StopTimeUpdate.getDefaultInstance()) return this; if (other.hasStopSequence()) { setStopSequence(other.getStopSequence()); } if (other.hasStopId()) { bitField0_ |= 0x00000002; stopId_ = other.stopId_; onChanged(); } if (other.hasArrival()) { mergeArrival(other.getArrival()); } if (other.hasDeparture()) { mergeDeparture(other.getDeparture()); } if (other.hasScheduleRelationship()) { setScheduleRelationship(other.getScheduleRelationship()); } this.mergeExtensionFields(other); this.mergeUnknownFields(other.getUnknownFields()); return this; }
public final boolean isInitialized() { byte isInitialized = memoizedIsInitialized; if (isInitialized != -1) return isInitialized == 1; if (hasArrival()) { if (!getArrival().isInitialized()) { memoizedIsInitialized = 0; return false; } } if (hasDeparture()) { if (!getDeparture().isInitialized()) { memoizedIsInitialized = 0; return false; } } if (!extensionsAreInitialized()) { memoizedIsInitialized = 0; return false; } memoizedIsInitialized = 1; return true; }