if (options == null) {
LOG.error("PathService was passed a null routing request.");
return null;
}
SPTService sptService = this.sptServiceFactory.instantiate();
if (options.rctx == null) {
options.setRoutingContext(graphService.getGraph(options.routerId));
options.rctx.pathParsers = new PathParser[] { new Parser() };
}
LOG.debug("rreq={}", options);
RemainingWeightHeuristic heuristic;
if (options.disableRemainingWeightHeuristic) {
heuristic = new TrivialRemainingWeightHeuristic();
} else if (options.modes.isTransit()) {
// Only use the BiDi heuristic for transit.
heuristic = new InterleavedBidirectionalHeuristic(options.rctx.graph);
} else {
heuristic = new DefaultRemainingWeightHeuristic();
}
options.rctx.remainingWeightHeuristic = heuristic;
/* In RoutingRequest, maxTransfers defaults to 2. Over long distances, we may see
* itineraries with far more transfers. We do not expect transfer limiting to improve
* search times on the LongDistancePathService, so we set it to the maximum we ever expect
* to see. Because people may use either the traditional path services or the
* LongDistancePathService, we do not change the global default but override it here. */
options.setMaxTransfers(10);
/* In long distance mode, maxWalk has a different meaning. It's the radius around the origin or destination
* within which you can walk on the streets. If no value is provided, max walk defaults to the largest
* double-precision float. This would cause long distance mode to do unbounded street searches and consider
* the whole graph walkable. */
if (options.maxWalkDistance == Double.MAX_VALUE) options.maxWalkDistance = DEFAULT_MAX_WALK;
if (options.maxWalkDistance > CLAMP_MAX_WALK) options.maxWalkDistance = CLAMP_MAX_WALK;
long searchBeginTime = System.currentTimeMillis();
LOG.debug("BEGIN SEARCH");
ShortestPathTree spt = sptService.getShortestPathTree(options, timeout);
LOG.debug("END SEARCH ({} msec)", System.currentTimeMillis() - searchBeginTime);
if (spt == null) { // timeout or other fail
LOG.warn("SPT was null.");
return null;