Search in sources :

Example 46 with CHProfile

use of com.graphhopper.config.CHProfile in project graphhopper by graphhopper.

the class CHProfileSelectorTest method missingWeighting_multiplePossibilities_throws.

@Test
public void missingWeighting_multiplePossibilities_throws() {
    List<Profile> profiles = Arrays.asList(fastBike, shortBike);
    List<CHProfile> chProfiles = Arrays.asList(new CHProfile("fast_bike"), new CHProfile("short_bike"));
    assertCHProfileSelectionError(MULTIPLE_MATCHES_ERROR, profiles, chProfiles, "bike", 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 47 with CHProfile

use of com.graphhopper.config.CHProfile in project graphhopper by graphhopper.

the class CHProfileSelectorTest method onlyNodeBasedPresent.

@Test
public void onlyNodeBasedPresent() {
    List<Profile> profiles = Collections.singletonList(fastCar);
    List<CHProfile> chProfiles = Collections.singletonList(new CHProfile("fast_car"));
    assertCHProfileSelectionError(NO_MATCH_ERROR, profiles, chProfiles, true, null);
    assertCHProfileSelectionError(NO_MATCH_ERROR, profiles, chProfiles, true, 20);
    assertProfileFound(profiles.get(0), profiles, chProfiles, false, null);
    assertCHProfileSelectionError(NO_MATCH_ERROR, profiles, chProfiles, false, 20);
    assertProfileFound(profiles.get(0), profiles, chProfiles, null, null);
    assertCHProfileSelectionError(NO_MATCH_ERROR, profiles, chProfiles, null, 30);
    String error = assertCHProfileSelectionError(NO_MATCH_ERROR, profiles, chProfiles, "foot", "fastest", false, null);
    assertTrue(error.contains("requested:  fastest|foot|turn_costs=false|u_turn_costs=*"), error);
    assertTrue(error.contains("available: [fastest|car|turn_costs=false]"), error);
}
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 48 with CHProfile

use of com.graphhopper.config.CHProfile in project graphhopper by graphhopper.

the class CHProfileSelectorTest method missingWeightingMultipleProfiles.

@Test
public void missingWeightingMultipleProfiles() {
    List<Profile> profiles = Arrays.asList(fastBike, fastCarEdge10, fastBikeEdge40);
    List<CHProfile> chProfiles = Arrays.asList(new CHProfile("fast_bike"), new CHProfile("fast_car_edge10"), new CHProfile("fast_bike_edge40"));
    // the weighting is not given but only fastest is used so its fine. note that we prefer edge-based because no edge_based parameter is specified
    assertProfileFound(profiles.get(2), profiles, chProfiles, "bike", null, null, null);
    // if we do not specify the vehicle 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 vehicle but edge_based=false its clear what to return because for node-based there is only one weighting
    assertProfileFound(profiles.get(0), profiles, chProfiles, null, null, false, null);
    // ... for edge_based=true this is an error, because there are two edge_based profiles
    assertCHProfileSelectionError(MULTIPLE_MATCHES_ERROR, profiles, chProfiles, null, null, true, null);
    // ... we can however get a clear match if we specify the u-turn costs
    assertProfileFound(profiles.get(1), profiles, chProfiles, null, null, true, 10);
}
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 49 with CHProfile

use of com.graphhopper.config.CHProfile in project graphhopper by graphhopper.

the class CHProfileSelectorTest method multipleEdgeBased.

@Test
public void multipleEdgeBased() {
    List<Profile> profiles = Arrays.asList(fastCar, fastCarEdge30, fastCarEdge50);
    List<CHProfile> chProfiles = Arrays.asList(new CHProfile("fast_car"), new CHProfile("fast_car_edge30"), new CHProfile("fast_car_edge50"));
    // when no u-turns are specified we throw
    assertCHProfileSelectionError(MULTIPLE_MATCHES_ERROR, profiles, chProfiles, true, null);
    // when we request one that does not exist we throw
    assertCHProfileSelectionError(NO_MATCH_ERROR, profiles, chProfiles, true, 40);
    // when we request one that exists it works
    assertProfileFound(profiles.get(1), profiles, chProfiles, true, 30);
    // without specifying edge-based we also get an error
    assertProfileFound(profiles.get(1), profiles, chProfiles, null, 30);
    assertCHProfileSelectionError(NO_MATCH_ERROR, profiles, chProfiles, null, 40);
    String error = assertCHProfileSelectionError(MULTIPLE_MATCHES_ERROR, profiles, chProfiles, null, null);
    assertTrue(error.contains("requested:  fastest|car|turn_costs=*|u_turn_costs=*"), error);
    assertTrue(error.contains("matched:   [fastest|car|turn_costs=false, fastest|car|turn_costs=true|u_turn_costs=30, fastest|car|turn_costs=true|u_turn_costs=50]"), error);
    assertTrue(error.contains("available: [fastest|car|turn_costs=false, fastest|car|turn_costs=true|u_turn_costs=30, fastest|car|turn_costs=true|u_turn_costs=50]"), error);
}
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 50 with CHProfile

use of com.graphhopper.config.CHProfile in project graphhopper by graphhopper.

the class CHProfileSelectorTest method missingVehicleOrWeighting_otherVehicleAndCar.

@Test
public void missingVehicleOrWeighting_otherVehicleAndCar() {
    List<Profile> profiles = Collections.singletonList(shortBike);
    List<CHProfile> chProfiles = Collections.singletonList(new CHProfile("short_bike"));
    assertProfileFound(profiles.get(0), profiles, chProfiles, "bike", "shortest", null, null);
    assertProfileFound(profiles.get(0), profiles, chProfiles, "bike", null, null, null);
    assertProfileFound(profiles.get(0), profiles, chProfiles, null, "shortest", 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)

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