use of com.graphhopper.config.LMProfile in project graphhopper by graphhopper.
the class GraphHopperProfileTest method lmProfileDoesNotExist_error.
@Test
public void lmProfileDoesNotExist_error() {
final GraphHopper hopper = createHopper();
hopper.setProfiles(new Profile("profile1").setVehicle("car"));
hopper.getLMPreparationHandler().setLMProfiles(new LMProfile("other_profile"));
assertIllegalArgument(hopper::load, "LM profile references unknown profile 'other_profile'");
}
use of com.graphhopper.config.LMProfile in project graphhopper by graphhopper.
the class GraphHopperProfileTest method duplicateLMProfile_error.
@Test
public void duplicateLMProfile_error() {
final GraphHopper hopper = createHopper();
hopper.setProfiles(new Profile("profile").setVehicle("car"));
hopper.getLMPreparationHandler().setLMProfiles(new LMProfile("profile"), new LMProfile("profile"));
assertIllegalArgument(hopper::load, "Multiple LM profiles are using the same profile 'profile'");
}
use of com.graphhopper.config.LMProfile in project graphhopper by graphhopper.
the class GraphHopperTest method testPreparedProfileNotAvailable.
@Test
public void testPreparedProfileNotAvailable() {
final String profile1 = "fast_profile";
final String profile2 = "short_fast_profile";
final String vehicle = "car";
final String weighting1 = "fastest";
final String weighting2 = "short_fastest";
GraphHopper hopper = new GraphHopper().setGraphHopperLocation(GH_LOCATION).setOSMFile(MONACO).setProfiles(new Profile(profile1).setVehicle(vehicle).setWeighting(weighting1), new Profile(profile2).setVehicle(vehicle).setWeighting(weighting2)).setStoreOnFlush(true);
hopper.getCHPreparationHandler().setCHProfiles(new CHProfile(profile1));
hopper.getLMPreparationHandler().setLMProfiles(new LMProfile(profile1).setMaximumLMWeight(2000));
hopper.importOrLoad();
// request a profile that was not prepared
GHRequest req = new GHRequest(43.727687, 7.418737, 43.74958, 7.436566).setProfile(profile2);
// try with CH
req.putHint(CH.DISABLE, false);
req.putHint(Landmark.DISABLE, false);
GHResponse res = hopper.route(req);
assertTrue(res.hasErrors(), res.getErrors().toString());
assertTrue(res.getErrors().get(0).getMessage().contains("Cannot find CH preparation for the requested profile: 'short_fast_profile'"), res.getErrors().toString());
// try with LM
req.putHint(CH.DISABLE, true);
req.putHint(Landmark.DISABLE, false);
res = hopper.route(req);
assertTrue(res.hasErrors(), res.getErrors().toString());
assertTrue(res.getErrors().get(0).getMessage().contains("Cannot find LM preparation for the requested profile: 'short_fast_profile'"), res.getErrors().toString());
// falling back to non-prepared algo works
req.putHint(CH.DISABLE, true);
req.putHint(Landmark.DISABLE, true);
res = hopper.route(req);
assertFalse(res.hasErrors(), res.getErrors().toString());
assertEquals(3587, res.getBest().getDistance(), 1);
}
Aggregations