Search in sources :

Example 1 with Frequency

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

the class GenerateTripPatternsOperation method buildTripPatternForTrip.

private void buildTripPatternForTrip(Trip trip) {
    // Check that the mode is supported
    if (trip.getRoute().getMode() == null) {
        issueStore.add(new GTFSModeNotSupported(trip, Integer.toString(trip.getRoute().getType())));
        return;
    }
    // TODO: move to a validator module
    if (!calendarServiceIds.contains(trip.getServiceId())) {
        issueStore.add(new TripUndefinedService(trip));
        // Invalid trip, skip it, it will break later
        return;
    }
    int directionId = getDirectionId(trip);
    Collection<StopTime> stopTimes = transitDaoBuilder.getStopTimesSortedByTrip().get(trip);
    // If after filtering this trip does not contain at least 2 stoptimes, it does not serve any purpose.
    if (stopTimes.size() < 2) {
        issueStore.add(new TripDegenerate(trip));
        return;
    }
    // Get the existing TripPattern for this filtered StopPattern, or create one.
    StopPattern stopPattern = new StopPattern(stopTimes);
    TripPattern tripPattern = findOrCreateTripPattern(stopPattern, trip.getRoute(), directionId);
    // Create a TripTimes object for this list of stoptimes, which form one trip.
    TripTimes tripTimes = new TripTimes(trip, stopTimes, deduplicator);
    // If this trip is referenced by one or more lines in frequencies.txt, wrap it in a FrequencyEntry.
    List<Frequency> frequencies = frequenciesForTrip.get(trip);
    if (frequencies != null && !(frequencies.isEmpty())) {
        for (Frequency freq : frequencies) {
            tripPattern.add(new FrequencyEntry(freq, tripTimes));
            freqCount++;
        }
    // TODO replace: createGeometry(graph, trip, stopTimes, hops);
    } else // This trip was not frequency-based. Add the TripTimes directly to the TripPattern's scheduled timetable.
    {
        tripPattern.add(tripTimes);
        scheduledCount++;
    }
}
Also used : StopPattern(org.opentripplanner.model.StopPattern) GTFSModeNotSupported(org.opentripplanner.graph_builder.issues.GTFSModeNotSupported) TripTimes(org.opentripplanner.routing.trippattern.TripTimes) Frequency(org.opentripplanner.model.Frequency) TripUndefinedService(org.opentripplanner.graph_builder.issues.TripUndefinedService) FrequencyEntry(org.opentripplanner.routing.trippattern.FrequencyEntry) TripPattern(org.opentripplanner.model.TripPattern) StopTime(org.opentripplanner.model.StopTime) TripDegenerate(org.opentripplanner.graph_builder.issues.TripDegenerate)

Example 2 with Frequency

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

the class FrequencyEntryTest method make.

private static FrequencyEntry make(int startTime, int endTime, int headwaySecs, boolean exact) {
    Frequency f = new Frequency();
    f.setStartTime(startTime);
    f.setEndTime(endTime);
    f.setHeadwaySecs(headwaySecs);
    f.setExactTimes(exact ? 1 : 0);
    return new FrequencyEntry(f, tripTimes);
}
Also used : Frequency(org.opentripplanner.model.Frequency)

Example 3 with Frequency

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

the class FrequencyMapper method doMap.

private Frequency doMap(org.onebusaway.gtfs.model.Frequency rhs) {
    Frequency lhs = new Frequency();
    lhs.setTrip(tripMapper.map(rhs.getTrip()));
    lhs.setStartTime(rhs.getStartTime());
    lhs.setEndTime(rhs.getEndTime());
    lhs.setHeadwaySecs(rhs.getHeadwaySecs());
    lhs.setExactTimes(rhs.getExactTimes());
    lhs.setLabelOnly(rhs.getLabelOnly());
    return lhs;
}
Also used : Frequency(org.opentripplanner.model.Frequency)

Aggregations

Frequency (org.opentripplanner.model.Frequency)3 GTFSModeNotSupported (org.opentripplanner.graph_builder.issues.GTFSModeNotSupported)1 TripDegenerate (org.opentripplanner.graph_builder.issues.TripDegenerate)1 TripUndefinedService (org.opentripplanner.graph_builder.issues.TripUndefinedService)1 StopPattern (org.opentripplanner.model.StopPattern)1 StopTime (org.opentripplanner.model.StopTime)1 TripPattern (org.opentripplanner.model.TripPattern)1 FrequencyEntry (org.opentripplanner.routing.trippattern.FrequencyEntry)1 TripTimes (org.opentripplanner.routing.trippattern.TripTimes)1