use of com.graphhopper.GHResponse in project graphhopper by graphhopper.
the class HeadingRoutingTest method headingTest6.
@Test
public void headingTest6() {
// Test if snaps at tower nodes are ignored
GraphHopperStorage graph = createSquareGraph();
Router router = createRouter(graph);
// QueryPoints directly on TowerNodes
GHPoint start = new GHPoint(0, 0);
GHPoint via = new GHPoint(0.002, 0.000);
GHPoint end = new GHPoint(0.002, 0.002);
GHRequest req = new GHRequest().setPoints(Arrays.asList(start, via, end)).setHeadings(Arrays.asList(90., 270., 270.)).setProfile("profile").setPathDetails(Collections.singletonList("edge_key"));
GHResponse response = router.route(req);
assertFalse(response.hasErrors());
assertArrayEquals(new int[] { 0, 1, 2, 3, 4 }, calcNodes(graph, response.getAll().get(0)));
}
use of com.graphhopper.GHResponse in project graphhopper by graphhopper.
the class HeadingRoutingTest method headingTest3.
@Test
public void headingTest3() {
GraphHopperStorage graph = createSquareGraph();
Router router = createRouter(graph);
// Start in middle of edge 4-5
GHPoint start = new GHPoint(0.0015, 0.002);
// Via Point between 8-7
GHPoint via = new GHPoint(0.0005, 0.001);
// End at middle of edge 2-3
GHPoint end = new GHPoint(0.002, 0.0005);
GHRequest req = new GHRequest().setPoints(Arrays.asList(start, via, end)).setHeadings(Arrays.asList(Double.NaN, 0., Double.NaN)).setProfile("profile").setPathDetails(Collections.singletonList("edge_key"));
GHResponse response = router.route(req);
assertFalse(response.hasErrors());
assertArrayEquals(new int[] { 4, 5, 6, 7, 8, 3, 2 }, calcNodes(graph, response.getAll().get(0)));
}
use of com.graphhopper.GHResponse 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.GHResponse 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);
}
use of com.graphhopper.GHResponse in project graphhopper by graphhopper.
the class RouteResourceClientHCTest method testPathDetails.
@ParameterizedTest
@EnumSource(value = TestParam.class)
public void testPathDetails(TestParam p) {
GraphHopperWeb gh = createGH(p);
GHRequest req = new GHRequest().addPoint(new GHPoint(42.507065, 1.529846)).addPoint(new GHPoint(42.510383, 1.533392)).setProfile("my_car");
req.getPathDetails().add("average_speed");
GHResponse res = gh.route(req);
assertFalse(res.hasErrors(), "errors:" + res.getErrors().toString());
ResponsePath alt = res.getBest();
assertEquals(1, alt.getPathDetails().size());
List<PathDetail> details = alt.getPathDetails().get("average_speed");
assertFalse(details.isEmpty());
assertTrue((Double) details.get(0).getValue() > 20);
assertTrue((Double) details.get(0).getValue() < 70);
}
Aggregations