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++;
}
}
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);
}
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;
}
Aggregations