Search in sources :

Example 16 with Profile

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

the class GraphHopperProfileTest method oneVehicleTwoProfilesWithAndWithoutTC2_noError.

@Test
public void oneVehicleTwoProfilesWithAndWithoutTC2_noError() {
    final GraphHopper hopper = createHopper();
    hopper.setProfiles(new Profile("profile2").setVehicle("car").setTurnCosts(true), new Profile("profile1").setVehicle("car").setTurnCosts(false));
    hopper.load();
}
Also used : Profile(com.graphhopper.config.Profile) CHProfile(com.graphhopper.config.CHProfile) LMProfile(com.graphhopper.config.LMProfile) Test(org.junit.jupiter.api.Test)

Example 17 with Profile

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

the class GraphHopperProfileTest method oneVehicleTwoProfilesWithAndWithoutTC_noError.

@Test
public void oneVehicleTwoProfilesWithAndWithoutTC_noError() {
    final GraphHopper hopper = createHopper();
    hopper.setProfiles(new Profile("profile1").setVehicle("car").setTurnCosts(false), new Profile("profile2").setVehicle("car").setTurnCosts(true));
    hopper.load();
}
Also used : Profile(com.graphhopper.config.Profile) CHProfile(com.graphhopper.config.CHProfile) LMProfile(com.graphhopper.config.LMProfile) Test(org.junit.jupiter.api.Test)

Example 18 with Profile

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

the class GraphHopperProfileTest method lmPreparationProfileChain_error.

@Test
public void lmPreparationProfileChain_error() {
    final GraphHopper hopper = createHopper();
    hopper.setProfiles(new Profile("profile1").setVehicle("car"), new Profile("profile2").setVehicle("bike"), new Profile("profile3").setVehicle("foot"));
    hopper.getLMPreparationHandler().setLMProfiles(new LMProfile("profile1"), new LMProfile("profile2").setPreparationProfile("profile1"), new LMProfile("profile3").setPreparationProfile("profile2"));
    assertIllegalArgument(hopper::load, "Cannot use 'profile2' as preparation_profile for LM profile 'profile3', because it uses another profile for preparation itself.");
}
Also used : 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)

Example 19 with Profile

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

the class ProfileResolverTest method defaultVehicle.

@Test
public void defaultVehicle() {
    ProfileResolver profileResolver = new ProfileResolver(EncodingManager.create("car,foot,bike"), Arrays.asList(new Profile("my_bike").setVehicle("bike"), new Profile("your_car").setVehicle("car")), Collections.<CHProfile>emptyList(), Collections.<LMProfile>emptyList());
    // without specifying the vehicle we get an error, because there are multiple matches
    assertMultiMatchError(profileResolver, new PMap(), "There are multiple profiles matching your request");
    // use vehicle to specify profile
    assertEquals("your_car", profileResolver.resolveProfile(new PMap().putObject("vehicle", "car")).getName());
    assertEquals("my_bike", profileResolver.resolveProfile(new PMap().putObject("vehicle", "bike")).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 20 with Profile

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

the class ProfileResolverTest method missingProfiles.

@Test
public void missingProfiles() {
    ProfileResolver profileResolver = new ProfileResolver(EncodingManager.create("car,bike"), Arrays.asList(new Profile("fast_bike").setVehicle("bike").setWeighting("fastest"), new Profile("short_bike").setVehicle("bike").setWeighting("shortest")), Collections.<CHProfile>emptyList(), Collections.<LMProfile>emptyList());
    // there is a car encoder but no associated profile
    assertProfileNotFound(profileResolver, new PMap().putObject("vehicle", "car"));
    // if we do not specify a vehicle or weighting we even have multiple matches
    assertMultiMatchError(profileResolver, new PMap(), "There are multiple profiles matching your request");
    // if we specify the weighting its clear which profile we want
    assertEquals("short_bike", profileResolver.resolveProfile(new PMap().putObject("weighting", "shortest")).getName());
    // setting the vehicle to bike is not enough
    assertMultiMatchError(profileResolver, new PMap().putObject("vehicle", "bike"), "There are multiple profiles matching your request");
    // if we set the weighting as well it works
    assertEquals("fast_bike", profileResolver.resolveProfile(new PMap().putObject("vehicle", "bike").putObject("weighting", "fastest")).getName());
    assertEquals("short_bike", profileResolver.resolveProfile(new PMap().putObject("vehicle", "bike").putObject("weighting", "shortest")).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)

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