Search in sources :

Example 1 with FrequencyEntryImpl

use of org.onebusaway.transit_data_federation.impl.transit_graph.FrequencyEntryImpl in project onebusaway-application-modules by camsys.

the class FrequencyEntriesFactory method processRawFrequency.

private void processRawFrequency(TransitGraphImpl graph, Frequency frequency, Map<AgencyAndId, List<FrequencyEntry>> frequenciesByTripId, Map<AgencyAndId, Integer> exactTimesValueByTrip) {
    AgencyAndId tripId = frequency.getTrip().getId();
    /**
     * The value of frequencies.txt exact_times is expected to be the same
     * across all entries for the same trip id.
     */
    Integer exactTimesValue = exactTimesValueByTrip.get(tripId);
    if (exactTimesValue == null) {
        exactTimesValue = frequency.getExactTimes();
        exactTimesValueByTrip.put(tripId, exactTimesValue);
    } else if (exactTimesValue != frequency.getExactTimes()) {
        throw new IllegalStateException("The value of frequencies.txt exact_times differed for frequency entries with tripId=" + tripId);
    }
    FrequencyEntryImpl entry = new FrequencyEntryImpl(frequency.getStartTime(), frequency.getEndTime(), frequency.getHeadwaySecs(), frequency.getExactTimes());
    List<FrequencyEntry> frequencies = frequenciesByTripId.get(tripId);
    if (frequencies == null) {
        frequencies = new ArrayList<FrequencyEntry>();
        frequenciesByTripId.put(tripId, frequencies);
    }
    frequencies.add(entry);
}
Also used : FrequencyEntryImpl(org.onebusaway.transit_data_federation.impl.transit_graph.FrequencyEntryImpl) AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) FrequencyEntry(org.onebusaway.transit_data_federation.services.transit_graph.FrequencyEntry)

Aggregations

AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)1 FrequencyEntryImpl (org.onebusaway.transit_data_federation.impl.transit_graph.FrequencyEntryImpl)1 FrequencyEntry (org.onebusaway.transit_data_federation.services.transit_graph.FrequencyEntry)1