Search in sources :

Example 21 with Profile

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

the class ProfileResolverTest method defaultVehicleAllAlgos.

@Test
public void defaultVehicleAllAlgos() {
    final String profile1 = "foot_profile";
    final String profile2 = "car_profile";
    final String vehicle1 = "foot";
    final String vehicle2 = "car";
    final String weighting = "shortest";
    ProfileResolver profileResolver = new ProfileResolver(EncodingManager.create(vehicle1 + "," + vehicle2), Arrays.asList(new Profile(profile1).setVehicle(vehicle1).setWeighting(weighting), new Profile(profile2).setVehicle(vehicle2).setWeighting(weighting)), Arrays.asList(new CHProfile(profile1), new CHProfile(profile2)), Arrays.asList(new LMProfile(profile1), new LMProfile(profile2)));
    // when we do not specify vehicle/weighting, we get an error because there are multiple matches
    PMap hints = new PMap();
    assertMultiMatchError(profileResolver, hints, "There are multiple CH profiles matching your request");
    assertMultiMatchError(profileResolver, hints.putObject(Parameters.CH.DISABLE, true), "There are multiple LM profiles matching your request");
    assertMultiMatchError(profileResolver, hints.putObject(Parameters.Landmark.DISABLE, true), "There are multiple profiles matching your request");
    // using the weighting is not enough, because its the same for both profiles
    hints = new PMap().putObject("weighting", "shortest");
    assertMultiMatchError(profileResolver, hints, "There are multiple CH profiles matching your request");
    assertMultiMatchError(profileResolver, hints.putObject(Parameters.CH.DISABLE, true), "There are multiple LM profiles matching your request");
    assertMultiMatchError(profileResolver, hints.putObject(Parameters.Landmark.DISABLE, true), "There are multiple profiles matching your request");
    // using the vehicle to select one of the profiles works
    hints = new PMap().putObject("vehicle", vehicle1);
    assertEquals(profile1, profileResolver.resolveProfile(hints).getName());
    assertEquals(profile1, profileResolver.resolveProfile(hints.putObject(Parameters.CH.DISABLE, true)).getName());
    assertEquals(profile1, profileResolver.resolveProfile(hints.putObject(Parameters.Landmark.DISABLE, true)).getName());
}
Also used : CHProfile(com.graphhopper.config.CHProfile) PMap(com.graphhopper.util.PMap) LMProfile(com.graphhopper.config.LMProfile) Profile(com.graphhopper.config.Profile) CHProfile(com.graphhopper.config.CHProfile) LMProfile(com.graphhopper.config.LMProfile) Test(org.junit.jupiter.api.Test) CHProfileSelectorTest(com.graphhopper.routing.ch.CHProfileSelectorTest) LMProfileSelectorTest(com.graphhopper.routing.lm.LMProfileSelectorTest)

Example 22 with Profile

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

the class ProfileResolverTest method edgeBasedAndTurnCosts.

@Test
public void edgeBasedAndTurnCosts() {
    ProfileResolver profileResolver = new ProfileResolver(EncodingManager.create("foot"), Collections.singletonList(new Profile("profile").setVehicle("foot").setWeighting("fastest")), Collections.emptyList(), Collections.emptyList());
    assertProfileNotFound(profileResolver, new PMap().putObject(Parameters.Routing.EDGE_BASED, true));
    assertEquals("profile", profileResolver.resolveProfile(new PMap()).getName());
    assertEquals("profile", profileResolver.resolveProfile(new PMap().putObject(Parameters.Routing.EDGE_BASED, false)).getName());
}
Also used : PMap(com.graphhopper.util.PMap) Profile(com.graphhopper.config.Profile) CHProfile(com.graphhopper.config.CHProfile) LMProfile(com.graphhopper.config.LMProfile) Test(org.junit.jupiter.api.Test) CHProfileSelectorTest(com.graphhopper.routing.ch.CHProfileSelectorTest) LMProfileSelectorTest(com.graphhopper.routing.lm.LMProfileSelectorTest)

Example 23 with Profile

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

the class RoutingAlgorithmWithOSMTest method testKremsMountainBikeRelation.

@Test
public void testKremsMountainBikeRelation() {
    List<Query> queries = new ArrayList<>();
    queries.add(new Query(48.409523, 15.602394, 48.375466, 15.72916, 12574, 169));
    queries.add(new Query(48.410061, 15.63951, 48.411386, 15.604899, 3101, 94));
    queries.add(new Query(48.412294, 15.62007, 48.398306, 15.609667, 3965, 95));
    GraphHopper hopper = createHopper(KREMS, new Profile("mtb").setVehicle("mtb").setWeighting("fastest"));
    hopper.importOrLoad();
    checkQueries(hopper, queries);
    Helper.removeDir(new File(GH_LOCATION));
    hopper = createHopper(KREMS, new Profile("mtb").setVehicle("mtb").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)

Example 24 with Profile

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

the class RoutingAlgorithmWithOSMTest method testMonacoFastest.

@Test
public void testMonacoFastest() {
    List<Query> queries = createMonacoCarQueries();
    queries.get(0).getPoints().get(1).expectedDistance = 2584;
    queries.get(0).getPoints().get(1).expectedPoints = 117;
    queries.get(3).getPoints().get(1).expectedDistance = 2279;
    queries.get(3).getPoints().get(1).expectedPoints = 141;
    queries.get(4).getPoints().get(1).expectedDistance = 2149;
    queries.get(4).getPoints().get(1).expectedPoints = 120;
    GraphHopper hopper = createHopper(MONACO, new Profile("car").setVehicle("car").setWeighting("fastest"));
    hopper.importOrLoad();
    checkQueries(hopper, queries);
}
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 25 with Profile

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

the class RoutingAlgorithmWithOSMTest method testSimpleTurnCosts.

@Test
public void testSimpleTurnCosts() {
    List<Query> list = new ArrayList<>();
    list.add(new Query(-0.49, 0.0, 0.0, -0.49, 298792.107, 6));
    GraphHopper hopper = createHopper(DIR + "/test_simple_turncosts.osm.xml", new Profile("car").setVehicle("car").setWeighting("fastest").setTurnCosts(true));
    hopper.importOrLoad();
    checkQueries(hopper, list);
}
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)

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