if (tripUpdate.getStopTimeUpdateCount() < 2) { LOG.warn("ADDED trip has less then two stops, skipping."); return false;
/** * Handle GTFS-RT TripUpdate message containing a MODIFIED trip. * * @param graph graph to update * @param trip trip that is modified * @param tripUpdate GTFS-RT TripUpdate message * @param stops the stops of each StopTimeUpdate in the TripUpdate message * @param feedId * @param serviceDate service date for modified trip * @return true iff successful */ private boolean handleModifiedTrip(final Graph graph, final Trip trip, final TripUpdate tripUpdate, final List<Stop> stops, final String feedId, final ServiceDate serviceDate) { // Preconditions Preconditions.checkNotNull(stops); Preconditions.checkArgument(tripUpdate.getStopTimeUpdateCount() == stops.size(), "number of stop should match the number of stop time updates"); // Cancel scheduled trip final String tripId = tripUpdate.getTrip().getTripId(); cancelScheduledTrip(feedId, tripId, serviceDate); // Check whether trip id has been used for previously ADDED/MODIFIED trip message and cancel // previously created trip cancelPreviouslyAddedTrip(feedId, tripId, serviceDate); // Add new trip final boolean success = addTripToGraphAndBuffer(feedId, graph, trip, tripUpdate, stops, serviceDate, RealTimeState.MODIFIED); return success; }
if (tripUpdate.getStopTimeUpdateCount() < 2) { LOG.warn("MODIFIED trip has less then two stops, skipping."); return false;
public final boolean isInitialized() { byte isInitialized = memoizedIsInitialized; if (isInitialized != -1) return isInitialized == 1; if (!hasTrip()) { memoizedIsInitialized = 0; return false; } if (!getTrip().isInitialized()) { memoizedIsInitialized = 0; return false; } if (hasVehicle()) { if (!getVehicle().isInitialized()) { memoizedIsInitialized = 0; return false; } } for (int i = 0; i < getStopTimeUpdateCount(); i++) { if (!getStopTimeUpdate(i).isInitialized()) { memoizedIsInitialized = 0; return false; } } if (!extensionsAreInitialized()) { memoizedIsInitialized = 0; return false; } memoizedIsInitialized = 1; return true; }
/** * Checks E041 "trip doesn't have any stop_time_updates", 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 errors the list to add the errors to */ private void checkE041(GtfsRealtime.FeedEntity entity, GtfsRealtime.TripUpdate tripUpdate, List<OccurrenceModel> errors) { if (tripUpdate.getStopTimeUpdateCount() < 1) { if (tripUpdate.hasTrip() && tripUpdate.getTrip().hasScheduleRelationship() && tripUpdate.getTrip().getScheduleRelationship().equals(GtfsRealtime.TripDescriptor.ScheduleRelationship.CANCELED)) { // No errors - the trip was canceled, so it doesn't need any stop_time_updates - return return; } RuleUtils.addOccurrence(ValidationRules.E041, GtfsUtils.getTripId(entity, tripUpdate), errors, _log); } }
Preconditions.checkArgument(tripUpdate.getStopTimeUpdateCount() == stops.size(), "number of stop should match the number of stop time updates"); final List<StopTime> stopTimes = new ArrayList<>(tripUpdate.getStopTimeUpdateCount()); for (int index = 0; index < tripUpdate.getStopTimeUpdateCount(); ++index) { final StopTimeUpdate stopTimeUpdate = tripUpdate.getStopTimeUpdate(index); final Stop stop = stops.get(index); if (index == tripUpdate.getStopTimeUpdateCount() - 1) { stopTime.setPickupType(1); // No pickup available } else {
uIndex, tripUpdate.getStopTimeUpdateCount()); LOG.trace("{}", tripUpdate);
Preconditions.checkArgument(tripUpdate.getStopTimeUpdateCount() == stops.size(), "number of stop should match the number of stop time updates");
public final boolean isInitialized() { byte isInitialized = memoizedIsInitialized; if (isInitialized != -1) return isInitialized == 1; if (!hasTrip()) { memoizedIsInitialized = 0; return false; } if (!getTrip().isInitialized()) { memoizedIsInitialized = 0; return false; } if (hasVehicle()) { if (!getVehicle().isInitialized()) { memoizedIsInitialized = 0; return false; } } for (int i = 0; i < getStopTimeUpdateCount(); i++) { if (!getStopTimeUpdate(i).isInitialized()) { memoizedIsInitialized = 0; return false; } } if (!extensionsAreInitialized()) { memoizedIsInitialized = 0; return false; } memoizedIsInitialized = 1; return true; }
private boolean handleScheduledTrip(final TripUpdate tripUpdate, final String feedId, final ServiceDate serviceDate) { final TripDescriptor tripDescriptor = tripUpdate.getTrip(); // This does not include Agency ID or feed ID, trips are feed-unique and we currently assume a single static feed. final String tripId = tripDescriptor.getTripId(); final TripPattern pattern = getPatternForTripId(feedId, tripId); if (pattern == null) { LOG.warn("No pattern found for tripId {}, skipping TripUpdate.", tripId); return false; } if (tripUpdate.getStopTimeUpdateCount() < 1) { LOG.warn("TripUpdate contains no updates, skipping."); return false; } // Apply update on the *scheduled* time table and set the updated trip times in the buffer final TripTimes updatedTripTimes = pattern.scheduledTimetable.createUpdatedTripTimes(tripUpdate, timeZone, serviceDate); if (updatedTripTimes == null) { return false; } // Make sure that updated trip times have the correct real time state updatedTripTimes.setRealTimeState(RealTimeState.UPDATED); final boolean success = buffer.update(feedId, pattern, updatedTripTimes, serviceDate); return success; }