.filter(GtfsRealtime.FeedEntity::hasTripUpdate) .map(GtfsRealtime.FeedEntity::getTripUpdate) .filter(tripUpdate -> tripUpdate.getTrip().getScheduleRelationship() == GtfsRealtime.TripDescriptor.ScheduleRelationship.SCHEDULED) .forEach(tripUpdate -> { Collection<Frequency> frequencies = feed.getFrequencies(tripUpdate.getTrip().getTripId()); int timeOffset = (tripUpdate.getTrip().hasStartTime() && !frequencies.isEmpty()) ? LocalTime.parse(tripUpdate.getTrip().getStartTime()).toSecondOfDay() : 0; String key = GtfsStorage.tripKey(tripUpdate.getTrip(), !frequencies.isEmpty()); final int[] boardEdges = staticGtfs.getBoardEdgesForTrip().get(key); return; final StopTime originalStopTime = feed.stop_times.get(new Fun.Tuple2(tripUpdate.getTrip().getTripId(), stopTime.stop_sequence)); int arrivalDelay = stopTime.arrival_time - originalStopTime.arrival_time; delaysForAlightEdges.put(leaveEdges[stopTime.stop_sequence], arrivalDelay * 1000); .filter(GtfsRealtime.FeedEntity::hasTripUpdate) .map(GtfsRealtime.FeedEntity::getTripUpdate) .filter(tripUpdate -> tripUpdate.getTrip().getScheduleRelationship() == GtfsRealtime.TripDescriptor.ScheduleRelationship.ADDED) .forEach(tripUpdate -> { Trip trip = new Trip(); trip.trip_id = tripUpdate.getTrip().getTripId(); trip.route_id = tripUpdate.getTrip().getRouteId(); final List<StopTime> stopTimes = tripUpdate.getStopTimeUpdateList().stream() .map(stopTimeUpdate -> {
final String tripId = tripUpdate.getTrip().getTripId(); cancelPreviouslyAddedTrip(feedId, tripId, serviceDate); if (tripUpdate.getTrip().hasRouteId()) { route = getRouteForRouteId(feedId, tripUpdate.getTrip().getRouteId()); if (tripUpdate.getTrip().hasRouteId()) { route.setId(new FeedScopedId(feedId, tripUpdate.getTrip().getRouteId())); } else { route.setId(new FeedScopedId(feedId, tripId)); trip.setId(new FeedScopedId(feedId, tripUpdate.getTrip().getTripId())); trip.setRoute(route);
if (!tripDescriptor.hasTripId()) { LOG.error("TripDescriptor object has no TripId field"); return null; String tripId = tripDescriptor.getTripId(); int tripIndex = getTripIndex(tripId); if (tripIndex == -1) { if (tripDescriptor.hasScheduleRelationship() && tripDescriptor.getScheduleRelationship() == TripDescriptor.ScheduleRelationship.CANCELED) { newTimes.cancel();
_log.warn( "Multiple anonymous TripUpdates for trip {}; will not map to VehiclePosition.", td.getTripId()); anonymousTripUpdatesByBlock.put(bd, tu); td.getTripId()); badAnonymousVehiclePositions.add(bd); update.block = getTripDescriptorAsBlockDescriptor(result, tu.getTrip(), time); update.tripUpdates = new ArrayList<TripUpdate>(tripUpdates); update.bestTrip = tu.getTrip().getTripId();
if (entity.hasTripUpdate()) { GtfsRealtime.TripUpdate tripUpdate = entity.getTripUpdate(); if (!tripUpdate.getTrip().hasTripId()) { checkW006(entity, tripUpdate.getTrip(), errorListW006); } else { String tripId = tripUpdate.getTrip().getTripId(); Trip trip = gtfsMetadata.getTrips().get(tripId); if (trip == null) { if (tripUpdate.getTrip().hasStartTime()) { checkE023(tripUpdate, tripUpdate.getTrip(), gtfsMetadata, errorListE023); if (tripUpdate.getTrip().hasStartTime()) { checkE020(tripUpdate, tripUpdate.getTrip(), errorListE020); if (!trip.hasTripId()) { checkW006(entity, trip, errorListW006); } else { String tripId = trip.getTripId(); if (!StringUtils.isEmpty(tripId)) { Trip gtfsTrip = gtfsMetadata.getTrips().get(tripId); if (trip.hasStartTime()) { checkE023(entity.getVehicle(), trip, gtfsMetadata, errorListE023); if (trip.hasStartTime()) { checkE020(entity.getVehicle(), trip, errorListE020);
if (entity.hasTripUpdate() && hasTripId(entity.getTripUpdate())) { tripUpdateCount++; String tripId = entity.getTripUpdate().getTrip().getTripId(); String vehicleId = ""; if (entity.getTripUpdate().hasVehicle() && entity.getTripUpdate().getVehicle().hasId()) { String vehicleId = entity.getVehicle().getVehicle().getId(); String tripId = ""; if (entity.getVehicle().hasTrip() && entity.getVehicle().getTrip().hasTripId()) { tripId = entity.getVehicle().getTrip().getTripId();
GtfsRealtime.TripUpdate tripUpdate = entity.getTripUpdate(); List<Frequency> frequenceTypeOneList = gtfsMetadata.getExactTimesOneTrips().get(tripUpdate.getTrip().getTripId()); if (frequenceTypeOneList != null) { boolean foundMatch = false; _log.debug("start time = " + startTime); _log.debug("formatted start time = " + gtfsStartTimeString); if (tripUpdate.getTrip().getStartTime().equals(gtfsStartTimeString)) { String prefix = "GTFS-rt trip_id " + tripUpdate.getTrip().getTripId() + " has start_time of " + tripUpdate.getTrip().getStartTime() + " and GTFS frequencies.txt start_time is " + gtfsStartTimeString + " with a headway of " + headwaySecs + " seconds "; RuleUtils.addOccurrence(E019, prefix, errorListE019, _log); List<Frequency> frequenceTypeOneList = gtfsMetadata.getExactTimesOneTrips().get(vehiclePosition.getTrip().getTripId()); if (frequenceTypeOneList != null) { boolean foundMatch = false; _log.debug("start time = " + startTime); _log.debug("formatted start time = " + gtfsStartTimeString); if (vehiclePosition.hasTrip() && vehiclePosition.getTrip().getStartTime().equals(gtfsStartTimeString)) { String prefix = "GTFS-rt trip_id " + vehiclePosition.getTrip().getTripId() + " has start_time of " + vehiclePosition.getTrip().getStartTime() + " and GTFS frequencies.txt start_time is " + gtfsStartTimeString + " with a headway of " + headwaySecs + " seconds "; RuleUtils.addOccurrence(E019, prefix, errorListE019, _log);
if(update.getTrip().hasDirectionId()) direction=""+update.getTrip().getDirectionId(); Trip trip = dbConfig.getTrip(update.getTrip().getTripId()); if (trip != null) { direction = trip.getDirectionId(); } else { logger.error("Got tripTag={} but no such trip in " + "the configuration.", update.getTrip().getTripId()); + "directionId={}, tripId={}, vehicleId={}, " + "stopId={}, prediction={}, isArrival={}", update.getTrip().getRouteId(), direction, update.getTrip().getTripId(), update.getVehicle().getId(), stopTime.getStopId(), new Date(stopTime.getArrival().getTime()*1000), true); update.getTrip().getRouteId(), direction, stopTime.getStopId(), update.getTrip().getTripId(), update.getVehicle().getId(), new Date(stopTime.getArrival().getTime()*1000) , update.getTrip().getRouteId(), direction, stopTime.getStopId(), update.getTrip().getTripId(), update.getVehicle().getId(), new Date(stopTime.getDeparture().getTime()*1000) ,
if (tripDescriptor.hasTripId()) { avlReport.setAssignment(tripDescriptor.getTripId(), AssignmentType.TRIP_ID); } else if (tripDescriptor.hasRouteId()) { avlReport.setAssignment(tripDescriptor.getRouteId(), AssignmentType.ROUTE_ID);
blockInstance.getServiceDate())); TripDescriptor.Builder tripDescriptor = TripDescriptor.newBuilder(); tripDescriptor.setRouteId(AgencyAndId.convertToString(routeId)); tripDescriptor.setScheduleRelationship(ScheduleRelationship.SCHEDULED);
for (GtfsRealtime.TripUpdate.StopTimeUpdate stopTimeUpdate : stopTimeUpdateList) { if (stopTimeUpdate.hasStopId()) { String prefix = "trip_id " + tripUpdate.getTrip().getTripId() + " stop_id " + stopTimeUpdate.getStopId(); if (!gtfsMetadata.getStopIds().contains(stopTimeUpdate.getStopId())) {
if (gtfsMetadata.getExactTimesZeroTripIds().contains(tripUpdate.getTrip().getTripId())) { if (!tripUpdate.getTrip().hasStartDate()) { RuleUtils.addOccurrence(E006, "trip_id " + tripUpdate.getTrip().getTripId() + " is missing start_date", errorListE006, _log); if (!tripUpdate.getTrip().hasStartTime()) { RuleUtils.addOccurrence(E006, "trip_id " + tripUpdate.getTrip().getTripId() + " is missing start_time", errorListE006, _log); if (!(!tripUpdate.getTrip().hasScheduleRelationship() || tripUpdate.getTrip().getScheduleRelationship().equals(GtfsRealtime.TripDescriptor.ScheduleRelationship.UNSCHEDULED))) { RuleUtils.addOccurrence(E013, "trip_id " + tripUpdate.getTrip().getTripId() + " schedule_relationship " + tripUpdate.getTrip().getScheduleRelationship(), errorListE013, _log); RuleUtils.addOccurrence(W005, "trip_id " + tripUpdate.getTrip().getTripId(), errorListW005, _log); GtfsRealtime.VehiclePosition vehiclePosition = entity.getVehicle(); if (vehiclePosition.hasTrip() && gtfsMetadata.getExactTimesZeroTripIds().contains(vehiclePosition.getTrip().getTripId())) { if (!vehiclePosition.getTrip().hasStartDate()) { RuleUtils.addOccurrence(E006, "vehicle_id " + vehiclePosition.getVehicle().getId() + " trip_id " + vehiclePosition.getTrip().getTripId() + " is missing start_date", errorListE006, _log); if (!vehiclePosition.getTrip().hasStartTime()) { RuleUtils.addOccurrence(E006, "vehicle_id " + vehiclePosition.getVehicle().getId() + " trip_id " + vehiclePosition.getTrip().getTripId() + " is missing start_time", errorListE006, _log); if (!(!vehiclePosition.getTrip().hasScheduleRelationship() || vehiclePosition.getTrip().getScheduleRelationship().equals(GtfsRealtime.TripDescriptor.ScheduleRelationship.UNSCHEDULED))) {
private BlockDescriptor getTripDescriptorAsBlockDescriptor(MonitoredResult result, TripDescriptor trip, long currentTime) { if (!trip.hasTripId()) { return null; TripEntry tripEntry = _entitySource.getTrip(trip.getTripId()); if (tripEntry == null) { if (result != null) { _log.debug("reporting unmatched trip with id=" + trip.getTripId()); result.addUnmatchedTripId(trip.getTripId()); } else { _log.warn("no trip found with id=" + trip.getTripId()); if (trip.hasStartDate() && ! "0".equals(trip.getStartDate())) { try { serviceDate = ServiceDate.parseString(trip.getStartDate()); } catch (ParseException ex) { _log.warn("Could not parse service date " + trip.getStartDate(), ex); blockDescriptor.setBlockInstance(instance); blockDescriptor.setStartDate(serviceDate); if (trip.hasScheduleRelationship()) { blockDescriptor.setScheduleRelationshipValue(trip.getScheduleRelationship().toString()); if (trip.hasStartTime() && !"0".equals(trip.getStartTime())) { try { tripStartTime = StopTimeFieldMappingFactory.getStringAsSeconds(trip.getStartTime()); } catch (InvalidStopTimeException iste) { _log.error("invalid stopTime of " + trip.getStartTime() + " for trip " + trip);
if (td.hasTripId()) { vpm.setTripId(td.getTripId()); if (td.hasRouteId()) { vpm.setRouteId(td.getRouteId()); if (td.hasStartDate() && td.hasStartTime()) { vpm.setTripStart(GtfsRealtimeConversionLibrary.parseDate(td.getStartDate(), td.getStartTime())); if (entity.getVehicle().getTrip().hasTripId()) { vpm.setTripId(entity.getVehicle().getTrip().getTripId()); if (entity.getVehicle().getTrip().hasRouteId()) { vpm.setRouteId(entity.getVehicle().getTrip().getRouteId());
entitySelector.setRouteId(id(serviceAlert.getAgencyId(), affects.getRouteId())); if (affects.getTripId() != null) { TripDescriptor.Builder trip = TripDescriptor.newBuilder(); trip.setTripId(id(serviceAlert.getAgencyId(), affects.getTripId())); entitySelector.setTrip(trip);
trip = TripDescriptor.newBuilder() .setRouteId(vehicleData.getRouteId());
if (!v.hasTrip() || !v.getTrip().hasTripId()) { return; String tripId = v.getTrip().getTripId(); String routeId = null; if (v.getTrip().hasRouteId()) { routeId = v.getTrip().getRouteId();
for (GtfsRealtime.EntitySelector entitySelector : a.getInformedEntityList()) { if (entitySelector.hasTrip()) { if (tripId.equals(entitySelector.getTrip().getTripId())) { if (routeId != null && routeId.equals(entitySelector.getTrip().getRouteId())) {
tu.setDelay(entity.getTripUpdate().getDelay()); if (t.hasTripId()) tu.setTripId(t.getTripId()); if (t.hasRouteId()) { tu.setRouteId(t.getRouteId()); if (t.hasStartDate() && t.hasStartTime()) { tu.setTripStart(GtfsRealtimeConversionLibrary.parseDate(t.getStartDate(), t.getStartTime()));