Search in sources :

Example 86 with EdgeIteratorState

use of com.graphhopper.util.EdgeIteratorState in project graphhopper by graphhopper.

the class NodeContractorTest method testContractNode_bidirected_shortcutsRequired.

@Test
public void testContractNode_bidirected_shortcutsRequired() {
    // 0 -- 1 -- 2
    final EdgeIteratorState edge1 = graph.edge(0, 1, 1, true);
    final EdgeIteratorState edge2 = graph.edge(1, 2, 2, true);
    graph.freeze();
    setMaxLevelOnAllNodes();
    createNodeContractor().contractNode(1);
    checkShortcuts(expectedShortcut(0, 2, edge2, edge1, true, true));
}
Also used : EdgeIteratorState(com.graphhopper.util.EdgeIteratorState) CHEdgeIteratorState(com.graphhopper.util.CHEdgeIteratorState) Test(org.junit.Test)

Example 87 with EdgeIteratorState

use of com.graphhopper.util.EdgeIteratorState in project graphhopper by graphhopper.

the class NodeContractorTest method testDirectedGraph.

@Test
public void testDirectedGraph() {
    // 5 6 7
    // \|/
    // 4-3_1<-\ 10
    // \_|/
    // 0___2_11
    graph.edge(0, 2, 2, true);
    graph.edge(10, 2, 2, true);
    graph.edge(11, 2, 2, true);
    // create a longer one directional edge => no longish one-dir shortcut should be created
    final EdgeIteratorState edge2to1bidirected = graph.edge(2, 1, 2, true);
    final EdgeIteratorState edge2to1directed = graph.edge(2, 1, 10, false);
    final EdgeIteratorState edge1to3 = graph.edge(1, 3, 2, true);
    graph.edge(3, 4, 2, true);
    graph.edge(3, 5, 2, true);
    graph.edge(3, 6, 2, true);
    graph.edge(3, 7, 2, true);
    graph.freeze();
    setMaxLevelOnAllNodes();
    // find all shortcuts if we contract node 1
    NodeContractor nodeContractor = createNodeContractor();
    nodeContractor.contractNode(1);
    checkShortcuts(expectedShortcut(2, 3, edge1to3, edge2to1bidirected, true, true), expectedShortcut(2, 3, edge2to1directed, edge1to3, true, false));
}
Also used : EdgeIteratorState(com.graphhopper.util.EdgeIteratorState) CHEdgeIteratorState(com.graphhopper.util.CHEdgeIteratorState) Test(org.junit.Test)

Example 88 with EdgeIteratorState

use of com.graphhopper.util.EdgeIteratorState in project graphhopper by graphhopper.

the class LandmarkStorageTest method testInfinitWeight.

@Test
public void testInfinitWeight() {
    Directory dir = new RAMDirectory();
    EdgeIteratorState edge = ghStorage.edge(0, 1);
    int res = new LandmarkStorage(ghStorage, dir, new FastestWeighting(encoder) {

        @Override
        public double calcWeight(EdgeIteratorState edgeState, boolean reverse, int prevOrNextEdgeId) {
            return Integer.MAX_VALUE * 2L;
        }
    }, 8).setMaximumWeight(LandmarkStorage.PRECISION).calcWeight(edge, false);
    assertEquals(Integer.MAX_VALUE, res);
    dir = new RAMDirectory();
    res = new LandmarkStorage(ghStorage, dir, new FastestWeighting(encoder) {

        @Override
        public double calcWeight(EdgeIteratorState edgeState, boolean reverse, int prevOrNextEdgeId) {
            return Double.POSITIVE_INFINITY;
        }
    }, 8).setMaximumWeight(LandmarkStorage.PRECISION).calcWeight(edge, false);
    assertEquals(Integer.MAX_VALUE, res);
}
Also used : EdgeIteratorState(com.graphhopper.util.EdgeIteratorState) FastestWeighting(com.graphhopper.routing.weighting.FastestWeighting) GHPoint(com.graphhopper.util.shapes.GHPoint) Test(org.junit.Test)

Example 89 with EdgeIteratorState

use of com.graphhopper.util.EdgeIteratorState in project graphhopper by graphhopper.

the class NameSimilarityEdgeFilterTest method testAcceptFromNominatim.

/**
 * With Nominatim you should not use the "placename" for best results, otherwise the length difference becomes too big
 */
@Test
public void testAcceptFromNominatim() {
    EdgeFilter edgeFilter;
    EdgeIteratorState edge;
    edgeFilter = new NameSimilarityEdgeFilter(new DefaultEdgeFilter(new CarFlagEncoder()), "Wentworth Street, Caringbah South");
    edge = createTestEdgeIterator("Wentworth Street");
    assertTrue(edgeFilter.accept(edge));
    edgeFilter = new NameSimilarityEdgeFilter(new DefaultEdgeFilter(new CarFlagEncoder()), "Zum Toffental, Altdorf bei Nürnnberg");
    edge = createTestEdgeIterator("Zum Toffental");
    assertTrue(edgeFilter.accept(edge));
}
Also used : EdgeIteratorState(com.graphhopper.util.EdgeIteratorState) Test(org.junit.Test)

Example 90 with EdgeIteratorState

use of com.graphhopper.util.EdgeIteratorState in project graphhopper by graphhopper.

the class GenericWeightingTest method testCalcTime.

@Test
public void testCalcTime() {
    GenericWeighting weighting = new GenericWeighting(encoder, new HintsMap());
    EdgeIteratorState edge = graph.getEdgeIteratorState(0, 1);
    assertEquals(edgeWeight, weighting.calcMillis(edge, false, EdgeIterator.NO_EDGE), .1);
}
Also used : HintsMap(com.graphhopper.routing.util.HintsMap) EdgeIteratorState(com.graphhopper.util.EdgeIteratorState) Test(org.junit.Test)

Aggregations

EdgeIteratorState (com.graphhopper.util.EdgeIteratorState)137 Test (org.junit.jupiter.api.Test)55 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)25 Test (org.junit.Test)22 RepeatedTest (org.junit.jupiter.api.RepeatedTest)17 FlagEncoder (com.graphhopper.routing.util.FlagEncoder)13 Snap (com.graphhopper.storage.index.Snap)12 GraphHopperStorage (com.graphhopper.storage.GraphHopperStorage)11 CHEdgeIteratorState (com.graphhopper.util.CHEdgeIteratorState)11 QueryGraph (com.graphhopper.routing.querygraph.QueryGraph)10 FastestWeighting (com.graphhopper.routing.weighting.FastestWeighting)10 NodeAccess (com.graphhopper.storage.NodeAccess)10 GHIntHashSet (com.graphhopper.coll.GHIntHashSet)9 GraphBuilder (com.graphhopper.storage.GraphBuilder)8 QueryRoutingCHGraph (com.graphhopper.routing.querygraph.QueryRoutingCHGraph)7 DecimalEncodedValue (com.graphhopper.routing.ev.DecimalEncodedValue)6 EncodingManager (com.graphhopper.routing.util.EncodingManager)6 GHPoint (com.graphhopper.util.shapes.GHPoint)6 Fun (org.mapdb.Fun)6 IntArrayList (com.carrotsearch.hppc.IntArrayList)5