Search in sources :

Example 31 with FastestWeighting

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

the class LandmarkStorageTest method testWithSubnetworks.

@Test
public void testWithSubnetworks() {
    ghStorage.edge(0, 1, 10, true);
    ghStorage.edge(1, 2, 10, true);
    ghStorage.edge(2, 4).setFlags(encoder.setAccess(0, false, false));
    ghStorage.edge(4, 5, 10, true);
    ghStorage.edge(5, 6, 10, false);
    LandmarkStorage storage = new LandmarkStorage(ghStorage, new RAMDirectory(), 2, new FastestWeighting(encoder), TraversalMode.NODE_BASED);
    storage.setMinimumNodes(2);
    storage.createLandmarks();
    assertEquals(3, storage.getSubnetworksWithLandmarks());
    assertEquals("[2, 0]", Arrays.toString(storage.getLandmarks(1)));
    assertEquals("[6, 4]", Arrays.toString(storage.getLandmarks(2)));
}
Also used : FastestWeighting(com.graphhopper.routing.weighting.FastestWeighting) Test(org.junit.Test)

Example 32 with FastestWeighting

use of com.graphhopper.routing.weighting.FastestWeighting 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, 8, new FastestWeighting(encoder) {

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

        @Override
        public double calcWeight(EdgeIteratorState edgeState, boolean reverse, int prevOrNextEdgeId) {
            return Double.POSITIVE_INFINITY;
        }
    }, TraversalMode.NODE_BASED).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)

Aggregations

FastestWeighting (com.graphhopper.routing.weighting.FastestWeighting)32 Test (org.junit.Test)30 Weighting (com.graphhopper.routing.weighting.Weighting)14 ShortestWeighting (com.graphhopper.routing.weighting.ShortestWeighting)6 Graph (com.graphhopper.storage.Graph)5 CarFlagEncoder (com.graphhopper.routing.util.CarFlagEncoder)4 EncodingManager (com.graphhopper.routing.util.EncodingManager)4 GraphHopperStorage (com.graphhopper.storage.GraphHopperStorage)4 QueryResult (com.graphhopper.storage.index.QueryResult)4 GHPoint (com.graphhopper.util.shapes.GHPoint)3 BikeFlagEncoder (com.graphhopper.routing.util.BikeFlagEncoder)2 DefaultEdgeFilter (com.graphhopper.routing.util.DefaultEdgeFilter)2 EdgeFilter (com.graphhopper.routing.util.EdgeFilter)2 AbstractWeighting (com.graphhopper.routing.weighting.AbstractWeighting)2 GraphBuilder (com.graphhopper.storage.GraphBuilder)2 RAMDirectory (com.graphhopper.storage.RAMDirectory)2 SPTEntry (com.graphhopper.storage.SPTEntry)2 LocationIndex (com.graphhopper.storage.index.LocationIndex)2 LocationIndexTree (com.graphhopper.storage.index.LocationIndexTree)2 EdgeExplorer (com.graphhopper.util.EdgeExplorer)2