Search in sources :

Example 1 with TurnCostProvider

use of com.graphhopper.routing.weighting.TurnCostProvider in project graphhopper by graphhopper.

the class AlternativeRouteEdgeCHTest method testAssumptions.

@Test
public void testAssumptions() {
    GraphHopperStorage g = createTestGraph(em);
    TurnCostProvider turnCostProvider = new DefaultTurnCostProvider(carFE, g.getTurnCostStorage());
    CHConfig chConfig = CHConfig.edgeBased("profile", new FastestWeighting(carFE, turnCostProvider));
    CHStorage chStorage = g.createCHStorage(chConfig);
    RoutingCHGraph chGraph = g.createCHGraph(chStorage, chConfig);
    DijkstraBidirectionEdgeCHNoSOD router = new DijkstraBidirectionEdgeCHNoSOD(chGraph);
    Path path = router.calcPath(5, 10);
    assertTrue(path.isFound());
    assertEquals(IntArrayList.from(5, 6, 7, 8, 4, 10), path.calcNodes());
    assertEquals(50000.0, path.getDistance(), 0.0);
    // 6 -> 3 -> 4 is forbidden
    g = createTestGraph(em);
    RoutingCHGraph routingCHGraph = prepareCH(g);
    router = new DijkstraBidirectionEdgeCHNoSOD(routingCHGraph);
    path = router.calcPath(5, 3, ANY_EDGE, GHUtility.getEdge(g, 2, 3).getEdge());
    assertEquals(IntArrayList.from(5, 1, 9, 2, 3), path.calcNodes());
    assertEquals(40000.0, path.getDistance(), 0.0);
// We can specifically route to the desired in-edge at node 3
// which does not lie upstream of the turn-restriction.
}
Also used : TurnCostProvider(com.graphhopper.routing.weighting.TurnCostProvider) DefaultTurnCostProvider(com.graphhopper.routing.weighting.DefaultTurnCostProvider) FastestWeighting(com.graphhopper.routing.weighting.FastestWeighting) DefaultTurnCostProvider(com.graphhopper.routing.weighting.DefaultTurnCostProvider) Test(org.junit.jupiter.api.Test)

Example 2 with TurnCostProvider

use of com.graphhopper.routing.weighting.TurnCostProvider in project graphhopper by graphhopper.

the class AlternativeRouteEdgeCHTest method prepareCH.

private RoutingCHGraph prepareCH(GraphHopperStorage graph) {
    TurnCostProvider turnCostProvider = new DefaultTurnCostProvider(carFE, graph.getTurnCostStorage());
    CHConfig chConfig = CHConfig.edgeBased("profile", new FastestWeighting(carFE, turnCostProvider));
    PrepareContractionHierarchies contractionHierarchies = PrepareContractionHierarchies.fromGraphHopperStorage(graph, chConfig);
    PrepareContractionHierarchies.Result res = contractionHierarchies.doWork();
    return graph.createCHGraph(res.getCHStorage(), res.getCHConfig());
}
Also used : TurnCostProvider(com.graphhopper.routing.weighting.TurnCostProvider) DefaultTurnCostProvider(com.graphhopper.routing.weighting.DefaultTurnCostProvider) PrepareContractionHierarchies(com.graphhopper.routing.ch.PrepareContractionHierarchies) FastestWeighting(com.graphhopper.routing.weighting.FastestWeighting) DefaultTurnCostProvider(com.graphhopper.routing.weighting.DefaultTurnCostProvider)

Aggregations

DefaultTurnCostProvider (com.graphhopper.routing.weighting.DefaultTurnCostProvider)2 FastestWeighting (com.graphhopper.routing.weighting.FastestWeighting)2 TurnCostProvider (com.graphhopper.routing.weighting.TurnCostProvider)2 PrepareContractionHierarchies (com.graphhopper.routing.ch.PrepareContractionHierarchies)1 Test (org.junit.jupiter.api.Test)1