Search in sources :

Example 6 with FastestWeighting

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

the class PrepareContractionHierarchiesTest method testMultiplePreparationsIdenticalView.

@Test
public void testMultiplePreparationsIdenticalView() {
    CarFlagEncoder tmpCarEncoder = new CarFlagEncoder();
    BikeFlagEncoder tmpBikeEncoder = new BikeFlagEncoder();
    EncodingManager tmpEncodingManager = new EncodingManager(tmpCarEncoder, tmpBikeEncoder);
    // FastestWeighting would lead to different shortcuts due to different default speeds for bike and car
    Weighting carWeighting = new ShortestWeighting(tmpCarEncoder);
    Weighting bikeWeighting = new ShortestWeighting(tmpBikeEncoder);
    List<Weighting> chWeightings = Arrays.asList(carWeighting, bikeWeighting);
    GraphHopperStorage ghStorage = new GraphHopperStorage(chWeightings, dir, tmpEncodingManager, false, new GraphExtension.NoOpExtension()).create(1000);
    initShortcutsGraph(ghStorage);
    ghStorage.freeze();
    for (Weighting w : chWeightings) {
        checkPath(ghStorage, w, 7, 5, Helper.createTList(3, 9, 14, 16, 13, 12));
    }
}
Also used : EncodingManager(com.graphhopper.routing.util.EncodingManager) FastestWeighting(com.graphhopper.routing.weighting.FastestWeighting) Weighting(com.graphhopper.routing.weighting.Weighting) ShortestWeighting(com.graphhopper.routing.weighting.ShortestWeighting) BikeFlagEncoder(com.graphhopper.routing.util.BikeFlagEncoder) CarFlagEncoder(com.graphhopper.routing.util.CarFlagEncoder) ShortestWeighting(com.graphhopper.routing.weighting.ShortestWeighting) Test(org.junit.Test)

Example 7 with FastestWeighting

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

the class PathTest method testFound.

@Test
public void testFound() {
    GraphHopperStorage g = new GraphBuilder(carManager).create();
    Path p = new Path(g, new FastestWeighting(encoder));
    assertFalse(p.isFound());
    assertEquals(0, p.getDistance(), 1e-7);
    assertEquals(0, p.calcNodes().size());
    g.close();
}
Also used : FastestWeighting(com.graphhopper.routing.weighting.FastestWeighting) Test(org.junit.Test)

Example 8 with FastestWeighting

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

the class LandmarkStorageTest method testWithOnewaySubnetworks.

@Test
public void testWithOnewaySubnetworks() {
    // should not happen with subnetwork preparation
    // create an indifferent problem: node 2 and 3 are part of two 'disconnected' subnetworks
    ghStorage.edge(0, 1, 10, true);
    ghStorage.edge(1, 2, 10, false);
    ghStorage.edge(2, 3, 10, false);
    ghStorage.edge(4, 5, 10, true);
    ghStorage.edge(5, 2, 10, false);
    LandmarkStorage storage = new LandmarkStorage(ghStorage, new RAMDirectory(), new FastestWeighting(encoder), 2);
    storage.setMinimumNodes(2);
    storage.createLandmarks();
    assertEquals(2, storage.getSubnetworksWithLandmarks());
    assertEquals("[4, 0]", Arrays.toString(storage.getLandmarks(1)));
}
Also used : FastestWeighting(com.graphhopper.routing.weighting.FastestWeighting) Test(org.junit.Test)

Example 9 with FastestWeighting

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

the class LandmarkStorageTest method testWeightingConsistence.

@Test
public void testWeightingConsistence() {
    // create an indifferent problem: shortest weighting can pass the speed==0 edge but fastest cannot (?)
    ghStorage.edge(0, 1, 10, true);
    ghStorage.edge(1, 2).setDistance(10).setFlags(encoder.setProperties(0.9, true, true));
    ghStorage.edge(2, 3, 10, true);
    LandmarkStorage storage = new LandmarkStorage(ghStorage, new RAMDirectory(), new FastestWeighting(encoder), 2);
    storage.setMinimumNodes(2);
    storage.createLandmarks();
    assertEquals(2, storage.getSubnetworksWithLandmarks());
    assertEquals("[1, 0]", Arrays.toString(storage.getLandmarks(1)));
}
Also used : FastestWeighting(com.graphhopper.routing.weighting.FastestWeighting) Test(org.junit.Test)

Example 10 with FastestWeighting

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

the class LandmarkStorageTest method testWithSubnetworks2.

@Test
public void testWithSubnetworks2() {
    // should not happen with subnetwork preparation
    // 0 - 1 - 2 = 3 - 4
    ghStorage.edge(0, 1, 10, true);
    ghStorage.edge(1, 2, 10, true);
    ghStorage.edge(2, 3, 10, false);
    ghStorage.edge(3, 2, 10, false);
    ghStorage.edge(3, 4, 10, true);
    LandmarkStorage storage = new LandmarkStorage(ghStorage, new RAMDirectory(), new FastestWeighting(encoder), 2);
    storage.setMinimumNodes(3);
    storage.createLandmarks();
    assertEquals(2, storage.getSubnetworksWithLandmarks());
    assertEquals("[4, 0]", Arrays.toString(storage.getLandmarks(1)));
}
Also used : FastestWeighting(com.graphhopper.routing.weighting.FastestWeighting) Test(org.junit.Test)

Aggregations

FastestWeighting (com.graphhopper.routing.weighting.FastestWeighting)35 Test (org.junit.Test)33 Weighting (com.graphhopper.routing.weighting.Weighting)15 ShortestWeighting (com.graphhopper.routing.weighting.ShortestWeighting)6 GraphHopperStorage (com.graphhopper.storage.GraphHopperStorage)5 QueryResult (com.graphhopper.storage.index.QueryResult)5 CarFlagEncoder (com.graphhopper.routing.util.CarFlagEncoder)4 EncodingManager (com.graphhopper.routing.util.EncodingManager)4 Graph (com.graphhopper.storage.Graph)4 GHPoint (com.graphhopper.util.shapes.GHPoint)4 RAMDirectory (com.graphhopper.storage.RAMDirectory)3 LocationIndex (com.graphhopper.storage.index.LocationIndex)3 LocationIndexTree (com.graphhopper.storage.index.LocationIndexTree)3 EdgeIteratorState (com.graphhopper.util.EdgeIteratorState)3 GHRequest (com.graphhopper.GHRequest)2 GHResponse (com.graphhopper.GHResponse)2 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