use of com.graphhopper.GHResponse in project graphhopper by graphhopper.
the class RouteResourceClientHCTest method testSimpleRoute.
@ParameterizedTest
@EnumSource(value = TestParam.class)
public void testSimpleRoute(TestParam p) {
GraphHopperWeb gh = createGH(p);
GHRequest req = new GHRequest().addPoint(new GHPoint(42.5093, 1.5274)).addPoint(new GHPoint(42.5126, 1.5410)).putHint("vehicle", "car").putHint("elevation", false).putHint("instructions", true).putHint("calc_points", true);
GHResponse rsp = gh.route(req);
assertFalse(rsp.hasErrors(), "errors:" + rsp.getErrors().toString());
ResponsePath res = rsp.getBest();
isBetween(60, 70, res.getPoints().size());
isBetween(2900, 3000, res.getDistance());
isBetween(110, 120, res.getAscend());
isBetween(70, 80, res.getDescend());
isBetween(190, 200, res.getRouteWeight());
// change vehicle
rsp = gh.route(new GHRequest(42.5093, 1.5274, 42.5126, 1.5410).putHint("vehicle", "bike"));
res = rsp.getBest();
assertFalse(rsp.hasErrors(), "errors:" + rsp.getErrors().toString());
isBetween(2500, 2600, res.getDistance());
assertEquals("[0, 1]", res.getPointsOrder().toString());
}
use of com.graphhopper.GHResponse in project graphhopper by graphhopper.
the class RouteResourceClientHCTest method testRetrieveOnlyStreetname.
@ParameterizedTest
@EnumSource(value = TestParam.class)
public void testRetrieveOnlyStreetname(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");
GHResponse res = gh.route(req);
List<String> given = extractInstructionNames(res.getBest(), 5);
assertEquals(Arrays.asList("Continue onto Carrer de l'Aigüeta", "Turn right onto Carrer Pere d'Urg", "Turn right onto Carrer Bonaventura Armengol", "Keep right onto Avinguda Consell d'Europa", "At roundabout, take exit 4"), given);
req.putHint("turn_description", false);
res = gh.route(req);
given = extractInstructionNames(res.getBest(), 5);
assertEquals(Arrays.asList("Carrer de l'Aigüeta", "Carrer Pere d'Urg", "Carrer Bonaventura Armengol", "Avinguda Consell d'Europa", ""), given);
}
use of com.graphhopper.GHResponse in project graphhopper by graphhopper.
the class RouteResourceClientHCTest method readFinishInstruction.
@ParameterizedTest
@EnumSource(value = TestParam.class)
public void readFinishInstruction(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");
GHResponse res = gh.route(req);
InstructionList instructions = res.getBest().getInstructions();
String finishInstructionName = instructions.get(instructions.size() - 1).getName();
assertEquals("Arrive at destination", finishInstructionName);
}
use of com.graphhopper.GHResponse in project graphhopper by graphhopper.
the class RouteResourceClientHCTest method testPointHints.
@ParameterizedTest
@EnumSource(value = TestParam.class)
public void testPointHints(TestParam p) {
GraphHopperWeb gh = createGH(p);
GHRequest req = new GHRequest().addPoint(new GHPoint(42.50856, 1.528451)).addPoint(new GHPoint(42.510383, 1.533392)).setProfile("my_car");
GHResponse response = gh.route(req);
isBetween(890, 900, response.getBest().getDistance());
req.setPointHints(Arrays.asList("Carrer Bonaventura Armengol", ""));
response = gh.route(req);
isBetween(520, 550, response.getBest().getDistance());
}
use of com.graphhopper.GHResponse in project graphhopper by graphhopper.
the class RouteResourceTest method testSnapPreventionsAndPointHints.
@Test
public void testSnapPreventionsAndPointHints() {
GraphHopperWeb hopper = new GraphHopperWeb(clientUrl(app, "/route"));
GHRequest request = new GHRequest(42.511139, 1.53285, 42.508165, 1.532271);
request.setProfile("my_car");
request.setSnapPreventions(Collections.singletonList("tunnel"));
request.setPointHints(Arrays.asList("Avinguda Fiter i Rossell", ""));
GHResponse rsp = hopper.route(request);
assertFalse(rsp.hasErrors(), rsp.getErrors().toString());
assertEquals(1590, rsp.getBest().getDistance(), 2);
// contradicting hints should still allow routing
request.setSnapPreventions(Collections.singletonList("tunnel"));
request.setPointHints(Arrays.asList("Tunèl del Pont Pla", ""));
rsp = hopper.route(request);
assertEquals(490, rsp.getBest().getDistance(), 2);
}
Aggregations