* Figure out the minimum amount of walking to reach the destination from transit.
* This is done by doing a Dijkstra search for the first reachable transit stop.
*/
private double determineRequiredWalkDistance(RoutingRequest req) {
if ( ! req.modes.isTransit()) return 0; // required walk distance will be unused.
GenericDijkstra gd = new GenericDijkstra(req);
State s = new State(req.rctx.target, req);
gd.setHeuristic(new TrivialRemainingWeightHeuristic());
final ClosestStopTraverseVisitor visitor = new ClosestStopTraverseVisitor();
gd.traverseVisitor = visitor;
gd.searchTerminationStrategy = new SearchTerminationStrategy() {
@Override public boolean shouldSearchTerminate(Vertex origin, Vertex target, State current,
ShortestPathTree spt, RoutingRequest traverseOptions) {
return visitor.distanceToClosestStop != Double.POSITIVE_INFINITY;
}
};
gd.getShortestPathTree(s);
return visitor.distanceToClosestStop;
}