Search in sources :

Example 1 with CHConfig

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;
}
Also used : RoutingCHGraph(com.graphhopper.storage.RoutingCHGraph) java.util(java.util) Logger(org.slf4j.Logger) GraphHopperConfig(com.graphhopper.GraphHopperConfig) Helper.createFormatter(com.graphhopper.util.Helper.createFormatter) PMap(com.graphhopper.util.PMap) LoggerFactory(org.slf4j.LoggerFactory) CHConfig(com.graphhopper.storage.CHConfig) CHStorage(com.graphhopper.storage.CHStorage) Callable(java.util.concurrent.Callable) GHUtility(com.graphhopper.util.GHUtility) CHProfile(com.graphhopper.config.CHProfile) Collectors(java.util.stream.Collectors) GraphHopperStorage(com.graphhopper.storage.GraphHopperStorage) Helper.getMemInfo(com.graphhopper.util.Helper.getMemInfo) CH(com.graphhopper.util.Parameters.CH) CHStorage(com.graphhopper.storage.CHStorage) RoutingCHGraph(com.graphhopper.storage.RoutingCHGraph) Callable(java.util.concurrent.Callable)

Example 2 with CHConfig

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());
}
Also used : CHConfig(com.graphhopper.storage.CHConfig) PrepareContractionHierarchies(com.graphhopper.routing.ch.PrepareContractionHierarchies) FastestWeighting(com.graphhopper.routing.weighting.FastestWeighting)

Aggregations

CHConfig (com.graphhopper.storage.CHConfig)2 GraphHopperConfig (com.graphhopper.GraphHopperConfig)1 CHProfile (com.graphhopper.config.CHProfile)1 PrepareContractionHierarchies (com.graphhopper.routing.ch.PrepareContractionHierarchies)1 FastestWeighting (com.graphhopper.routing.weighting.FastestWeighting)1 CHStorage (com.graphhopper.storage.CHStorage)1 GraphHopperStorage (com.graphhopper.storage.GraphHopperStorage)1 RoutingCHGraph (com.graphhopper.storage.RoutingCHGraph)1 GHUtility (com.graphhopper.util.GHUtility)1 Helper.createFormatter (com.graphhopper.util.Helper.createFormatter)1 Helper.getMemInfo (com.graphhopper.util.Helper.getMemInfo)1 PMap (com.graphhopper.util.PMap)1 CH (com.graphhopper.util.Parameters.CH)1 java.util (java.util)1 Callable (java.util.concurrent.Callable)1 Collectors (java.util.stream.Collectors)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1