Search in sources :

Example 26 with CHProfile

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

Example 27 with CHProfile

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);
}
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 28 with CHProfile

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);
}
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 29 with CHProfile

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);
}
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 30 with CHProfile

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

CHProfile (com.graphhopper.config.CHProfile)66 Profile (com.graphhopper.config.Profile)63 LMProfile (com.graphhopper.config.LMProfile)58 Test (org.junit.jupiter.api.Test)39 CustomProfile (com.graphhopper.routing.weighting.custom.CustomProfile)31 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)16 PMap (com.graphhopper.util.PMap)10 GHPoint (com.graphhopper.util.shapes.GHPoint)9 GraphHopperServerConfiguration (com.graphhopper.application.GraphHopperServerConfiguration)8 GraphHopperServerTestConfiguration (com.graphhopper.application.util.GraphHopperServerTestConfiguration)8 GraphHopper (com.graphhopper.GraphHopper)6 CHProfileSelectorTest (com.graphhopper.routing.ch.CHProfileSelectorTest)4 LMProfileSelectorTest (com.graphhopper.routing.lm.LMProfileSelectorTest)4 GraphHopperConfig (com.graphhopper.GraphHopperConfig)3 ProfileResolver (com.graphhopper.routing.ProfileResolver)3 CountryRuleFactory (com.graphhopper.routing.util.countryrules.CountryRuleFactory)2 LocationIndexTree (com.graphhopper.storage.index.LocationIndexTree)2 JtsModule (com.bedatadriven.jackson.datatype.jts.JtsModule)1 IntArrayList (com.carrotsearch.hppc.IntArrayList)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1