Search in sources :

Example 1 with ScheduledDeviatedTrip

use of org.opentripplanner.ext.flex.trip.ScheduledDeviatedTrip in project OpenTripPlanner by opentripplanner.

the class FlexTripsMapper method createFlexTrips.

public static void createFlexTrips(OtpTransitServiceBuilder builder) {
    TripStopTimes stopTimesByTrip = builder.getStopTimesSortedByTrip();
    final int tripSize = stopTimesByTrip.size();
    ProgressTracker progress = ProgressTracker.track("Create flex trips", 500, tripSize);
    for (org.opentripplanner.model.Trip trip : stopTimesByTrip.keys()) {
        /* Fetch the stop times for this trip. Copy the list since it's immutable. */
        List<StopTime> stopTimes = new ArrayList<>(stopTimesByTrip.get(trip));
        if (UnscheduledTrip.isUnscheduledTrip(stopTimes)) {
            if (stopTimes.size() == 2) {
                // TODO: Drop this restriction after time handling and ride times are defined
                builder.getFlexTripsById().add(new UnscheduledTrip(trip, stopTimes));
            }
        } else if (ScheduledDeviatedTrip.isScheduledFlexTrip(stopTimes)) {
            builder.getFlexTripsById().add(new ScheduledDeviatedTrip(trip, stopTimes));
        } else if (hasContinuousStops(stopTimes)) {
        // builder.getFlexTripsById().add(new ContinuousPickupDropOffTrip(trip, stopTimes));
        }
        // Keep lambda! A method-ref would causes incorrect class and line number to be logged
        progress.step(m -> LOG.info(m));
    }
    LOG.info(progress.completeMessage());
    LOG.info("Done creating flex trips. Created a total of {} trips.", builder.getFlexTripsById().size());
}
Also used : ProgressTracker(org.opentripplanner.util.ProgressTracker) ArrayList(java.util.ArrayList) UnscheduledTrip(org.opentripplanner.ext.flex.trip.UnscheduledTrip) TripStopTimes(org.opentripplanner.model.TripStopTimes) ScheduledDeviatedTrip(org.opentripplanner.ext.flex.trip.ScheduledDeviatedTrip) StopTime(org.opentripplanner.model.StopTime)

Aggregations

ArrayList (java.util.ArrayList)1 ScheduledDeviatedTrip (org.opentripplanner.ext.flex.trip.ScheduledDeviatedTrip)1 UnscheduledTrip (org.opentripplanner.ext.flex.trip.UnscheduledTrip)1 StopTime (org.opentripplanner.model.StopTime)1 TripStopTimes (org.opentripplanner.model.TripStopTimes)1 ProgressTracker (org.opentripplanner.util.ProgressTracker)1