use of com.graphhopper.config.CHProfile in project graphhopper by graphhopper.
the class LMProfileSelectorTest method assertProfileFound.
private void assertProfileFound(Profile expectedProfile, List<Profile> profiles, List<LMProfile> lmProfiles, String vehicle, String weighting, Boolean edgeBased, Integer uTurnCosts) {
PMap hintsMap = createHintsMap(vehicle, weighting, edgeBased, uTurnCosts);
try {
Profile selectedProfile = new ProfileResolver(encodingManager, profiles, Collections.<CHProfile>emptyList(), lmProfiles).selectProfileLM(hintsMap);
assertEquals(expectedProfile, selectedProfile);
} catch (IllegalArgumentException e) {
fail("no profile found\nexpected: " + expectedProfile + "\nerror: " + e.getMessage());
}
}
use of com.graphhopper.config.CHProfile 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.CHProfile 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.CHProfile 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.CHProfile 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