Search in sources :

Example 1 with Transfer

use of org.opentripplanner.routing.algorithm.raptor.transit.Transfer in project OpenTripPlanner by opentripplanner.

the class RaptorPathToItineraryMapper method mapTransferLeg.

private void mapTransferLeg(List<Leg> legs, TransferPathLeg<TripSchedule> pathLeg) {
    Stop transferFromStop = transitLayer.getStopByIndex(pathLeg.fromStop());
    Stop transferToStop = transitLayer.getStopByIndex(pathLeg.toStop());
    Transfer transfer = transitLayer.getTransferByStopIndex().get(pathLeg.fromStop()).stream().filter(t -> t.getToStop() == pathLeg.toStop()).findFirst().get();
    Place from = mapStopToPlace(transferFromStop, null);
    Place to = mapStopToPlace(transferToStop, null);
    mapNonTransitLeg(legs, pathLeg, transfer, from, to, false);
}
Also used : Stop(org.opentripplanner.model.Stop) Transfer(org.opentripplanner.routing.algorithm.raptor.transit.Transfer) Place(org.opentripplanner.model.plan.Place)

Example 2 with Transfer

use of org.opentripplanner.routing.algorithm.raptor.transit.Transfer in project OpenTripPlanner by opentripplanner.

the class TransfersMapper method mapTransfers.

/**
 * Copy pre-calculated transfers from the original graph
 */
static List<List<Transfer>> mapTransfers(StopIndexForRaptor stopIndex, Multimap<StopLocation, SimpleTransfer> transfersByStop) {
    List<List<Transfer>> transferByStopIndex = new ArrayList<>();
    for (int i = 0; i < stopIndex.stopsByIndex.size(); ++i) {
        Stop stop = stopIndex.stopsByIndex.get(i);
        ArrayList<Transfer> list = new ArrayList<>();
        transferByStopIndex.add(list);
        for (SimpleTransfer simpleTransfer : transfersByStop.get(stop)) {
            double effectiveDistance = simpleTransfer.getEffectiveWalkDistance();
            if (simpleTransfer.to instanceof Stop) {
                int toStopIndex = stopIndex.indexByStop.get(simpleTransfer.to);
                Transfer transfer = new Transfer(toStopIndex, (int) effectiveDistance, simpleTransfer.getEdges());
                list.add(transfer);
            }
        }
    }
    return transferByStopIndex;
}
Also used : Stop(org.opentripplanner.model.Stop) ArrayList(java.util.ArrayList) SimpleTransfer(org.opentripplanner.model.SimpleTransfer) Transfer(org.opentripplanner.routing.algorithm.raptor.transit.Transfer) List(java.util.List) ArrayList(java.util.ArrayList) SimpleTransfer(org.opentripplanner.model.SimpleTransfer)

Aggregations

Stop (org.opentripplanner.model.Stop)2 Transfer (org.opentripplanner.routing.algorithm.raptor.transit.Transfer)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 SimpleTransfer (org.opentripplanner.model.SimpleTransfer)1 Place (org.opentripplanner.model.plan.Place)1