use of com.graphhopper.storage.CHConfig in project graphhopper by graphhopper.
the class CHPreparationHandler method load.
public Map<String, RoutingCHGraph> load(GraphHopperStorage ghStorage, List<CHConfig> chConfigs) {
Map<String, RoutingCHGraph> loaded = Collections.synchronizedMap(new LinkedHashMap<>());
List<Callable<String>> callables = chConfigs.stream().map(c -> (Callable<String>) () -> {
CHStorage chStorage = ghStorage.loadCHStorage(c.getName(), c.isEdgeBased());
if (chStorage != null)
loaded.put(c.getName(), ghStorage.createCHGraph(chStorage, c));
else {
// todo: this is ugly, see comments in LMPreparationHandler
ghStorage.getDirectory().remove("nodes_ch_" + c.getName());
ghStorage.getDirectory().remove("shortcuts_" + c.getName());
}
return c.getName();
}).collect(Collectors.toList());
GHUtility.runConcurrently(callables, preparationThreads);
return loaded;
}
use of com.graphhopper.storage.CHConfig in project graphhopper by graphhopper.
the class AlternativeRouteCHTest method prepareCH.
private RoutingCHGraph prepareCH(GraphHopperStorage graph) {
// Carefully construct the CH so that the forward tree and the backward tree
// meet on all four possible paths from 5 to 10
// 5 ---> 11 will be reachable via shortcuts, as 11 is on shortest path 5 --> 12
final int[] nodeOrdering = new int[] { 0, 10, 12, 4, 3, 2, 5, 1, 6, 7, 8, 9, 11 };
CHConfig chConfig = CHConfig.nodeBased("p", new FastestWeighting(carFE));
PrepareContractionHierarchies contractionHierarchies = PrepareContractionHierarchies.fromGraphHopperStorage(graph, chConfig);
contractionHierarchies.useFixedNodeOrdering(NodeOrderingProvider.fromArray(nodeOrdering));
PrepareContractionHierarchies.Result res = contractionHierarchies.doWork();
return graph.createCHGraph(res.getCHStorage(), res.getCHConfig());
}
Aggregations