Search in sources :

Example 31 with Profile

use of com.graphhopper.config.Profile in project graphhopper by graphhopper.

the class RoutingAlgorithmWithOSMTest method testMoscowTurnCosts.

@Test
public void testMoscowTurnCosts() {
    List<Query> queries = new ArrayList<>();
    queries.add(new Query(55.813357, 37.5958585, 55.811042, 37.594689, 1043.99, 12));
    queries.add(new Query(55.813159, 37.593884, 55.811278, 37.594217, 1048, 13));
    GraphHopper hopper = createHopper(MOSCOW, new Profile("car").setVehicle("car").setWeighting("fastest").setTurnCosts(true));
    hopper.setMinNetworkSize(200);
    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 32 with Profile

use of com.graphhopper.config.Profile in project graphhopper by graphhopper.

the class RoutingAlgorithmWithOSMTest method testMonacoParallel.

@Test
public void testMonacoParallel() throws InterruptedException {
    GraphHopper hopper = createHopper(MONACO, new Profile("car").setVehicle("car").setWeighting("shortest"));
    hopper.getReaderConfig().setMaxWayPointDistance(0);
    hopper.getRouterConfig().setSimplifyResponse(false);
    hopper.importOrLoad();
    final List<Query> queries = createMonacoCarQueries();
    List<Thread> threads = new ArrayList<>();
    final AtomicInteger routeCount = new AtomicInteger(0);
    // testing if algorithms are independent. should be. so test only two algorithms.
    List<Function<Query, GHRequest>> requestFactories = Arrays.asList(q -> createRequest(q).setAlgorithm(DIJKSTRA_BI).setProfile("car"), q -> createRequest(q).setAlgorithm(ASTAR_BI).setProfile("car"));
    int loops = 100;
    for (int i = 0; i < loops; i++) {
        for (Query query : queries) {
            for (Function<Query, GHRequest> requestFactory : requestFactories) {
                GHRequest req = requestFactory.apply(query);
                Thread t = new Thread(() -> {
                    GHResponse res = hopper.route(req);
                    checkResponse(res, query);
                    routeCount.incrementAndGet();
                });
                t.start();
                threads.add(t);
            }
        }
    }
    for (Thread t : threads) t.join();
    assertEquals(loops * queries.size() * requestFactories.size(), routeCount.get());
}
Also used : ArrayList(java.util.ArrayList) GraphHopper(com.graphhopper.GraphHopper) GHResponse(com.graphhopper.GHResponse) Profile(com.graphhopper.config.Profile) CHProfile(com.graphhopper.config.CHProfile) LMProfile(com.graphhopper.config.LMProfile) GHPoint(com.graphhopper.util.shapes.GHPoint) Function(java.util.function.Function) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) GHRequest(com.graphhopper.GHRequest) Test(org.junit.jupiter.api.Test)

Example 33 with Profile

use of com.graphhopper.config.Profile in project graphhopper by graphhopper.

the class RoutingAlgorithmWithOSMTest method testOneWayCircleBug.

@Test
public void testOneWayCircleBug() {
    // export from http://www.openstreetmap.org/export#map=19/51.37605/-0.53155
    List<Query> queries = new ArrayList<>();
    // going the bit longer way out of the circle
    queries.add(new Query(51.376197, -0.531576, 51.376509, -0.530863, 153, 18));
    // now exacle the opposite direction: going into the circle (shorter)
    queries.add(new Query(51.376509, -0.530863, 51.376197, -0.531576, 75, 15));
    GraphHopper hopper = createHopper(DIR + "/circle-bug.osm.gz", new Profile("car").setVehicle("car").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 34 with Profile

use of com.graphhopper.config.Profile in project graphhopper by graphhopper.

the class RoutingAlgorithmWithOSMTest method testAndorra.

@Test
public void testAndorra() {
    Profile profile = new Profile("car").setVehicle("car").setWeighting("shortest");
    GraphHopper hopper = createHopper(ANDORRA, 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 35 with Profile

use of com.graphhopper.config.Profile in project graphhopper by graphhopper.

the class RoutingAlgorithmWithOSMTest method testMonacoRacingBike.

@Test
public void testMonacoRacingBike() {
    List<Query> queries = new ArrayList<>();
    queries.add(new Query(43.730864, 7.420771, 43.727687, 7.418737, 2594, 111));
    queries.add(new Query(43.727687, 7.418737, 43.74958, 7.436566, 3614, 184));
    queries.add(new Query(43.728677, 7.41016, 43.739213, 7.427806, 2572, 135));
    queries.add(new Query(43.733802, 7.413433, 43.739662, 7.424355, 1490, 84));
    GraphHopper hopper = createHopper(MONACO, new Profile("racingbike").setVehicle("racingbike").setWeighting("fastest"));
    hopper.importOrLoad();
    checkQueries(hopper, queries);
    Helper.removeDir(new File(GH_LOCATION));
    hopper = createHopper(MONACO, new Profile("racingbike").setVehicle("racingbike").setWeighting("fastest"), new Profile("bike").setVehicle("bike").setWeighting("fastest"));
    hopper.importOrLoad();
    checkQueries(hopper, queries);
}
Also used : ArrayList(java.util.ArrayList) GraphHopper(com.graphhopper.GraphHopper) File(java.io.File) Profile(com.graphhopper.config.Profile) CHProfile(com.graphhopper.config.CHProfile) LMProfile(com.graphhopper.config.LMProfile) Test(org.junit.jupiter.api.Test)

Aggregations

Profile (com.graphhopper.config.Profile)203 LMProfile (com.graphhopper.config.LMProfile)167 CHProfile (com.graphhopper.config.CHProfile)164 Test (org.junit.jupiter.api.Test)138 CustomProfile (com.graphhopper.routing.weighting.custom.CustomProfile)84 GraphHopper (com.graphhopper.GraphHopper)54 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)54 GHPoint (com.graphhopper.util.shapes.GHPoint)35 ArrayList (java.util.ArrayList)29 File (java.io.File)25 GraphHopperServerConfiguration (com.graphhopper.application.GraphHopperServerConfiguration)19 GraphHopperServerTestConfiguration (com.graphhopper.application.util.GraphHopperServerTestConfiguration)19 PMap (com.graphhopper.util.PMap)14 SRTMProvider (com.graphhopper.reader.dem.SRTMProvider)11 BeforeAll (org.junit.jupiter.api.BeforeAll)10 Weighting (com.graphhopper.routing.weighting.Weighting)9 LocationIndexTree (com.graphhopper.storage.index.LocationIndexTree)8 TranslationMap (com.graphhopper.util.TranslationMap)7 Snap (com.graphhopper.storage.index.Snap)6 GHRequest (com.graphhopper.GHRequest)5