org.opentripplanner.transit.raptor.RaptorService 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.transit.raptor;
import org.opentripplanner.transit.raptor.api.path.Path;
import org.opentripplanner.transit.raptor.api.request.RaptorRequest;
import org.opentripplanner.transit.raptor.api.response.RaptorResponse;
import org.opentripplanner.transit.raptor.api.transit.RaptorTransitDataProvider;
import org.opentripplanner.transit.raptor.api.transit.RaptorTripSchedule;
import org.opentripplanner.transit.raptor.rangeraptor.configure.RaptorConfig;
import org.opentripplanner.transit.raptor.service.HeuristicSearchTask;
import org.opentripplanner.transit.raptor.service.RangRaptorDynamicSearch;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Collection;
/**
* A service for performing Range Raptor routing request.
*
* @param The TripSchedule type defined by the user of the range raptor API.
*/
public class RaptorService {
private static final Logger LOG = LoggerFactory.getLogger(RaptorService.class);
private final RaptorConfig config;
public RaptorService(RaptorConfig config) {
this.config = config;
}
public RaptorResponse route(RaptorRequest request, RaptorTransitDataProvider transitData) {
LOG.debug("Raptor request: {}", request);
if(request.isDynamicSearch()) {
return new RangRaptorDynamicSearch<>(config, transitData, request).route();
}
return routeUsingStdWorker(transitData, request);
}
public void compareHeuristics(
RaptorRequest r1,
RaptorRequest r2,
RaptorTransitDataProvider transitData
) {
HeuristicSearchTask fwdHeur = new HeuristicSearchTask<>(r1, config, transitData);
HeuristicSearchTask revHeur = new HeuristicSearchTask<>(r2, config, transitData);
fwdHeur.forceRun();
revHeur.forceRun();
fwdHeur.debugCompareResult(revHeur);
}
public void shutdown() {
config.shutdown();
}
/* private methods */
private RaptorResponse routeUsingStdWorker(RaptorTransitDataProvider transitData, RaptorRequest request) {
Collection> paths = config.createStdWorker(transitData, request).route();
return new RaptorResponse<>(paths, request, request);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy