Skip to content

Commit

Permalink
Allow loading GHStorage with a single CH preparation
Browse files Browse the repository at this point in the history
  • Loading branch information
easbar committed Feb 10, 2020
1 parent 3d63cdc commit 0a43887
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 @@ -282,12 +282,6 @@ private void checkIfConfiguredAndLoadedWeightingsCompatible() {
String loadedStr = properties.get("graph.ch.profiles");
List<String> loaded = parseList(loadedStr);
List<CHProfile> configured = getCHProfiles();
// todo: not entirely sure here. when no ch is configured at all (neither edge nor node), but there are any
// ch graphs (edge or node) we throw an error ? previously we threw an error when no ch weighting was configured
// even though there was a ch graph.
if (configured.isEmpty() && !loaded.isEmpty()) {
throw new IllegalStateException("You loaded a CH graph, but you did not specify any CH weightings in prepare.ch.weightings");
}
for (CHProfile chProfile : configured) {
if (!loaded.contains(chProfile.toString())) {
throw new IllegalStateException("Configured CH profile: " + chProfile.toString() + " is not contained in loaded weightings for CH" + loadedStr + ".\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,13 @@ private void testLoadingWithLessWeightings_works(boolean edgeBased) {
assertEquals(edgeBased ? 1 : 0, smallStorage.getCHProfiles(true).size());
smallStorage.flush();

// now we create a new storage without any ch weightings, which should also be ok
GraphHopperStorage smallerStorage = createStorageWithWeightings();
smallerStorage.loadExisting();
assertEquals(0, smallerStorage.getCHProfiles(false).size());
assertEquals(0, smallerStorage.getCHProfiles(true).size());
smallerStorage.flush();

// now we create yet another storage that uses both weightings again, which still works
GraphHopperStorage fullStorage = createStorageWithWeightings(
"car|fastest|" + edgeOrNode,
Expand Down

0 comments on commit 0a43887

Please sign in to comment.