use of com.graphhopper.reader.osm.GraphHopperOSM in project graphhopper by graphhopper.
the class GraphHopperIT method testRoundaboutInstructionsWithCH.
@Test
public void testRoundaboutInstructionsWithCH() {
String tmpOsmFile = DIR + "/monaco.osm.gz";
String tmpVehicle = "car";
String tmpImportVehicles = "car,bike";
String tmpWeightCalcStr = "fastest";
GraphHopper tmpHopper = new GraphHopperOSM().setOSMFile(tmpOsmFile).setStoreOnFlush(true).setGraphHopperLocation(tmpGraphFile).setEncodingManager(new EncodingManager(tmpImportVehicles)).importOrLoad();
assertEquals(tmpVehicle, tmpHopper.getDefaultVehicle().toString());
assertEquals(2, tmpHopper.getCHFactoryDecorator().getPreparations().size());
GHResponse rsp = tmpHopper.route(new GHRequest(43.745084, 7.430513, 43.745247, 7.430347).setVehicle(tmpVehicle).setWeighting(tmpWeightCalcStr));
PathWrapper arsp = rsp.getBest();
assertEquals(2, ((RoundaboutInstruction) arsp.getInstructions().get(1)).getExitNumber());
rsp = tmpHopper.route(new GHRequest(43.745968, 7.42907, 43.745832, 7.428614).setVehicle(tmpVehicle).setWeighting(tmpWeightCalcStr));
arsp = rsp.getBest();
assertEquals(2, ((RoundaboutInstruction) arsp.getInstructions().get(1)).getExitNumber());
rsp = tmpHopper.route(new GHRequest(43.745948, 7.42914, 43.746173, 7.428834).setVehicle(tmpVehicle).setWeighting(tmpWeightCalcStr));
arsp = rsp.getBest();
assertEquals(1, ((RoundaboutInstruction) arsp.getInstructions().get(1)).getExitNumber());
rsp = tmpHopper.route(new GHRequest(43.735817, 7.417096, 43.735666, 7.416587).setVehicle(tmpVehicle).setWeighting(tmpWeightCalcStr));
arsp = rsp.getBest();
assertEquals(2, ((RoundaboutInstruction) arsp.getInstructions().get(1)).getExitNumber());
}
use of com.graphhopper.reader.osm.GraphHopperOSM in project graphhopper by graphhopper.
the class GraphHopperIT method testPointHint.
@Test
public void testPointHint() {
GraphHopper tmpHopper = new GraphHopperOSM().setOSMFile(DIR + "/Laufamholzstrasse.osm.xml").setCHEnabled(false).setGraphHopperLocation(tmpGraphFile).setEncodingManager(new EncodingManager("car"));
tmpHopper.importOrLoad();
GHRequest req = new GHRequest(49.46553, 11.154669, 49.465244, 11.152577).setVehicle("car").setWeighting("fastest");
req.setPointHints(new ArrayList<>(Arrays.asList("Laufamholzstraße, 90482, Nürnberg, Deutschland", "")));
GHResponse rsp = tmpHopper.route(req);
assertFalse(rsp.getErrors().toString(), rsp.hasErrors());
GHPoint snappedPoint = rsp.getBest().getWaypoints().toGHPoint(0);
assertEquals(49.465686, snappedPoint.getLat(), .000001);
assertEquals(11.154605, snappedPoint.getLon(), .000001);
req.setPointHints(new ArrayList<>(Arrays.asList("", "")));
rsp = tmpHopper.route(req);
assertFalse(rsp.getErrors().toString(), rsp.hasErrors());
snappedPoint = rsp.getBest().getWaypoints().toGHPoint(0);
assertEquals(49.465502, snappedPoint.getLat(), .000001);
assertEquals(11.154498, snappedPoint.getLon(), .000001);
// Match to closest edge, since hint was not found
req.setPointHints(new ArrayList<>(Arrays.asList("xy", "")));
rsp = tmpHopper.route(req);
assertFalse(rsp.getErrors().toString(), rsp.hasErrors());
snappedPoint = rsp.getBest().getWaypoints().toGHPoint(0);
assertEquals(49.465502, snappedPoint.getLat(), .000001);
assertEquals(11.154498, snappedPoint.getLon(), .000001);
}
use of com.graphhopper.reader.osm.GraphHopperOSM in project graphhopper by graphhopper.
the class GraphHopperIT method testNorthBayreuthDestination.
@Test
public void testNorthBayreuthDestination() {
GraphHopper tmpHopper = new GraphHopperOSM().setOSMFile(DIR + "/north-bayreuth.osm.gz").setCHEnabled(false).setGraphHopperLocation(tmpGraphFile).setEncodingManager(new EncodingManager("car,generic", 8));
tmpHopper.importOrLoad();
GHRequest req = new GHRequest(49.985307, 11.50628, 49.985731, 11.507465).setVehicle("car").setWeighting("fastest");
GHResponse rsp = tmpHopper.route(req);
assertFalse(rsp.getErrors().toString(), rsp.hasErrors());
assertEquals(550, rsp.getBest().getDistance(), 1);
req = new GHRequest(49.985307, 11.50628, 49.985731, 11.507465).setVehicle("generic").setWeighting("generic");
rsp = tmpHopper.route(req);
assertFalse(rsp.getErrors().toString(), rsp.hasErrors());
assertEquals(550, rsp.getBest().getDistance(), 1);
}
use of com.graphhopper.reader.osm.GraphHopperOSM in project graphhopper by graphhopper.
the class GraphHopperIT method testTurnCostsOnOff.
@Test
public void testTurnCostsOnOff() {
GraphHopper tmpHopper = new GraphHopperOSM().setOSMFile(DIR + "/moscow.osm.gz").setStoreOnFlush(true).setCHEnabled(false).setGraphHopperLocation(tmpGraphFile).setEncodingManager(new EncodingManager("car|turn_costs=true"));
tmpHopper.importOrLoad();
// with turn costs (default if none-CH and turn cost enabled)
GHRequest req = new GHRequest(55.813357, 37.5958585, 55.811042, 37.594689);
GHResponse rsp = tmpHopper.route(req);
assertEquals(1044, rsp.getBest().getDistance(), 1);
// without turn costs
req.getHints().put(Routing.EDGE_BASED, "false");
rsp = tmpHopper.route(req);
assertEquals(400, rsp.getBest().getDistance(), 1);
// with turn costs
req.getHints().put(Routing.EDGE_BASED, "true");
rsp = tmpHopper.route(req);
assertEquals(1044, rsp.getBest().getDistance(), 1);
}
use of com.graphhopper.reader.osm.GraphHopperOSM in project graphhopper by graphhopper.
the class GraphHopperIT method testSRTMWithTunnelInterpolation.
@Test
public void testSRTMWithTunnelInterpolation() throws Exception {
GraphHopper tmpHopper = new GraphHopperOSM().setOSMFile(osmFile).setStoreOnFlush(true).setCHEnabled(false).setGraphHopperLocation(tmpGraphFile).setEncodingManager(new EncodingManager(genericImportVehicles, 8));
tmpHopper.setElevationProvider(new SRTMProvider(DIR));
tmpHopper.importOrLoad();
GHResponse rsp = tmpHopper.route(new GHRequest(43.74056471749763, 7.4299266210693755, 43.73790260334179, 7.427984089259056).setAlgorithm(ASTAR).setVehicle(vehicle).setWeighting(weightCalcStr));
PathWrapper arsp = rsp.getBest();
// Without interpolation: 356.5
assertEquals(351.4, arsp.getDistance(), .1);
PointList pointList = arsp.getPoints();
assertEquals(6, pointList.getSize());
assertTrue(pointList.is3D());
assertEquals(17, pointList.getEle(0), .1);
assertEquals(19.04, pointList.getEle(1), .1);
assertEquals(21.67, pointList.getEle(2), .1);
assertEquals(25.03, pointList.getEle(3), .1);
assertEquals(28.65, pointList.getEle(4), .1);
assertEquals(31.32, pointList.getEle(5), .1);
}
Aggregations