Skip to content

Commit

Permalink
refactor: prepare method movement
Browse files Browse the repository at this point in the history
This commit adds a parameter of type RoutingRequest to setSpeedups
in order to move this method from RoutingProfile to RoutingReqest.
  • Loading branch information
Sascha Fendrich committed Jan 27, 2025
1 parent a0354fd commit a4ee961
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -185,18 +185,19 @@ public Double getAstarEpsilon() {
* Set the speedup techniques used for calculating the route.
* Reults in usage of CH, Core or ALT/AStar, if they are enabled.
*
* @param routingRequest
* @param req Request whose hints will be set
* @param useCH Should CH be enabled
* @param useCore Should Core be enabled
* @param useALT Should ALT be enabled
*/
public void setSpeedups(GHRequest req, boolean useCH, boolean useCore, boolean useALT, String profileNameCH) {
public void setSpeedups(GHRequest req, boolean useCH, boolean useCore, boolean useALT, String profileNameCH, RoutingRequest routingRequest) {
String requestProfileName = req.getProfile();

//Priority: CH->Core->ALT
String profileNameNoTC = requestProfileName.replace("_with_turn_costs", "");

ORSGraphHopper gh = getGraphhopper();
ORSGraphHopper gh = routingRequest.profile().getGraphhopper();

useCH = useCH && gh.isCHAvailable(profileNameCH);
useCore = useCore && !useCH && (gh.isCoreAvailable(requestProfileName) || gh.isCoreAvailable(profileNameNoTC));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -480,15 +480,15 @@ else if (bearings[1] == null)
if (flexibleMode == ProfileTools.KEY_FLEX_STATIC)
//Speedup order: useCH, useCore, useALT
// TODO Future improvement: profileNameCH is an ugly hack and is required because of the hard-coded turnCost=false for CH
routingProfile.setSpeedups(req, true, true, true, searchCntx.profileNameCH());
routingProfile.setSpeedups(req, true, true, true, searchCntx.profileNameCH(), this);

if (flexibleMode == ProfileTools.KEY_FLEX_PREPROCESSED) {
routingProfile.setSpeedups(req, false, optimized, true, searchCntx.profileNameCH());
routingProfile.setSpeedups(req, false, optimized, true, searchCntx.profileNameCH(), this);
}

//cannot use CH or CoreALT with requests where the weighting of non-predefined edges might change
if (flexibleMode == ProfileTools.KEY_FLEX_FULLY)
routingProfile.setSpeedups(req, false, false, true, searchCntx.profileNameCH());
routingProfile.setSpeedups(req, false, false, true, searchCntx.profileNameCH(), this);

if (searchParams.isTimeDependent()) {
String key;
Expand Down Expand Up @@ -588,7 +588,7 @@ private GHResponse computeRoundTripRoute(double lat0, double lon0, WayPointBeari
throw new IllegalArgumentException("Unsupported weighting " + weightingMethod + " for profile + " + profileType);

//Roundtrip not possible with preprocessed edges.
routingProfile.setSpeedups(req, false, false, true, searchCntx.profileNameCH());
routingProfile.setSpeedups(req, false, false, true, searchCntx.profileNameCH(), this);

if (routingProfile.getAstarEpsilon() != null)
req.getHints().putObject("astarbi.epsilon", routingProfile.getAstarEpsilon());
Expand Down

0 comments on commit a4ee961

Please sign in to comment.