Search in sources :

Example 71 with GraphHopper

use of com.graphhopper.GraphHopper in project graphhopper by graphhopper.

the class RoutingAlgorithmWithOSMTest method testHarsdorf.

@Test
public void testHarsdorf() {
    List<Query> queries = new ArrayList<>();
    // TODO somehow the bigger road is take even if we make it less preferred (e.g. introduce AVOID AT ALL costs for lanes=2&&maxspeed>50)
    queries.add(new Query(50.004333, 11.600254, 50.044449, 11.543434, 6952, 190));
    // choose Unterloher Weg and the following residential + cycleway
    // list.add(new OneRun(50.004333, 11.600254, 50.044449, 11.543434, 6931, 184));
    GraphHopper hopper = createHopper(BAYREUTH, new Profile("bike").setVehicle("bike").setWeighting("fastest"));
    hopper.importOrLoad();
    checkQueries(hopper, queries);
}
Also used : ArrayList(java.util.ArrayList) GraphHopper(com.graphhopper.GraphHopper) Profile(com.graphhopper.config.Profile) CHProfile(com.graphhopper.config.CHProfile) LMProfile(com.graphhopper.config.LMProfile) Test(org.junit.jupiter.api.Test)

Example 72 with GraphHopper

use of com.graphhopper.GraphHopper in project graphhopper by graphhopper.

the class RoutingAlgorithmWithOSMTest method testNeudrossenfeld.

@Test
public void testNeudrossenfeld() {
    List<Query> list = new ArrayList<>();
    // choose cycleway (Dreschenauer Straße)
    list.add(new Query(49.987132, 11.510496, 50.018839, 11.505024, 3985, 106));
    GraphHopper hopper = createHopper(BAYREUTH, new Profile("bike").setVehicle("bike").setWeighting("fastest"));
    hopper.setElevationProvider(new SRTMProvider(DIR));
    hopper.importOrLoad();
    checkQueries(hopper, list);
    Helper.removeDir(new File(GH_LOCATION));
    hopper = createHopper(BAYREUTH, new Profile("bike2").setVehicle("bike2").setWeighting("fastest"));
    hopper.setElevationProvider(new SRTMProvider(DIR));
    hopper.importOrLoad();
    checkQueries(hopper, list);
}
Also used : ArrayList(java.util.ArrayList) GraphHopper(com.graphhopper.GraphHopper) File(java.io.File) Profile(com.graphhopper.config.Profile) CHProfile(com.graphhopper.config.CHProfile) LMProfile(com.graphhopper.config.LMProfile) SRTMProvider(com.graphhopper.reader.dem.SRTMProvider) Test(org.junit.jupiter.api.Test)

Example 73 with GraphHopper

use of com.graphhopper.GraphHopper in project graphhopper by graphhopper.

the class RoutingAlgorithmWithOSMTest method testCampoGrande.

@Test
public void testCampoGrande() {
    // test not only NE quadrant of earth!
    // bzcat campo-grande.osm.bz2
    // | ./bin/osmosis --read-xml enableDateParsing=no file=- --bounding-box top=-20.4 left=-54.6 bottom=-20.6 right=-54.5 --write-xml file=-
    // | bzip2 > campo-grande.extracted.osm.bz2
    List<Query> queries = new ArrayList<>();
    queries.add(new Query(-20.4001, -54.5999, -20.598, -54.54, 25323, 271));
    queries.add(new Query(-20.43, -54.54, -20.537, -54.5999, 16231, 223));
    GraphHopper hopper = createHopper(DIR + "/campo-grande.osm.gz", new Profile("car").setVehicle("car").setWeighting("shortest"));
    hopper.importOrLoad();
    checkQueries(hopper, queries);
}
Also used : ArrayList(java.util.ArrayList) GraphHopper(com.graphhopper.GraphHopper) Profile(com.graphhopper.config.Profile) CHProfile(com.graphhopper.config.CHProfile) LMProfile(com.graphhopper.config.LMProfile) Test(org.junit.jupiter.api.Test)

