Skip to content

Commit 65bea04

Browse files
committed
Add hint about disabling CH/LM when profile not found.
1 parent e2686bd commit 65bea04

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

core/src/main/java/com/graphhopper/routing/ch/CHProfileSelector.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ private CHProfile select() {
6666
}
6767

6868
if (matchingProfiles.isEmpty()) {
69-
throw new CHProfileSelectionException("Cannot find matching CH profile for your request.\nrequested: " + getRequestAsString() + "\navailable: " + chProfiles);
69+
throw new CHProfileSelectionException("Cannot find matching CH profile for your request. Please check your parameters." +
70+
"\nYou can try disabling CH using " + Parameters.CH.DISABLE + "=true" +
71+
"\nrequested: " + getRequestAsString() + "\navailable: " + chProfiles);
7072
} else if (matchingProfiles.size() == 1) {
7173
return matchingProfiles.get(0);
7274
} else {
@@ -80,6 +82,7 @@ private CHProfile select() {
8082
return match1.isEdgeBased() ? match1 : match2;
8183
}
8284
throw new CHProfileSelectionException("There are multiple CH profiles matching your request. Use the `weighting`,`vehicle`,`edge_based` and/or `u_turn_costs` parameters to be more specific." +
85+
"\nYou can also try disabling CH altogether using " + Parameters.CH.DISABLE + "=true" +
8386
"\nrequested: " + getRequestAsString() + "\nmatched: " + matchingProfiles + "\navailable: " + chProfiles);
8487
}
8588
}

core/src/main/java/com/graphhopper/routing/lm/LMPreparationHandler.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
*/
1818
package com.graphhopper.routing.lm;
1919

20-
import com.graphhopper.GHRequest;
21-
import com.graphhopper.GHResponse;
2220
import com.graphhopper.GraphHopperConfig;
2321
import com.graphhopper.routing.AlgorithmOptions;
2422
import com.graphhopper.routing.RoutingAlgorithm;
@@ -231,13 +229,11 @@ public RoutingAlgorithmFactory getAlgorithmFactory(HintsMap map) {
231229
// trivial to check whether or not this is the case so we do not allow this for now.
232230
String requestedString = (map.getWeighting().isEmpty() ? "*" : map.getWeighting()) + "|" +
233231
(map.getVehicle().isEmpty() ? "*" : map.getVehicle());
234-
throw new IllegalArgumentException("Cannot find matching LM profile for your request." +
232+
throw new IllegalArgumentException("Cannot find matching LM profile for your request. Please check your parameters." +
233+
"\nYou can try disabling LM by setting " + Parameters.Landmark.DISABLE + "=true" +
235234
"\nrequested: " + requestedString + "\navailable: " + lmProfiles);
236235
}
237236

238-
/**
239-
* @see com.graphhopper.GraphHopper#calcPaths(GHRequest, GHResponse)
240-
*/
241237
private static class LMRoutingAlgorithmFactory implements RoutingAlgorithmFactory {
242238
private RoutingAlgorithmFactory defaultAlgoFactory;
243239
private PrepareLandmarks p;

reader-osm/src/test/java/com/graphhopper/GraphHopperIT.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,7 +1290,9 @@ public void testNodeBasedCHOnlyButTurnCostForNonCH() {
12901290
assertMoscowNodeBased(tmpHopper, "false", true);
12911291
GHResponse rsp = runMoscow(tmpHopper, "true", true);
12921292
assertEquals(1, rsp.getErrors().size());
1293-
String expected = "Cannot find matching CH profile for your request.\nrequested: *|car|edge_based=true|u_turn_costs=*\navailable: [fastest|car|edge_based=false]";
1293+
String expected = "Cannot find matching CH profile for your request. Please check your parameters." +
1294+
"\nYou can try disabling CH using ch.disable=true" +
1295+
"\nrequested: *|car|edge_based=true|u_turn_costs=*\navailable: [fastest|car|edge_based=false]";
12941296
assertTrue("unexpected error:\n" + rsp.getErrors().toString() + "\nwhen expecting an error containing:\n" + expected,
12951297
rsp.getErrors().toString().contains(expected));
12961298
}
@@ -1314,7 +1316,9 @@ public void testEdgeBasedByDefaultIfOnlyEdgeBased() {
13141316
GHResponse rsp = runMoscow(tmpHopper, "false", true);
13151317
assertTrue(rsp.hasErrors());
13161318
assertTrue("unexpected error: " + rsp.getErrors(), rsp.getErrors().toString().contains(
1317-
"Cannot find matching CH profile for your request.\nrequested: *|car|edge_based=false|u_turn_costs=*\navailable: [fastest|car|edge_based=true|u_turn_costs=-1]"));
1319+
"Cannot find matching CH profile for your request. Please check your parameters." +
1320+
"\nYou can try disabling CH using ch.disable=true" +
1321+
"\nrequested: *|car|edge_based=false|u_turn_costs=*\navailable: [fastest|car|edge_based=true|u_turn_costs=-1]"));
13181322
}
13191323

13201324
private GHResponse assertMoscowNodeBased(GraphHopper tmpHopper, String edgeBasedParam, boolean ch) {

0 commit comments

Comments
 (0)