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