int stopSequenceCeiling = Math.max(stopTimeUpdateListWithSentinel.isEmpty() ? 0 : stopTimeUpdateListWithSentinel.get(stopTimeUpdateListWithSentinel.size() - 1).getStopSequence(), StreamSupport.stream(interpolatedStopTimesForTrip.spliterator(), false).mapToInt(stopTime -> stopTime.stop_sequence).max().orElse(0) ) + 1; for (GtfsRealtime.TripUpdate.StopTimeUpdate stopTimeUpdate : stopTimeUpdateListWithSentinel) { int nextStopSequence = stopTimes.isEmpty() ? 1 : stopTimes.get(stopTimes.size()-1).stop_sequence+1; for (int i=nextStopSequence; i<stopTimeUpdate.getStopSequence(); i++) { StopTime previousOriginalStopTime = feed.stop_times.get(new Fun.Tuple2(tripUpdate.getTrip().getTripId(), i)); if (previousOriginalStopTime == null) { final StopTime originalStopTime = feed.stop_times.get(new Fun.Tuple2(tripUpdate.getTrip().getTripId(), stopTimeUpdate.getStopSequence())); if (originalStopTime != null) { StopTime updatedStopTime = originalStopTime.clone(); logger.trace("stop_sequence {} scheduled arrival {} updated arrival {}", stopTimeUpdate.getStopSequence(), originalStopTime.arrival_time, updatedStopTime.arrival_time); time = updatedStopTime.arrival_time; if (stopTimeUpdate.hasDeparture()) { logger.trace("stop_sequence {} scheduled departure {} updated departure {}", stopTimeUpdate.getStopSequence(), originalStopTime.departure_time, updatedStopTime.departure_time); time = updatedStopTime.departure_time; stopTimes.add(updatedStopTime); logger.trace("Number of stop times: {}", stopTimes.size()); if (stopTimeUpdate.getScheduleRelationship() == SKIPPED) { cancelledArrivals.add(stopTimeUpdate.getStopSequence()); cancelledDepartures.add(stopTimeUpdate.getStopSequence()); stopTime.stop_sequence = stopTimeUpdate.getStopSequence(); stopTime.stop_id = stopTimeUpdate.getStopId(); stopTime.trip_id = trip.trip_id;
final Integer stopSequence = stopTimeUpdate.getStopSequence();
.map(stopTimeUpdate -> { final StopTime stopTime = new StopTime(); stopTime.stop_sequence = stopTimeUpdate.getStopSequence(); stopTime.stop_id = stopTimeUpdate.getStopId(); stopTime.trip_id = trip.trip_id;
String previousDepartureTimeText = null; for (GtfsRealtime.TripUpdate.StopTimeUpdate stopTimeUpdate : stopTimeUpdates) { String stopDescription = stopTimeUpdate.hasStopSequence() ? " stop_sequence " + stopTimeUpdate.getStopSequence() : " stop_id " + stopTimeUpdate.getStopId(); Long arrivalTime = null; String arrivalTimeText;
checkE037(entity, previousRtStopId, stopTimeUpdate, e037List); previousRtStopSequence = stopTimeUpdate.getStopSequence(); previousRtStopId = stopTimeUpdate.getStopId(); if (stopTimeUpdate.hasStopSequence()) { rtStopSequenceList.add(stopTimeUpdate.getStopSequence()); boolean foundStopId = false; if (stopTimeUpdate.hasStopSequence()) { if (gtfsStopSequence == stopTimeUpdate.getStopSequence()) { RuleUtils.addOccurrence(ValidationRules.E051, "GTFS-rt " + GtfsUtils.getTripId(entity, tripUpdate) + " contains stop_sequence " + stopTimeUpdate.getStopSequence(), e051List, _log);
tpr.setTimepointScheduledTime(instance.getServiceDate() + stopTime.getArrivalTime() * 1000); if (stopTimeUpdate.hasStopSequence()) { tpr.setStopSequence(stopTimeUpdate.getStopSequence());
int stopSequence = stopTimeUpdate.getStopSequence();
StopTimeUpdateModel stum = new StopTimeUpdateModel(); if (stu.hasStopSequence()) { stum.setStopSequence(stu.getStopSequence());
/** * Checks E037 - if the provided previousStopId value is the same as the current stopTimeUpdate stop_id it adds * an error to the provided error list. * * @param entity entity that the stopTimeUpdate is from * @param previousStopId the stop_id for the previous StopTimeUpdate * @param stopTimeUpdate the current stopTimeUpdate * @param errors the list to add the errors to */ private void checkE037(GtfsRealtime.FeedEntity entity, String previousStopId, GtfsRealtime.TripUpdate.StopTimeUpdate stopTimeUpdate, List<OccurrenceModel> errors) { if (!previousStopId.isEmpty() && stopTimeUpdate.hasStopId() && previousStopId.equals(stopTimeUpdate.getStopId())) { String id = GtfsUtils.getTripId(entity, entity.getTripUpdate()); StringBuilder prefix = new StringBuilder(); prefix.append(id); prefix.append(" has repeating stop_id "); prefix.append(previousStopId); if (stopTimeUpdate.hasStopSequence()) { prefix.append(" at stop_sequence "); prefix.append(stopTimeUpdate.getStopSequence()); } RuleUtils.addOccurrence(ValidationRules.E037, prefix.toString(), errors, _log); } }
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 E045 "GTFS-rt stop_time_update stop_sequence and stop_id do not match 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 gtfsStopSequence the stop_sequence from the GTFS stop_times.txt data * @param stop the GTFS stop that is paired with the provided gtfsStopSequence, using stop_id from the same record in stop_times.txt * @param errors the list to add the errors to */ private void checkE045(GtfsRealtime.FeedEntity entity, GtfsRealtime.TripUpdate tripUpdate, GtfsRealtime.TripUpdate.StopTimeUpdate stopTimeUpdate, int gtfsStopSequence, Stop stop, List<OccurrenceModel> errors) { if (stopTimeUpdate.hasStopId() && !stop.getId().getId().equals(stopTimeUpdate.getStopId())) { String tripId = "GTFS-rt " + GtfsUtils.getTripId(entity, tripUpdate) + " "; String stopSequence = "stop_sequence " + stopTimeUpdate.getStopSequence(); String stopId = "stop_id " + stopTimeUpdate.getStopId(); String gtfsSummary = " but GTFS stop_sequence " + gtfsStopSequence + " has stop_id " + stop.getId().getId(); RuleUtils.addOccurrence(ValidationRules.E045, tripId + stopSequence + " has " + stopId + gtfsSummary, errors, _log); } }
/** * Checks E036 - if the provided previousStopSequence value is the same as the current stopTimeUpdate stop_sequence * it adds an error to the provided error list. * * @param entity entity that the stopTimeUpdate is from * @param previousStopSequence the stop_sequence for the previous StopTimeUpdate * @param stopTimeUpdate the current stopTimeUpdate * @param errors the list to add the errors to */ private void checkE036(GtfsRealtime.FeedEntity entity, Integer previousStopSequence, GtfsRealtime.TripUpdate.StopTimeUpdate stopTimeUpdate, List<OccurrenceModel> errors) { if (stopTimeUpdate.hasStopSequence() && previousStopSequence == stopTimeUpdate.getStopSequence()) { String id = GtfsUtils.getTripId(entity, entity.getTripUpdate()); RuleUtils.addOccurrence(ValidationRules.E036, id + " has repeating stop_sequence " + previousStopSequence, errors, _log); } }
/** * Returns the stop_sequence for the given StopTimeUpdate if one exists, if not the stop_id is returned in the format * "stop_sequence 1234" or "stop_id 9876". * * @param stopTimeUpdate the stop_time_update to generate the stop_sequence or stop_id text from * @return the stop_sequence for the given StopTimeUpdate if one exists, if not the stop_id is returned in the format"stop_sequence 1234" or "stop_id 9876". */ public static String getStopTimeUpdateId(GtfsRealtime.TripUpdate.StopTimeUpdate stopTimeUpdate) { if (stopTimeUpdate.hasStopSequence()) { return "stop_sequence " + stopTimeUpdate.getStopSequence(); } else { return "stop_id " + stopTimeUpdate.getStopId(); } }
if (update != null) { if (update.hasStopSequence()) { match = update.getStopSequence() == newTimes.getStopSequence(i); } else if (update.hasStopId()) { match = pattern.getStop(i).getId().getId().equals(update.getStopId());
stopTime.setStopSequence(stopTimeUpdate.getStopSequence());
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; }