Skip to content

Commit c82c172

Browse files
easbarkarussell
authored andcommitted
Improves error message in case of forgotten/wrong edge_based=true/false parameter. (graphhopper#1555)
Signed-off-by: easbar <[email protected]>
1 parent 7be19e1 commit c82c172

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,15 +244,22 @@ public RoutingAlgorithmFactory getDecoratedAlgorithmFactory(RoutingAlgorithmFact
244244
map.setWeighting(getDefaultWeighting());
245245

246246
boolean edgeBased = map.getBool(Parameters.Routing.EDGE_BASED, false);
247-
String entriesStr = "";
247+
List<String> entriesStrs = new ArrayList<>();
248+
boolean weightingMatchesButNotEdgeBased = false;
248249
for (PrepareContractionHierarchies p : allPreparations) {
249-
if (p.isEdgeBased() == edgeBased && p.getWeighting().matches(map))
250+
boolean weightingMatches = p.getWeighting().matches(map);
251+
if (p.isEdgeBased() == edgeBased && weightingMatches)
250252
return p;
253+
else if (weightingMatches)
254+
weightingMatchesButNotEdgeBased = true;
251255

252-
entriesStr += p.getWeighting() + "|" + (p.isEdgeBased() ? "edge" : "node") + ", ";
256+
entriesStrs.add(p.getWeighting() + "|" + (p.isEdgeBased() ? "edge" : "node"));
253257
}
254258

255-
throw new IllegalArgumentException("Cannot find CH RoutingAlgorithmFactory for weighting map " + map + " in entries " + entriesStr);
259+
String hint = weightingMatchesButNotEdgeBased
260+
? " The '" + Parameters.Routing.EDGE_BASED + "' url parameter is missing or does not fit the weightings. Its value was: '" + edgeBased + "'"
261+
: "";
262+
throw new IllegalArgumentException("Cannot find CH RoutingAlgorithmFactory for weighting map " + map + " in entries: " + entriesStrs + "." + hint);
256263
}
257264

258265
public int getPreparationThreads() {

0 commit comments

Comments
 (0)