Search in sources :

Example 76 with GraphHopper

use of com.graphhopper.GraphHopper in project graphhopper by graphhopper.

the class RoutingAlgorithmWithOSMTest method testMonacoBike.

@Test
public void testMonacoBike() {
    List<Query> queries = new ArrayList<>();
    queries.add(new Query(43.730864, 7.420771, 43.727687, 7.418737, 1642, 87));
    queries.add(new Query(43.727687, 7.418737, 43.74958, 7.436566, 3580, 168));
    queries.add(new Query(43.728677, 7.41016, 43.739213, 7.427806, 2323, 121));
    queries.add(new Query(43.733802, 7.413433, 43.739662, 7.424355, 1434, 89));
    GraphHopper hopper = createHopper(MONACO, new Profile("bike").setVehicle("bike").setWeighting("shortest"));
    hopper.importOrLoad();
    checkQueries(hopper, queries);
}
Also used : ArrayList(java.util.ArrayList) GraphHopper(com.graphhopper.GraphHopper) Profile(com.graphhopper.config.Profile) CHProfile(com.graphhopper.config.CHProfile) LMProfile(com.graphhopper.config.LMProfile) Test(org.junit.jupiter.api.Test)

Example 77 with GraphHopper

use of com.graphhopper.GraphHopper in project graphhopper by graphhopper.

the class RoutingAlgorithmWithOSMTest method testBug1014.

@Test
public void testBug1014() {
    List<Query> queries = new ArrayList<>();
    Query query = new Query();
    query.add(50.015861, 11.51041, 0, 0);
    query.add(50.019129, 11.500325, 0, 0);
    query.add(50.023623, 11.56929, 6777, 175);
    queries.add(query);
    GraphHopper hopper = createHopper(BAYREUTH, new Profile("bike").setVehicle("bike").setWeighting("fastest"));
    hopper.importOrLoad();
    checkQueries(hopper, queries);
}
Also used : ArrayList(java.util.ArrayList) GraphHopper(com.graphhopper.GraphHopper) Profile(com.graphhopper.config.Profile) CHProfile(com.graphhopper.config.CHProfile) LMProfile(com.graphhopper.config.LMProfile) Test(org.junit.jupiter.api.Test)

Example 78 with GraphHopper

use of com.graphhopper.GraphHopper in project graphhopper by graphhopper.

the class RoutingAlgorithmWithOSMTest method testAndorraPbf.

@Test
public void testAndorraPbf() {
    Profile profile = new Profile("car").setVehicle("car").setWeighting("shortest");
    GraphHopper hopper = createHopper(ANDORRA_PBF, profile);
    hopper.importOrLoad();
    checkQueries(hopper, createAndorraQueries());
}
Also used : GraphHopper(com.graphhopper.GraphHopper) Profile(com.graphhopper.config.Profile) CHProfile(com.graphhopper.config.CHProfile) LMProfile(com.graphhopper.config.LMProfile) Test(org.junit.jupiter.api.Test)

Example 79 with GraphHopper

use of com.graphhopper.GraphHopper in project graphhopper by graphhopper.

the class OSMReaderTest method testOneWay.

