Search in sources :

Example 51 with CHProfile

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

the class CHProfileSelectorTest method missingVehicle_multiplePossibilities_throws.

@Test
public void missingVehicle_multiplePossibilities_throws() {
    List<Profile> profiles = Arrays.asList(fastBike, fastCar);
    List<CHProfile> chProfiles = Arrays.asList(new CHProfile("fast_bike"), new CHProfile("fast_car"));
    assertCHProfileSelectionError(MULTIPLE_MATCHES_ERROR, profiles, chProfiles, null, "fastest", 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 52 with CHProfile

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

the class RoutingAlgorithmWithOSMTest method createHopper.

/**
 * Creates a {@link GraphHopper} instance with some default settings for this test. The settings can
 * be adjusted before calling {@link GraphHopper#importOrLoad()}
 */
private GraphHopper createHopper(String osmFile, Profile... profiles) {
    GraphHopper hopper = new GraphHopper().setStoreOnFlush(true).setOSMFile(osmFile).setProfiles(profiles).setGraphHopperLocation(GH_LOCATION);
    hopper.getRouterConfig().setSimplifyResponse(false);
    hopper.setMinNetworkSize(0);
    hopper.getReaderConfig().setMaxWayPointDistance(0);
    hopper.getLMPreparationHandler().setLMProfiles(new LMProfile(profiles[0].getName()));
    hopper.getCHPreparationHandler().setCHProfiles(new CHProfile(profiles[0].getName()));
    return hopper;
}
Also used : CHProfile(com.graphhopper.config.CHProfile) LMProfile(com.graphhopper.config.LMProfile) GraphHopper(com.graphhopper.GraphHopper)

Example 53 with CHProfile

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

the class GraphHopperLandmarksTest method createConfig.

private static GraphHopperServerConfiguration createConfig() {
    GraphHopperServerConfiguration config = new GraphHopperServerTestConfiguration();
    config.getGraphHopperConfiguration().putObject("graph.flag_encoders", "car").putObject("datareader.file", "../core/files/belarus-east.osm.gz").putObject("prepare.min_network_size", 0).putObject("graph.location", DIR).putObject("prepare.lm.min_network_size", 2).setProfiles(Collections.singletonList(new Profile("car_profile").setVehicle("car").setWeighting("fastest"))).setCHProfiles(Collections.singletonList(new CHProfile("car_profile"))).setLMProfiles(Collections.singletonList(new LMProfile("car_profile")));
    return config;
}
Also used : CHProfile(com.graphhopper.config.CHProfile) GraphHopperServerTestConfiguration(com.graphhopper.application.util.GraphHopperServerTestConfiguration) LMProfile(com.graphhopper.config.LMProfile) CHProfile(com.graphhopper.config.CHProfile) Profile(com.graphhopper.config.Profile) LMProfile(com.graphhopper.config.LMProfile)

Example 54 with CHProfile

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

the class GraphHopperConfig method toString.

@Override
public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("profiles:\n");
    for (Profile profile : profiles) {
        sb.append(profile);
        sb.append("\n");
    }
    sb.append("profiles_ch:\n");
    for (CHProfile profile : chProfiles) {
        sb.append(profile);
        sb.append("\n");
    }
    sb.append("profiles_lm:\n");
    for (LMProfile profile : lmProfiles) {
        sb.append(profile);
        sb.append("\n");
    }
    sb.append("properties:\n");
    for (Map.Entry<String, Object> entry : map.toMap().entrySet()) {
        sb.append(entry.getKey()).append(": ").append(entry.getValue());
        sb.append("\n");
    }
    return sb.toString();
}
Also used : CHProfile(com.graphhopper.config.CHProfile) LMProfile(com.graphhopper.config.LMProfile) Map(java.util.Map) PMap(com.graphhopper.util.PMap) Profile(com.graphhopper.config.Profile) CHProfile(com.graphhopper.config.CHProfile) LMProfile(com.graphhopper.config.LMProfile)

Example 55 with CHProfile

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

the class GraphHopperTest method testRoundaboutInstructionsWithCH.

@Test
public void testRoundaboutInstructionsWithCH() {
    final String profile1 = "my_profile";
    final String profile2 = "your_profile";
    final String vehicle1 = "car";
    final String vehicle2 = "bike";
    final String weighting = "fastest";
    GraphHopper hopper = new GraphHopper().setGraphHopperLocation(GH_LOCATION).setOSMFile(MONACO).setProfiles(Arrays.asList(new Profile(profile1).setVehicle(vehicle1).setWeighting(weighting), new Profile(profile2).setVehicle(vehicle2).setWeighting(weighting))).setStoreOnFlush(true);
    hopper.getCHPreparationHandler().setCHProfiles(new CHProfile(profile1), new CHProfile(profile2));
    hopper.setMinNetworkSize(0);
    hopper.importOrLoad();
    assertEquals(2, hopper.getCHGraphs().size());
    GHResponse rsp = hopper.route(new GHRequest(43.745084, 7.430513, 43.745247, 7.430347).setProfile(profile1));
    ResponsePath res = rsp.getBest();
    assertEquals(2, ((RoundaboutInstruction) res.getInstructions().get(1)).getExitNumber());
    rsp = hopper.route(new GHRequest(43.745968, 7.42907, 43.745832, 7.428614).setProfile(profile1));
    res = rsp.getBest();
    assertEquals(2, ((RoundaboutInstruction) res.getInstructions().get(1)).getExitNumber());
    rsp = hopper.route(new GHRequest(43.745948, 7.42914, 43.746173, 7.428834).setProfile(profile1));
    res = rsp.getBest();
    assertEquals(1, ((RoundaboutInstruction) res.getInstructions().get(1)).getExitNumber());
    rsp = hopper.route(new GHRequest(43.735817, 7.417096, 43.735666, 7.416587).setProfile(profile1));
    res = rsp.getBest();
    assertEquals(2, ((RoundaboutInstruction) res.getInstructions().get(1)).getExitNumber());
}
Also used : CHProfile(com.graphhopper.config.CHProfile) CustomProfile(com.graphhopper.routing.weighting.custom.CustomProfile) Profile(com.graphhopper.config.Profile) CHProfile(com.graphhopper.config.CHProfile) LMProfile(com.graphhopper.config.LMProfile) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

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