org.opentripplanner.routing.algorithm.raptor.transit.mappers.TransfersMapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of otp Show documentation
Show all versions of otp Show documentation
The OpenTripPlanner multimodal journey planning system
package org.opentripplanner.routing.algorithm.raptor.transit.mappers;
import com.google.common.collect.Multimap;
import org.opentripplanner.model.SimpleTransfer;
import org.opentripplanner.model.Stop;
import org.opentripplanner.model.StopLocation;
import org.opentripplanner.routing.algorithm.raptor.transit.StopIndexForRaptor;
import org.opentripplanner.routing.algorithm.raptor.transit.Transfer;
import java.util.ArrayList;
import java.util.List;
class TransfersMapper {
/**
* Copy pre-calculated transfers from the original graph
*/
static List> mapTransfers(
StopIndexForRaptor stopIndex,
Multimap transfersByStop
) {
List> transferByStopIndex = new ArrayList<>();
for (int i = 0; i < stopIndex.stopsByIndex.size(); ++i) {
Stop stop = stopIndex.stopsByIndex.get(i);
ArrayList 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;
}
}