Search in sources :

Example 61 with TripPattern

use of org.opentripplanner.model.TripPattern 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

TripPattern (org.opentripplanner.model.TripPattern)61 Trip (org.opentripplanner.model.Trip)26 FeedScopedId (org.opentripplanner.model.FeedScopedId)23 Stop (org.opentripplanner.model.Stop)23 ArrayList (java.util.ArrayList)19 TripTimes (org.opentripplanner.routing.trippattern.TripTimes)19 Timetable (org.opentripplanner.model.Timetable)13 ServiceDate (org.opentripplanner.model.calendar.ServiceDate)13 Route (org.opentripplanner.model.Route)12 Test (org.junit.Test)11 HashSet (java.util.HashSet)8 RoutingService (org.opentripplanner.routing.RoutingService)8 List (java.util.List)7 StopPattern (org.opentripplanner.model.StopPattern)7 TimetableSnapshot (org.opentripplanner.model.TimetableSnapshot)7 GET (javax.ws.rs.GET)6 Path (javax.ws.rs.Path)6 StopTime (org.opentripplanner.model.StopTime)5 TripUpdate (com.google.transit.realtime.GtfsRealtime.TripUpdate)4 StopTimeUpdate (com.google.transit.realtime.GtfsRealtime.TripUpdate.StopTimeUpdate)4