All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.opentripplanner.routing.algorithm.raptor.transit.mappers.TripPatternMapper Maven / Gradle / Ivy

There is a newer version: 2.5.0
Show newest version
package org.opentripplanner.routing.algorithm.raptor.transit.mappers;

import org.opentripplanner.model.TripPattern;
import org.opentripplanner.routing.algorithm.raptor.transit.StopIndexForRaptor;
import org.opentripplanner.routing.algorithm.raptor.transit.TripPatternWithRaptorStopIndexes;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

public class TripPatternMapper {

    /**
     * Convert all old TripPatterns into new ones, keeping a Map between the two. Do this conversion
     * up front (rather than lazily on demand) to ensure pattern IDs match the sequence of patterns
     * in source data.
     */
    static Map mapOldTripPatternToRaptorTripPattern(
            StopIndexForRaptor stopIndex, Collection oldTripPatterns
    ) {
        Map newTripPatternForOld;
        newTripPatternForOld = new HashMap<>();

        for (TripPattern oldTripPattern : oldTripPatterns) {
            TripPatternWithRaptorStopIndexes newTripPattern = new TripPatternWithRaptorStopIndexes(
                    stopIndex.listStopIndexesForStops(oldTripPattern.stopPattern.stops),
                    oldTripPattern
            );
            newTripPatternForOld.put(oldTripPattern, newTripPattern);
        }
        return newTripPatternForOld;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy