use of com.graphhopper.api.GraphHopperWeb in project graphhopper by graphhopper.
the class RouteResourceClientHCTest method testCannotFindPointException.
@ParameterizedTest
@EnumSource(value = TestParam.class)
public void testCannotFindPointException(TestParam p) {
GraphHopperWeb gh = createGH(p);
GHRequest req = new GHRequest().addPoint(new GHPoint(42.49058, 1.602974)).addPoint(new GHPoint(42.510383, 1.533392)).putHint("vehicle", "car");
GHResponse res = gh.route(req);
assertTrue(res.hasErrors(), "no errors found?");
assertTrue(res.getErrors().get(0) instanceof PointNotFoundException);
}
use of com.graphhopper.api.GraphHopperWeb in project graphhopper by graphhopper.
the class RouteResourceClientHCTest method testNoPoints.
@ParameterizedTest
@EnumSource(value = TestParam.class)
public void testNoPoints(TestParam p) {
GraphHopperWeb gh = createGH(p);
GHRequest req = new GHRequest().addPoint(new GHPoint(42.509225, 1.534728)).addPoint(new GHPoint(42.512602, 1.551558)).putHint("vehicle", "car");
req.putHint("instructions", false);
req.putHint("calc_points", false);
GHResponse rsp = gh.route(req);
assertFalse(rsp.hasErrors(), "errors:" + rsp.getErrors().toString());
ResponsePath res = rsp.getBest();
assertEquals(0, res.getPoints().size());
isBetween(1750, 1800, res.getDistance());
}
use of com.graphhopper.api.GraphHopperWeb in project graphhopper by graphhopper.
the class RouteResourceClientHCTest method readRoundabout.
@ParameterizedTest
@EnumSource(value = TestParam.class)
public void readRoundabout(TestParam p) {
GraphHopperWeb gh = createGH(p);
GHRequest req = new GHRequest().addPoint(new GHPoint(42.509644, 1.532958)).addPoint(new GHPoint(42.510383, 1.533392)).putHint("vehicle", "car");
GHResponse res = gh.route(req);
int counter = 0;
for (Instruction i : res.getBest().getInstructions()) {
if (i instanceof RoundaboutInstruction) {
counter++;
RoundaboutInstruction ri = (RoundaboutInstruction) i;
assertEquals(-5, ri.getTurnAngle(), 0.1, "turn_angle was incorrect:" + ri.getTurnAngle());
// This route contains only one roundabout and no (via) point in a roundabout
assertTrue(ri.isExited(), "exited was incorrect:" + ri.isExited());
}
}
assertTrue(counter > 0, "no roundabout in route?");
}
use of com.graphhopper.api.GraphHopperWeb in project graphhopper by graphhopper.
the class RouteResourceClientHCTest method testAlternativeRoute.
@ParameterizedTest
@EnumSource(value = TestParam.class)
public void testAlternativeRoute(TestParam p) {
GraphHopperWeb gh = createGH(p);
GHRequest req = new GHRequest().addPoint(new GHPoint(42.505041, 1.521864)).addPoint(new GHPoint(42.509074, 1.537936)).putHint("vehicle", "car").setAlgorithm("alternative_route").putHint("instructions", true).putHint("calc_points", true).putHint("ch.disable", true);
GHResponse res = gh.route(req);
assertFalse(res.hasErrors(), "errors:" + res.getErrors().toString());
List<ResponsePath> paths = res.getAll();
assertEquals(2, paths.size());
ResponsePath path = paths.get(0);
assertEquals(35, path.getPoints().size());
assertEquals(1689, path.getDistance(), 1);
assertTrue(path.getInstructions().toString().contains("Avinguda de Tarragona"), path.getInstructions().toString());
path = paths.get(1);
assertEquals(30, path.getPoints().size());
assertEquals(1759, path.getDistance(), 1);
assertTrue(path.getInstructions().toString().contains("Avinguda Prat de la Creu"), path.getInstructions().toString());
}
use of com.graphhopper.api.GraphHopperWeb in project graphhopper by graphhopper.
the class RouteResourceTest method testExportWithoutTrack.
@Test
public void testExportWithoutTrack() {
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("type", "gpx");
req.putHint("gpx.track", false);
GraphHopperWeb gh = new GraphHopperWeb(clientUrl(app, "/route")).setPostRequest(false);
String res = gh.export(req);
assertTrue(res.contains("<gpx"));
assertTrue(res.contains("<rtept lat="));
assertFalse(res.contains("<trk><name>GraphHopper Track</name><trkseg>"));
assertTrue(res.endsWith("</gpx>"));
}
Aggregations