Example 74 with GraphHopper

use of com.graphhopper.GraphHopper in project graphhopper by graphhopper.

the class RoutingAlgorithmWithOSMTest method testSidewalkNo.

@Test
public void testSidewalkNo() {
    List<Query> queries = new ArrayList<>();
    // roundabout contains sidewalk=no which should be avoided
    queries.add(new Query(57.154888, -2.101822, 57.153445, -2.099869, 329, 31));
    // longer path should go through tertiary, see discussion in #476
    queries.add(new Query(57.154888, -2.101822, 57.147299, -2.096286, 1118, 68));
    Profile profile = new Profile("hike").setVehicle("hike").setWeighting("fastest");
    GraphHopper hopper = createHopper(DIR + "/map-sidewalk-no.osm.gz", profile);
    hopper.importOrLoad();
    checkQueries(hopper, queries);
}
Also used : ArrayList(java.util.ArrayList) GraphHopper(com.graphhopper.GraphHopper) Profile(com.graphhopper.config.Profile) CHProfile(com.graphhopper.config.CHProfile) LMProfile(com.graphhopper.config.LMProfile) Test(org.junit.jupiter.api.Test)

Example 75 with GraphHopper

use of com.graphhopper.GraphHopper in project graphhopper by graphhopper.

the class RoutingAlgorithmWithOSMTest method testDisconnectedAreaAndMultiplePoints.

@Test
public void testDisconnectedAreaAndMultiplePoints() {
    Query query = new Query();
    query.add(53.753177, 9.435968, 10, 10);
    query.add(53.751299, 9.386959, 10, 10);
    query.add(53.751299, 9.3869, 10, 10);
    GraphHopper hopper = createHopper(DIR + "/krautsand.osm.gz", new Profile("car").setVehicle("car").setWeighting("fastest"));
    hopper.setElevationProvider(new SRTMProvider(DIR));
    hopper.importOrLoad();
    for (Function<Query, GHRequest> requestFactory : createRequestFactories()) {
        GHRequest request = requestFactory.apply(query);
        request.setProfile(hopper.getProfiles().get(0).getName());
        GHResponse res = hopper.route(request);
        assertTrue(res.hasErrors());
        assertTrue(res.getErrors().toString().contains("ConnectionNotFound"), res.getErrors().toString());
    }
}
Also used : GHRequest(com.graphhopper.GHRequest) GraphHopper(com.graphhopper.GraphHopper) GHResponse(com.graphhopper.GHResponse) Profile(com.graphhopper.config.Profile) CHProfile(com.graphhopper.config.CHProfile) LMProfile(com.graphhopper.config.LMProfile) SRTMProvider(com.graphhopper.reader.dem.SRTMProvider) Test(org.junit.jupiter.api.Test)

Aggregations

GraphHopper (com.graphhopper.GraphHopper)101 Test (org.junit.jupiter.api.Test)62 Profile (com.graphhopper.config.Profile)52 LMProfile (com.graphhopper.config.LMProfile)44 CHProfile (com.graphhopper.config.CHProfile)39 GraphHopperTest (com.graphhopper.GraphHopperTest)25 ArrayList (java.util.ArrayList)24 File (java.io.File)16 Test (org.junit.Test)11 SRTMProvider (com.graphhopper.reader.dem.SRTMProvider)10 GHRequest (com.graphhopper.GHRequest)7 GHResponse (com.graphhopper.GHResponse)7 GraphHopperConfig (com.graphhopper.GraphHopperConfig)6 GraphHopperOSM (com.graphhopper.reader.osm.GraphHopperOSM)6 EncodingManager (com.graphhopper.routing.util.EncodingManager)6 PMap (com.graphhopper.util.PMap)6 GHPoint (com.graphhopper.util.shapes.GHPoint)5 IOException (java.io.IOException)5 Gpx (com.graphhopper.jackson.Gpx)4 MapMatching (com.graphhopper.matching.MapMatching)4