Search in sources :

Example 1 with LMRoutingAlgorithmFactory

use of com.graphhopper.routing.lm.LMRoutingAlgorithmFactory in project graphhopper by graphhopper.

the class MiniGraphUI method createAlgo.

private RoutingAlgorithm createAlgo(GraphHopper hopper) {
    Profile profile = hopper.getProfiles().iterator().next();
    if (useCH) {
        RoutingCHGraph chGraph = hopper.getCHGraphs().get(profile.getName());
        logger.info("CH algo, profile: " + profile.getName());
        QueryGraph qGraph = QueryGraph.create(hopper.getGraphHopperStorage(), fromRes, toRes);
        QueryRoutingCHGraph queryRoutingCHGraph = new QueryRoutingCHGraph(chGraph, qGraph);
        return new CHDebugAlgo(queryRoutingCHGraph, mg);
    } else {
        LandmarkStorage landmarks = hopper.getLandmarks().get(profile.getName());
        RoutingAlgorithmFactory algoFactory = (g, w, opts) -> {
            RoutingAlgorithm algo = new LMRoutingAlgorithmFactory(landmarks).createAlgo(g, w, opts);
            if (algo instanceof AStarBidirection) {
                return new DebugAStarBi(g, w, opts.getTraversalMode(), mg).setApproximation(((AStarBidirection) algo).getApproximation());
            } else if (algo instanceof AStar) {
                return new DebugAStar(g, w, opts.getTraversalMode(), mg);
            } else if (algo instanceof DijkstraBidirectionRef) {
                return new DebugDijkstraBidirection(g, w, opts.getTraversalMode(), mg);
            } else if (algo instanceof Dijkstra) {
                return new DebugDijkstraSimple(g, w, opts.getTraversalMode(), mg);
            }
            return algo;
        };
        AlgorithmOptions algoOpts = new AlgorithmOptions().setAlgorithm(Algorithms.ASTAR_BI);
        logger.info("algoOpts:" + algoOpts + ", weighting: " + landmarks.getWeighting() + ", profile: " + profile.getName());
        QueryGraph qGraph = QueryGraph.create(graph, fromRes, toRes);
        return algoFactory.createAlgo(qGraph, landmarks.getWeighting(), algoOpts);
    }
}
Also used : RoutingCHGraph(com.graphhopper.storage.RoutingCHGraph) Arrays(java.util.Arrays) GraphHopperConfig(com.graphhopper.GraphHopperConfig) EdgeFilter(com.graphhopper.routing.util.EdgeFilter) QueryRoutingCHGraph(com.graphhopper.routing.querygraph.QueryRoutingCHGraph) com.graphhopper.routing(com.graphhopper.routing) LoggerFactory(org.slf4j.LoggerFactory) Random(java.util.Random) LandmarkStorage(com.graphhopper.routing.lm.LandmarkStorage) LocationIndexTree(com.graphhopper.storage.index.LocationIndexTree) StopWatch(com.graphhopper.util.StopWatch) LMRoutingAlgorithmFactory(com.graphhopper.routing.lm.LMRoutingAlgorithmFactory) MouseWheelEvent(java.awt.event.MouseWheelEvent) DecimalEncodedValue(com.graphhopper.routing.ev.DecimalEncodedValue) Profile(com.graphhopper.config.Profile) MouseAdapter(java.awt.event.MouseAdapter) Graph(com.graphhopper.storage.Graph) GraphHopper(com.graphhopper.GraphHopper) FlagEncoder(com.graphhopper.routing.util.FlagEncoder) IntIndexedContainer(com.carrotsearch.hppc.IntIndexedContainer) Logger(org.slf4j.Logger) BBox(com.graphhopper.util.shapes.BBox) PMap(com.graphhopper.util.PMap) Algorithms(com.graphhopper.util.Parameters.Algorithms) BooleanEncodedValue(com.graphhopper.routing.ev.BooleanEncodedValue) CHProfile(com.graphhopper.config.CHProfile) QueryGraph(com.graphhopper.routing.querygraph.QueryGraph) PointList(com.graphhopper.util.PointList) MouseEvent(java.awt.event.MouseEvent) GHBitSet(com.graphhopper.coll.GHBitSet) java.awt(java.awt) GHTBitSet(com.graphhopper.coll.GHTBitSet) NodeAccess(com.graphhopper.storage.NodeAccess) MouseWheelListener(java.awt.event.MouseWheelListener) Snap(com.graphhopper.storage.index.Snap) FetchMode(com.graphhopper.util.FetchMode) LMProfile(com.graphhopper.config.LMProfile) AllEdgesIterator(com.graphhopper.routing.util.AllEdgesIterator) javax.swing(javax.swing) QueryRoutingCHGraph(com.graphhopper.routing.querygraph.QueryRoutingCHGraph) RoutingCHGraph(com.graphhopper.storage.RoutingCHGraph) QueryRoutingCHGraph(com.graphhopper.routing.querygraph.QueryRoutingCHGraph) LMRoutingAlgorithmFactory(com.graphhopper.routing.lm.LMRoutingAlgorithmFactory) Profile(com.graphhopper.config.Profile) CHProfile(com.graphhopper.config.CHProfile) LMProfile(com.graphhopper.config.LMProfile) LandmarkStorage(com.graphhopper.routing.lm.LandmarkStorage) LMRoutingAlgorithmFactory(com.graphhopper.routing.lm.LMRoutingAlgorithmFactory) QueryGraph(com.graphhopper.routing.querygraph.QueryGraph)

Aggregations

IntIndexedContainer (com.carrotsearch.hppc.IntIndexedContainer)1 GraphHopper (com.graphhopper.GraphHopper)1 GraphHopperConfig (com.graphhopper.GraphHopperConfig)1 GHBitSet (com.graphhopper.coll.GHBitSet)1 GHTBitSet (com.graphhopper.coll.GHTBitSet)1 CHProfile (com.graphhopper.config.CHProfile)1 LMProfile (com.graphhopper.config.LMProfile)1 Profile (com.graphhopper.config.Profile)1 com.graphhopper.routing (com.graphhopper.routing)1 BooleanEncodedValue (com.graphhopper.routing.ev.BooleanEncodedValue)1 DecimalEncodedValue (com.graphhopper.routing.ev.DecimalEncodedValue)1 LMRoutingAlgorithmFactory (com.graphhopper.routing.lm.LMRoutingAlgorithmFactory)1 LandmarkStorage (com.graphhopper.routing.lm.LandmarkStorage)1 QueryGraph (com.graphhopper.routing.querygraph.QueryGraph)1 QueryRoutingCHGraph (com.graphhopper.routing.querygraph.QueryRoutingCHGraph)1 AllEdgesIterator (com.graphhopper.routing.util.AllEdgesIterator)1 EdgeFilter (com.graphhopper.routing.util.EdgeFilter)1 FlagEncoder (com.graphhopper.routing.util.FlagEncoder)1 Graph (com.graphhopper.storage.Graph)1 NodeAccess (com.graphhopper.storage.NodeAccess)1