@Test
public void testOneWay() {
    GraphHopper hopper = new GraphHopperFacade(file2).setMinNetworkSize(0).importOrLoad();
    GraphHopperStorage graph = hopper.getGraphHopperStorage();
    assertEquals("2014-01-02T01:10:14Z", graph.getProperties().get("datareader.data.date"));
    int n20 = AbstractGraphStorageTester.getIdOf(graph, 52.0);
    int n22 = AbstractGraphStorageTester.getIdOf(graph, 52.133);
    int n23 = AbstractGraphStorageTester.getIdOf(graph, 52.144);
    int n10 = AbstractGraphStorageTester.getIdOf(graph, 51.2492152);
    int n30 = AbstractGraphStorageTester.getIdOf(graph, 51.2);
    assertEquals(1, GHUtility.count(carOutExplorer.setBaseNode(n10)));
    assertEquals(2, GHUtility.count(carOutExplorer.setBaseNode(n20)));
    assertEquals(0, GHUtility.count(carOutExplorer.setBaseNode(n30)));
    EdgeIterator iter = carOutExplorer.setBaseNode(n20);
    assertTrue(iter.next());
    assertTrue(iter.next());
    assertEquals(n30, iter.getAdjNode());
    iter = carAllExplorer.setBaseNode(n20);
    assertTrue(iter.next());
    assertEquals(n23, iter.getAdjNode());
    assertTrue(iter.get(carAccessEnc));
    assertFalse(iter.getReverse(carAccessEnc));
    assertTrue(iter.next());
    assertEquals(n22, iter.getAdjNode());
    assertFalse(iter.get(carAccessEnc));
    assertTrue(iter.getReverse(carAccessEnc));
    assertTrue(iter.next());
    assertFalse(iter.get(carAccessEnc));
    assertTrue(iter.getReverse(carAccessEnc));
    assertTrue(iter.next());
    assertEquals(n30, iter.getAdjNode());
    assertTrue(iter.get(carAccessEnc));
    assertFalse(iter.getReverse(carAccessEnc));
    assertTrue(iter.next());
    assertEquals(n10, iter.getAdjNode());
    assertFalse(iter.get(carAccessEnc));
    assertTrue(iter.getReverse(carAccessEnc));
}
Also used : GraphHopper(com.graphhopper.GraphHopper) Test(org.junit.jupiter.api.Test) GraphHopperTest(com.graphhopper.GraphHopperTest)

Example 80 with GraphHopper

use of com.graphhopper.GraphHopper in project graphhopper by graphhopper.

the class RoutingAlgorithmWithOSMTest method createHopper.

/**
 * Creates a {@link GraphHopper} instance with some default settings for this test. The settings can
 * be adjusted before calling {@link GraphHopper#importOrLoad()}
 */
private GraphHopper createHopper(String osmFile, Profile... profiles) {
    GraphHopper hopper = new GraphHopper().setStoreOnFlush(true).setOSMFile(osmFile).setProfiles(profiles).setGraphHopperLocation(GH_LOCATION);
    hopper.getRouterConfig().setSimplifyResponse(false);
    hopper.setMinNetworkSize(0);
    hopper.getReaderConfig().setMaxWayPointDistance(0);
    hopper.getLMPreparationHandler().setLMProfiles(new LMProfile(profiles[0].getName()));
    hopper.getCHPreparationHandler().setCHProfiles(new CHProfile(profiles[0].getName()));
    return hopper;
}
Also used : CHProfile(com.graphhopper.config.CHProfile) LMProfile(com.graphhopper.config.LMProfile) GraphHopper(com.graphhopper.GraphHopper)

Aggregations

GraphHopper (com.graphhopper.GraphHopper)101 Test (org.junit.jupiter.api.Test)62 Profile (com.graphhopper.config.Profile)52 LMProfile (com.graphhopper.config.LMProfile)44 CHProfile (com.graphhopper.config.CHProfile)39 GraphHopperTest (com.graphhopper.GraphHopperTest)25 ArrayList (java.util.ArrayList)24 File (java.io.File)16 Test (org.junit.Test)11 SRTMProvider (com.graphhopper.reader.dem.SRTMProvider)10 GHRequest (com.graphhopper.GHRequest)7 GHResponse (com.graphhopper.GHResponse)7 GraphHopperConfig (com.graphhopper.GraphHopperConfig)6 GraphHopperOSM (com.graphhopper.reader.osm.GraphHopperOSM)6 EncodingManager (com.graphhopper.routing.util.EncodingManager)6 PMap (com.graphhopper.util.PMap)6 GHPoint (com.graphhopper.util.shapes.GHPoint)5 IOException (java.io.IOException)5 Gpx (com.graphhopper.jackson.Gpx)4 MapMatching (com.graphhopper.matching.MapMatching)4