use of com.graphhopper.config.Profile in project graphhopper by graphhopper.
the class CHProfileSelectorTest method edgeAndNodePresent.
@Test
public void edgeAndNodePresent() {
List<Profile> profiles = Arrays.asList(fastCar, fastCarEdge);
List<CHProfile> chProfiles = Arrays.asList(new CHProfile("fast_car"), new CHProfile("fast_car_edge"));
// in case edge-based is not specified we prefer the edge-based profile over the node-based one
assertProfileFound(profiles.get(1), profiles, chProfiles, null, null);
assertProfileFound(profiles.get(0), profiles, chProfiles, false, null);
assertProfileFound(profiles.get(1), profiles, chProfiles, true, null);
}
use of com.graphhopper.config.Profile in project graphhopper by graphhopper.
the class CHProfileSelectorTest method missingVehicleMultipleProfiles.
@Test
public void missingVehicleMultipleProfiles() {
List<Profile> profiles = Arrays.asList(fastBike, shortBike, fastBikeEdge40);
List<CHProfile> chProfiles = Arrays.asList(new CHProfile("fast_bike"), new CHProfile("short_bike"), new CHProfile("fast_bike_edge40"));
// the vehicle is not given but only bike is used so its fine. note that we prefer edge-based because no edge_based parameter is specified
assertProfileFound(profiles.get(2), profiles, chProfiles, null, "fastest", null, null);
// if we do not specify the weighting its not clear what to return -> there is an error
assertCHProfileSelectionError(MULTIPLE_MATCHES_ERROR, profiles, chProfiles, null, null, null, null);
// if we do not specify the weighting but edge_based=true its clear what to return because for edge-based there is only one weighting
assertProfileFound(profiles.get(2), profiles, chProfiles, null, null, true, null);
// ... for edge_based=false this is an error because there are two node-based profiles
assertCHProfileSelectionError(MULTIPLE_MATCHES_ERROR, profiles, chProfiles, null, null, false, null);
}
use of com.graphhopper.config.Profile in project graphhopper by graphhopper.
the class CHProfileSelectorTest method missingVehicleOrWeighting.
@Test
public void missingVehicleOrWeighting() {
// when we do not set the weighting and/or the car but it can be derived from the profile the profile is returned
List<Profile> profiles = Collections.singletonList(fastCar);
List<CHProfile> chProfiles = Collections.singletonList(new CHProfile("fast_car"));
assertProfileFound(profiles.get(0), profiles, chProfiles, "car", "fastest", null, null);
assertProfileFound(profiles.get(0), profiles, chProfiles, "car", null, null, null);
assertProfileFound(profiles.get(0), profiles, chProfiles, null, "fastest", null, null);
assertProfileFound(profiles.get(0), profiles, chProfiles, null, null, null, null);
}
use of com.graphhopper.config.Profile in project graphhopper by graphhopper.
the class CHProfileSelectorTest method setup.
@BeforeEach
public void setup() {
FlagEncoder carEncoder = new CarFlagEncoder();
FlagEncoder bikeEncoder = new BikeFlagEncoder();
encodingManager = EncodingManager.create(carEncoder, bikeEncoder);
fastCar = new Profile("fast_car").setWeighting("fastest").setVehicle("car").setTurnCosts(false);
fastCarEdge = new Profile("fast_car_edge").setWeighting("fastest").setVehicle("car").setTurnCosts(true);
fastCarEdge10 = new Profile("fast_car_edge10").setWeighting("fastest").setVehicle("car").setTurnCosts(true).putHint(Parameters.Routing.U_TURN_COSTS, 10);
fastCarEdge30 = new Profile("fast_car_edge30").setWeighting("fastest").setVehicle("car").setTurnCosts(true).putHint(Parameters.Routing.U_TURN_COSTS, 30);
fastCarEdge50 = new Profile("fast_car_edge50").setWeighting("fastest").setVehicle("car").setTurnCosts(true).putHint(Parameters.Routing.U_TURN_COSTS, 50);
fastBike = new Profile("fast_bike").setWeighting("fastest").setVehicle("bike").setTurnCosts(false);
fastBikeEdge40 = new Profile("fast_bike_edge40").setWeighting("fastest").setVehicle("bike").setTurnCosts(true).putHint(Parameters.Routing.U_TURN_COSTS, 40);
shortCar = new Profile("short_car").setWeighting("shortest").setVehicle("car").setTurnCosts(false);
shortBike = new Profile("short_bike").setWeighting("shortest").setVehicle("bike").setTurnCosts(false);
}
use of com.graphhopper.config.Profile in project graphhopper by graphhopper.
the class CHProfileSelectorTest method assertProfileFound.
private void assertProfileFound(Profile expectedProfile, List<Profile> profiles, List<CHProfile> chProfiles, String vehicle, String weighting, Boolean edgeBased, Integer uTurnCosts) {
PMap hintsMap = createHintsMap(vehicle, weighting, edgeBased, uTurnCosts);
try {
Profile selectedProfile = new ProfileResolver(encodingManager, profiles, chProfiles, Collections.<LMProfile>emptyList()).selectProfileCH(hintsMap);
assertEquals(expectedProfile, selectedProfile);
} catch (IllegalArgumentException e) {
fail("no profile found\nexpected: " + expectedProfile + "\nerror: " + e.getMessage());
}
}
Aggregations