Search in sources :

Example 26 with DecimalEncodedValue

use of com.graphhopper.routing.ev.DecimalEncodedValue in project graphhopper by graphhopper.

the class LMIssueTest method lm_issue2.

@ParameterizedTest
@EnumSource
public void lm_issue2(Algo algo) {
    // Before #1745 This would fail for LM, because an underrun of 'delta' would not be treated correctly,
    // and the remaining weight would be over-approximated
    // ---
    // /     \
    // 0 - 1 - 5 - 6 - 9 - 4 - 0
    // \     /
    // ->-
    NodeAccess na = graph.getNodeAccess();
    DecimalEncodedValue speedEnc = encoder.getAverageSpeedEnc();
    na.setNode(0, 49.406987, 9.709767);
    na.setNode(1, 49.403612, 9.702953);
    na.setNode(2, 49.409755, 9.706517);
    na.setNode(3, 49.409021, 9.708649);
    na.setNode(4, 49.400674, 9.700906);
    na.setNode(5, 49.408735, 9.709486);
    na.setNode(6, 49.406402, 9.700937);
    na.setNode(7, 49.406965, 9.702660);
    na.setNode(8, 49.405227, 9.702863);
    na.setNode(9, 49.409411, 9.709085);
    GHUtility.setSpeed(112, true, true, encoder, graph.edge(0, 1).setDistance(623.197000));
    GHUtility.setSpeed(13, true, true, encoder, graph.edge(5, 1).setDistance(741.414000));
    GHUtility.setSpeed(35, true, true, encoder, graph.edge(9, 4).setDistance(1140.835000));
    GHUtility.setSpeed(18, true, true, encoder, graph.edge(5, 6).setDistance(670.689000));
    GHUtility.setSpeed(88, true, false, encoder, graph.edge(5, 9).setDistance(80.731000));
    GHUtility.setSpeed(82, true, true, encoder, graph.edge(0, 9).setDistance(273.948000));
    GHUtility.setSpeed(60, true, true, encoder, graph.edge(4, 0).setDistance(956.552000));
    preProcessGraph();
    int source = 5;
    int target = 4;
    Path refPath = new DijkstraBidirectionRef(graph, weighting, NODE_BASED).calcPath(source, target);
    Path path = createAlgo(algo).calcPath(source, target);
    assertEquals(refPath.getWeight(), path.getWeight(), 1.e-2);
    assertEquals(refPath.getDistance(), path.getDistance(), 1.e-1);
    assertEquals(refPath.getTime(), path.getTime(), 50);
    assertEquals(refPath.calcNodes(), path.calcNodes());
}
Also used : DecimalEncodedValue(com.graphhopper.routing.ev.DecimalEncodedValue) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

DecimalEncodedValue (com.graphhopper.routing.ev.DecimalEncodedValue)26 Test (org.junit.jupiter.api.Test)15 BooleanEncodedValue (com.graphhopper.routing.ev.BooleanEncodedValue)6 Snap (com.graphhopper.storage.index.Snap)6 EdgeIteratorState (com.graphhopper.util.EdgeIteratorState)6 ReaderWay (com.graphhopper.reader.ReaderWay)4 FlagEncoder (com.graphhopper.routing.util.FlagEncoder)4 FastestWeighting (com.graphhopper.routing.weighting.FastestWeighting)4 IntsRef (com.graphhopper.storage.IntsRef)4 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)4 EncodingManager (com.graphhopper.routing.util.EncodingManager)3 DefaultTurnCostProvider (com.graphhopper.routing.weighting.DefaultTurnCostProvider)3 Weighting (com.graphhopper.routing.weighting.Weighting)3 Graph (com.graphhopper.storage.Graph)3 TurnCostStorage (com.graphhopper.storage.TurnCostStorage)3 Path (com.graphhopper.routing.Path)2 RoutingAlgorithm (com.graphhopper.routing.RoutingAlgorithm)2 QueryGraph (com.graphhopper.routing.querygraph.QueryGraph)2 CarFlagEncoder (com.graphhopper.routing.util.CarFlagEncoder)2 GraphBuilder (com.graphhopper.storage.GraphBuilder)2