Skip to content

Commit 6903fda

Browse files
committed
Merge branch 'master' into virtual_way_geometry
2 parents b72842d + c51a8b9 commit 6903fda

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
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() {

core/src/main/java/com/graphhopper/storage/CHGraphImpl.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -423,18 +423,16 @@ public void debugPrint() {
423423
header += String.format(Locale.ROOT, formatShortcutExt, "S_ORIG_FIRST", "S_ORIG_LAST");
424424
}
425425
System.out.println(header);
426-
IntsRef intsRef = new IntsRef(shortcutBytesForFlags / 4);
427426
for (int i = baseGraph.edgeCount; i < baseGraph.edgeCount + Math.min(shortcutCount, printMax); ++i) {
428427
long edgePointer = chEdgeAccess.toPointer(i);
429-
chEdgeAccess.readFlags(edgePointer, intsRef);
430428
String edgeString = String.format(Locale.ROOT, formatShortcutsBase,
431429
i,
432430
chEdgeAccess.getNodeA(edgePointer),
433431
chEdgeAccess.getNodeB(edgePointer),
434432
chEdgeAccess.getLinkA(edgePointer),
435433
chEdgeAccess.getLinkB(edgePointer),
436434
chEdgeAccess.getDist(edgePointer),
437-
intsRef,
435+
chEdgeAccess.getShortcutFlags(edgePointer),
438436
shortcuts.getInt(edgePointer + S_SKIP_EDGE1),
439437
shortcuts.getInt(edgePointer + S_SKIP_EDGE2));
440438
if (edgeBased) {
@@ -751,19 +749,22 @@ public final boolean isShortcut() {
751749

752750
@Override
753751
public final CHEdgeIteratorState setWeight(double weight) {
752+
checkShortcut(true, "setWeight");
754753
chEdgeAccess.setShortcutWeight(edgePointer, weight);
755754
return this;
756755
}
757756

758757
@Override
759758
public void setFlagsAndWeight(int flags, double weight) {
759+
checkShortcut(true, "setFlagsAndWeight");
760760
chEdgeAccess.setAccessAndWeight(edgePointer, flags, weight);
761761
chFlags = flags;
762762
freshFlags = true;
763763
}
764764

765765
@Override
766766
public final double getWeight() {
767+
checkShortcut(true, "getWeight");
767768
return chEdgeAccess.getShortcutWeight(edgePointer);
768769
}
769770

0 commit comments

Comments
 (0)