Search in sources :

Example 91 with Profile

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

Example 92 with Profile

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

Example 93 with Profile

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

Example 94 with Profile

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);
}
Also used : CarFlagEncoder(com.graphhopper.routing.util.CarFlagEncoder) BikeFlagEncoder(com.graphhopper.routing.util.BikeFlagEncoder) FlagEncoder(com.graphhopper.routing.util.FlagEncoder) BikeFlagEncoder(com.graphhopper.routing.util.BikeFlagEncoder) CarFlagEncoder(com.graphhopper.routing.util.CarFlagEncoder) CHProfile(com.graphhopper.config.CHProfile) Profile(com.graphhopper.config.Profile) LMProfile(com.graphhopper.config.LMProfile) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 95 with Profile

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());
    }
}
Also used : ProfileResolver(com.graphhopper.routing.ProfileResolver) PMap(com.graphhopper.util.PMap) LMProfile(com.graphhopper.config.LMProfile) CHProfile(com.graphhopper.config.CHProfile) Profile(com.graphhopper.config.Profile) LMProfile(com.graphhopper.config.LMProfile)

Aggregations

Profile (com.graphhopper.config.Profile)203 LMProfile (com.graphhopper.config.LMProfile)167 CHProfile (com.graphhopper.config.CHProfile)164 Test (org.junit.jupiter.api.Test)138 CustomProfile (com.graphhopper.routing.weighting.custom.CustomProfile)84 GraphHopper (com.graphhopper.GraphHopper)54 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)54 GHPoint (com.graphhopper.util.shapes.GHPoint)35 ArrayList (java.util.ArrayList)29 File (java.io.File)25 GraphHopperServerConfiguration (com.graphhopper.application.GraphHopperServerConfiguration)19 GraphHopperServerTestConfiguration (com.graphhopper.application.util.GraphHopperServerTestConfiguration)19 PMap (com.graphhopper.util.PMap)14 SRTMProvider (com.graphhopper.reader.dem.SRTMProvider)11 BeforeAll (org.junit.jupiter.api.BeforeAll)10 Weighting (com.graphhopper.routing.weighting.Weighting)9 LocationIndexTree (com.graphhopper.storage.index.LocationIndexTree)8 TranslationMap (com.graphhopper.util.TranslationMap)7 Snap (com.graphhopper.storage.index.Snap)6 GHRequest (com.graphhopper.GHRequest)5