Search in sources :

Example 16 with Timetable

use of org.opentripplanner.model.Timetable in project OpenTripPlanner by opentripplanner.

the class TimetableSnapshotSource method cancelScheduledTrip.

/**
 * Cancel scheduled trip in buffer given trip id (without agency id) on service date
 *
 * @param tripId trip id without agency id
 * @param serviceDate service date
 * @return true if scheduled trip was cancelled
 */
private boolean cancelScheduledTrip(String feedId, String tripId, final ServiceDate serviceDate) {
    boolean success = false;
    final TripPattern pattern = getPatternForTripId(feedId, tripId);
    if (pattern != null) {
        // Cancel scheduled trip times for this trip in this pattern
        final Timetable timetable = pattern.scheduledTimetable;
        final int tripIndex = timetable.getTripIndex(tripId);
        if (tripIndex == -1) {
            LOG.warn("Could not cancel scheduled trip {}", tripId);
        } else {
            final TripTimes newTripTimes = new TripTimes(timetable.getTripTimes(tripIndex));
            newTripTimes.cancel();
            buffer.update(pattern, newTripTimes, serviceDate);
            success = true;
        }
    }
    return success;
}
Also used : Timetable(org.opentripplanner.model.Timetable) TripTimes(org.opentripplanner.routing.trippattern.TripTimes) TripPattern(org.opentripplanner.model.TripPattern)

Aggregations

Timetable (org.opentripplanner.model.Timetable)16 TripPattern (org.opentripplanner.model.TripPattern)13 TripTimes (org.opentripplanner.routing.trippattern.TripTimes)12 TimetableSnapshot (org.opentripplanner.model.TimetableSnapshot)6 Trip (org.opentripplanner.model.Trip)6 FeedScopedId (org.opentripplanner.model.FeedScopedId)5 Stop (org.opentripplanner.model.Stop)5 Test (org.junit.Test)4 TimetableHelper.createUpdatedTripTimes (org.opentripplanner.ext.siri.TimetableHelper.createUpdatedTripTimes)4 ServiceDate (org.opentripplanner.model.calendar.ServiceDate)4 TripUpdate (com.google.transit.realtime.GtfsRealtime.TripUpdate)3 StopTimeUpdate (com.google.transit.realtime.GtfsRealtime.TripUpdate.StopTimeUpdate)3 ArrayList (java.util.ArrayList)3 ServiceDay (org.opentripplanner.routing.core.ServiceDay)3 Calendar (java.util.Calendar)2 GtfsContextBuilder.contextBuilder (org.opentripplanner.gtfs.GtfsContextBuilder.contextBuilder)2 TripTimeShort (org.opentripplanner.model.TripTimeShort)2 TripDescriptor (com.google.transit.realtime.GtfsRealtime.TripDescriptor)1 StopTimeEvent (com.google.transit.realtime.GtfsRealtime.TripUpdate.StopTimeEvent)1 LocalDate (java.time.LocalDate)1