use of com.graphhopper.reader.osm.GraphHopperOSM in project graphhopper by graphhopper.
the class GraphHopperIT method testAlternativeRoutesBikeAndCar.
@Test
public void testAlternativeRoutesBikeAndCar() {
GraphHopper tmpHopper = new GraphHopperOSM().setOSMFile(DIR + "/north-bayreuth.osm.gz").setCHEnabled(false).setGraphHopperLocation(tmpGraphFile).setEncodingManager(new EncodingManager("bike, car"));
tmpHopper.importOrLoad();
GHRequest req = new GHRequest(50.028917, 11.496506, 49.985228, 11.600876).setAlgorithm(ALT_ROUTE).setVehicle("bike").setWeighting("fastest");
req.getHints().put("alternative_route.max_paths", "3");
GHResponse rsp = tmpHopper.route(req);
assertFalse(rsp.getErrors().toString(), rsp.hasErrors());
assertEquals(3, rsp.getAll().size());
// via ramsenthal
assertEquals(2864, rsp.getAll().get(0).getTime() / 1000);
// via unterwaiz
assertEquals(3318, rsp.getAll().get(1).getTime() / 1000);
// via eselslohe -> theta; BTW: here smaller time as 2nd alternative due to priority influences time order
assertEquals(3094, rsp.getAll().get(2).getTime() / 1000);
req = new GHRequest(50.023513, 11.548862, 49.969441, 11.537876).setAlgorithm(ALT_ROUTE).setVehicle("car").setWeighting("fastest");
req.getHints().put("alternative_route.max_paths", "3");
rsp = tmpHopper.route(req);
assertFalse(rsp.getErrors().toString(), rsp.hasErrors());
assertEquals(3, rsp.getAll().size());
// directly via obergräfenthal
assertEquals(870, rsp.getAll().get(0).getTime() / 1000);
// via ramsenthal -> lerchenhof
assertEquals(913, rsp.getAll().get(1).getTime() / 1000);
// via neudrossenfeld
assertEquals(958, rsp.getAll().get(2).getTime() / 1000);
}
Aggregations