Search in sources :

Example 1 with VirtualEdgeIteratorState

use of com.graphhopper.routing.VirtualEdgeIteratorState in project graphhopper by graphhopper.

the class FastestWeightingTest method testWeightWrongHeading.

@Test
public void testWeightWrongHeading() {
    Weighting instance = new FastestWeighting(encoder, new PMap().put(Parameters.Routing.HEADING_PENALTY, "100"));
    VirtualEdgeIteratorState virtEdge = new VirtualEdgeIteratorState(0, 1, 1, 2, 10, encoder.setProperties(10, true, true), "test", Helper.createPointList(51, 0, 51, 1));
    double time = instance.calcWeight(virtEdge, false, 0);
    virtEdge.setUnfavored(true);
    // heading penalty on edge
    assertEquals(time + 100, instance.calcWeight(virtEdge, false, 0), 1e-8);
    // only after setting it
    virtEdge.setUnfavored(true);
    assertEquals(time + 100, instance.calcWeight(virtEdge, true, 0), 1e-8);
    // but not after releasing it
    virtEdge.setUnfavored(false);
    assertEquals(time, instance.calcWeight(virtEdge, true, 0), 1e-8);
    // test default penalty
    virtEdge.setUnfavored(true);
    instance = new FastestWeighting(encoder);
    assertEquals(time + Routing.DEFAULT_HEADING_PENALTY, instance.calcWeight(virtEdge, false, 0), 1e-8);
}
Also used : VirtualEdgeIteratorState(com.graphhopper.routing.VirtualEdgeIteratorState) PMap(com.graphhopper.util.PMap) Test(org.junit.Test)

Aggregations

VirtualEdgeIteratorState (com.graphhopper.routing.VirtualEdgeIteratorState)1 PMap (com.graphhopper.util.PMap)1 Test (org.junit.Test)1