Search in sources :

Example 46 with LMProfile

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'");
}
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 47 with LMProfile

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'");
}
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 48 with LMProfile

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);
}
Also used : CHProfile(com.graphhopper.config.CHProfile) LMProfile(com.graphhopper.config.LMProfile) CustomProfile(com.graphhopper.routing.weighting.custom.CustomProfile) Profile(com.graphhopper.config.Profile) CHProfile(com.graphhopper.config.CHProfile) LMProfile(com.graphhopper.config.LMProfile) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

LMProfile (com.graphhopper.config.LMProfile)48 Profile (com.graphhopper.config.Profile)41 CHProfile (com.graphhopper.config.CHProfile)33 Test (org.junit.jupiter.api.Test)24 CustomProfile (com.graphhopper.routing.weighting.custom.CustomProfile)15 PMap (com.graphhopper.util.PMap)12 GraphHopper (com.graphhopper.GraphHopper)10 GraphHopperServerConfiguration (com.graphhopper.application.GraphHopperServerConfiguration)6 GraphHopperServerTestConfiguration (com.graphhopper.application.util.GraphHopperServerTestConfiguration)6 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)5 CHProfileSelectorTest (com.graphhopper.routing.ch.CHProfileSelectorTest)4 LMProfileSelectorTest (com.graphhopper.routing.lm.LMProfileSelectorTest)4 File (java.io.File)4 GraphHopperConfig (com.graphhopper.GraphHopperConfig)3 Gpx (com.graphhopper.jackson.Gpx)3 EdgeMatch (com.graphhopper.matching.EdgeMatch)3 MapMatching (com.graphhopper.matching.MapMatching)3 MatchResult (com.graphhopper.matching.MatchResult)3 ProfileResolver (com.graphhopper.routing.ProfileResolver)3 GHPoint (com.graphhopper.util.shapes.GHPoint)3