time = updatedStopTime.arrival_time; if (stopTimeUpdate.hasDeparture()) { delay = stopTimeUpdate.getDeparture().getDelay();
if (stopTimeUpdate.hasDeparture() && stopTimeUpdate.getDeparture().hasTime()) { final Long time = stopTimeUpdate.getDeparture().getTime(); if (previousTime != null && previousTime > time) { LOG.warn("Trip update contains decreasing times, skipping.");
StopTimeEvent departure = update.getDeparture(); if (departure.hasDelay()) { delay = departure.getDelay();
if (stopTimeUpdate.getDeparture().hasTime()) { departureTime = stopTimeUpdate.getDeparture().getTime(); departureTimeText = TimestampUtils.posixToClock(departureTime, gtfsMetadata.getTimeZone());
update.getTrip().getTripId(), update.getVehicle().getId(), new Date(stopTime.getDeparture().getTime()*1000) , new Date(feed.getHeader().getTimestamp()*1000), false,
if (stu.getDeparture() != null) { if (stu.getDeparture().hasDelay()) { stum.setDepartureDelay(stu.getDeparture().getDelay()); if (stu.getDeparture().hasTime()) { stum.setDepartureTime(new Date(stu.getDeparture().getTime() * 1000)); if (stu.getDeparture().hasUncertainty()) { stum.setDepartureUncertainty(stu.getDeparture().getUncertainty());
/** * 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 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); } }
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; }
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) { LOG.warn("ADDED trip has invalid departure time (compared to start date in "
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; }