delay = stopTimeUpdate.getArrival().getDelay(); stopTime.stop_id = stopTimeUpdate.getStopId(); stopTime.trip_id = trip.trip_id; final ZonedDateTime arrival_time = Instant.ofEpochSecond(stopTimeUpdate.getArrival().getTime()).atZone(timezone); stopTime.arrival_time = (int) Duration.between(arrival_time.truncatedTo(ChronoUnit.DAYS), arrival_time).getSeconds(); final ZonedDateTime departure_time = Instant.ofEpochSecond(stopTimeUpdate.getArrival().getTime()).atZone(timezone); stopTime.departure_time = (int) Duration.between(departure_time.truncatedTo(ChronoUnit.DAYS), departure_time).getSeconds(); stopTimes.add(stopTime);
if (stopTimeUpdate.hasArrival() && stopTimeUpdate.getArrival().hasTime()) { final Long time = stopTimeUpdate.getArrival().getTime(); if (previousTime != null && previousTime > time) { LOG.warn("Trip update contains decreasing times, skipping.");
stopTime.stop_id = stopTimeUpdate.getStopId(); stopTime.trip_id = trip.trip_id; final ZonedDateTime arrival_time = Instant.ofEpochSecond(stopTimeUpdate.getArrival().getTime()).atZone(timezone); stopTime.arrival_time = (int) Duration.between(arrival_time.truncatedTo(ChronoUnit.DAYS), arrival_time).getSeconds(); final ZonedDateTime departure_time = Instant.ofEpochSecond(stopTimeUpdate.getArrival().getTime()).atZone(timezone); stopTime.departure_time = (int) Duration.between(departure_time.truncatedTo(ChronoUnit.DAYS), departure_time).getSeconds(); return stopTime;
String departureTimeText; if (stopTimeUpdate.hasArrival()) { if (stopTimeUpdate.getArrival().hasTime()) { arrivalTime = stopTimeUpdate.getArrival().getTime(); arrivalTimeText = TimestampUtils.posixToClock(arrivalTime, gtfsMetadata.getTimeZone()); RuleUtils.addOccurrence(E022, prefix, e022List, _log); if (stopTimeUpdate.getArrival().hasTime() && departureTime < stopTimeUpdate.getArrival().getTime()) { TimestampUtils.posixToClock(stopTimeUpdate.getArrival().getTime(), gtfsMetadata.getTimeZone()) + " (" + stopTimeUpdate.getArrival().getTime() + ")"; RuleUtils.addOccurrence(E025, prefix, e025List, _log);
+ "stopId={}, prediction={}, isArrival={}", update.getTrip().getRouteId(), direction, update.getTrip().getTripId(), update.getVehicle().getId(), stopTime.getStopId(), new Date(stopTime.getArrival().getTime()*1000), true); logger.info("Prediction in milliseonds is {} and converted is {}",stopTime.getArrival().getTime()*1000, new Date(stopTime.getArrival().getTime()*1000)); update.getTrip().getTripId(), update.getVehicle().getId(), new Date(stopTime.getArrival().getTime()*1000) , new Date(feed.getHeader().getTimestamp()*1000), true,
stum.setStopId(stu.getStopId()); if (stu.getArrival() != null) { if (stu.getArrival().hasDelay()) { stum.setArrivalDelay(stu.getArrival().getDelay()); if (stu.getArrival().hasTime()) { stum.setArrivalTime(new Date(stu.getArrival().getTime() * 1000)); if (stu.getArrival().hasUncertainty()) { stum.setArrivalUncertainty(stu.getArrival().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 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; }
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; }
/** * 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 computeArrivalTime(StopTimeEntry stopTime, StopTimeUpdate stopTimeUpdate, long serviceDate) { if (!stopTimeUpdate.hasArrival()) return -1; StopTimeEvent arrival = stopTimeUpdate.getArrival(); if (arrival.hasDelay()) return stopTime.getArrivalTime() + arrival.getDelay(); if (arrival.hasTime()) return (int) (arrival.getTime() - serviceDate / 1000); // instead of illegal state exception we return -1 to not corrupt the read return -1; }
StopTimeEvent arrival = update.getArrival(); if (arrival.hasDelay()) { delay = arrival.getDelay();
stopTime.setStop(stop); if (stopTimeUpdate.hasArrival() && stopTimeUpdate.getArrival().hasTime()) { final long arrivalTime = stopTimeUpdate.getArrival().getTime() - midnightSecondsSinceEpoch; if (arrivalTime < 0 || arrivalTime > MAX_ARRIVAL_DEPARTURE_TIME) { LOG.warn("ADDED trip has invalid arrival 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; }