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();
}
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();
}
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.");
}
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());
}
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());
}
Aggregations