use of com.graphhopper.api.GraphHopperWeb in project graphhopper by graphhopper.
the class RouteResourceTest method testInitInstructionsWithTurnDescription.
@Test
public void testInitInstructionsWithTurnDescription() {
GraphHopperWeb hopper = new GraphHopperWeb(clientUrl(app, "/route"));
GHRequest request = new GHRequest(42.554851, 1.536198, 42.510071, 1.548128);
request.setProfile("my_car");
GHResponse rsp = hopper.route(request);
assertFalse(rsp.hasErrors(), rsp.getErrors().toString());
assertEquals("Continue onto Carrer Antoni Fiter i Rossell", rsp.getBest().getInstructions().get(3).getName());
request.getHints().putObject("turn_description", false);
rsp = hopper.route(request);
assertFalse(rsp.hasErrors());
assertEquals("Carrer Antoni Fiter i Rossell", rsp.getBest().getInstructions().get(3).getName());
}
use of com.graphhopper.api.GraphHopperWeb in project graphhopper by graphhopper.
the class RouteResourceTest method testGPXExport.
@Test
public void testGPXExport() {
GHRequest req = new GHRequest(42.554851, 1.536198, 42.510071, 1.548128);
req.putHint("elevation", false);
req.putHint("instructions", true);
req.putHint("calc_points", true);
req.putHint("gpx.millis", "300000000");
req.putHint("type", "gpx");
GraphHopperWeb gh = new GraphHopperWeb(clientUrl(app, "/route")).setPostRequest(false);
String res = gh.export(req);
assertTrue(res.contains("<gpx"));
assertTrue(res.contains("<rtept lat="));
assertTrue(res.contains("<trk><name>GraphHopper Track</name><trkseg>"));
assertTrue(res.endsWith("</gpx>"));
// this is due to `gpx.millis` we set (dates are shifted by the given (ms!) value from 1970-01-01)
assertTrue(res.contains("1970-01-04"));
}
use of com.graphhopper.api.GraphHopperWeb in project graphhopper by graphhopper.
the class RouteResourceTest method testGraphHopperWeb.
@Test
public void testGraphHopperWeb() {
GraphHopperWeb hopper = new GraphHopperWeb(clientUrl(app, "/route"));
GHResponse rsp = hopper.route(new GHRequest(42.554851, 1.536198, 42.510071, 1.548128).setProfile("my_car"));
assertFalse(rsp.hasErrors(), rsp.getErrors().toString());
assertTrue(rsp.getErrors().isEmpty(), rsp.getErrors().toString());
ResponsePath res = rsp.getBest();
assertTrue(res.getDistance() > 9000, "distance wasn't correct:" + res.getDistance());
assertTrue(res.getDistance() < 9500, "distance wasn't correct:" + res.getDistance());
rsp = hopper.route(new GHRequest().setProfile("my_car").addPoint(new GHPoint(42.554851, 1.536198)).addPoint(new GHPoint(42.531896, 1.553278)).addPoint(new GHPoint(42.510071, 1.548128)));
assertTrue(rsp.getErrors().isEmpty(), rsp.getErrors().toString());
res = rsp.getBest();
assertTrue(res.getDistance() > 20000, "distance wasn't correct:" + res.getDistance());
assertTrue(res.getDistance() < 21000, "distance wasn't correct:" + res.getDistance());
InstructionList instructions = res.getInstructions();
assertEquals(24, instructions.size());
assertEquals("Continue onto la Callisa", instructions.get(0).getTurnDescription(null));
assertEquals("At roundabout, take exit 2", instructions.get(4).getTurnDescription(null));
assertEquals(true, instructions.get(4).getExtraInfoJSON().get("exited"));
assertEquals(false, instructions.get(22).getExtraInfoJSON().get("exited"));
}
use of com.graphhopper.api.GraphHopperWeb in project graphhopper by graphhopper.
the class RouteResourceClientHCTest method doNotReadFinishInstruction.
@ParameterizedTest
@EnumSource(value = TestParam.class)
public void doNotReadFinishInstruction(TestParam p) {
GraphHopperWeb gh = createGH(p);
GHRequest req = new GHRequest().addPoint(new GHPoint(42.507065, 1.529846)).addPoint(new GHPoint(42.510383, 1.533392)).putHint("vehicle", "car").putHint("turn_description", false);
GHResponse res = gh.route(req);
InstructionList instructions = res.getBest().getInstructions();
String finishInstructionName = instructions.get(instructions.size() - 1).getName();
assertEquals("", finishInstructionName);
}
use of com.graphhopper.api.GraphHopperWeb in project graphhopper by graphhopper.
the class RouteResourceClientHCTest method testOutOfBoundsException.
@ParameterizedTest
@EnumSource(value = TestParam.class)
public void testOutOfBoundsException(TestParam p) {
GraphHopperWeb gh = createGH(p);
GHRequest req = new GHRequest().addPoint(new GHPoint(-400.214943, -130.078125)).addPoint(new GHPoint(39.909736, -91.054687)).putHint("vehicle", "car");
GHResponse res = gh.route(req);
assertTrue(res.hasErrors(), "no errors found?");
assertTrue(res.getErrors().get(0) instanceof PointOutOfBoundsException);
}
Aggregations