Skip to content

Commit 0a43887

Browse files
committed
Allow loading GHStorage with a single CH preparation
1 parent 3d63cdc commit 0a43887

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -282,12 +282,6 @@ private void checkIfConfiguredAndLoadedWeightingsCompatible() {
282282
String loadedStr = properties.get("graph.ch.profiles");
283283
List<String> loaded = parseList(loadedStr);
284284
List<CHProfile> configured = getCHProfiles();
285-
// todo: not entirely sure here. when no ch is configured at all (neither edge nor node), but there are any
286-
// ch graphs (edge or node) we throw an error ? previously we threw an error when no ch weighting was configured
287-
// even though there was a ch graph.
288-
if (configured.isEmpty() && !loaded.isEmpty()) {
289-
throw new IllegalStateException("You loaded a CH graph, but you did not specify any CH weightings in prepare.ch.weightings");
290-
}
291285
for (CHProfile chProfile : configured) {
292286
if (!loaded.contains(chProfile.toString())) {
293287
throw new IllegalStateException("Configured CH profile: " + chProfile.toString() + " is not contained in loaded weightings for CH" + loadedStr + ".\n" +

core/src/test/java/com/graphhopper/storage/GraphHopperStorageCHTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,13 @@ private void testLoadingWithLessWeightings_works(boolean edgeBased) {
592592
assertEquals(edgeBased ? 1 : 0, smallStorage.getCHProfiles(true).size());
593593
smallStorage.flush();
594594

595+
// now we create a new storage without any ch weightings, which should also be ok
596+
GraphHopperStorage smallerStorage = createStorageWithWeightings();
597+
smallerStorage.loadExisting();
598+
assertEquals(0, smallerStorage.getCHProfiles(false).size());
599+
assertEquals(0, smallerStorage.getCHProfiles(true).size());
600+
smallerStorage.flush();
601+
595602
// now we create yet another storage that uses both weightings again, which still works
596603
GraphHopperStorage fullStorage = createStorageWithWeightings(
597604
"car|fastest|" + edgeOrNode,

0 commit comments

Comments
 (0)