use of com.graphhopper.util.shapes.GHPoint in project graphhopper by graphhopper.
the class GraphHopperWebTest method testGetClientForRequest.
@ParameterizedTest(name = "POST={0}")
@ValueSource(booleans = { true, false })
public void testGetClientForRequest(boolean usePost) {
GraphHopperWeb gh = new GraphHopperWeb(null).setPostRequest(usePost);
GHRequest req = new GHRequest().addPoint(new GHPoint(42.509225, 1.534728)).addPoint(new GHPoint(42.512602, 1.551558)).putHint("vehicle", "car");
req.putHint(GraphHopperWeb.TIMEOUT, 5);
assertEquals(5, gh.getClientForRequest(req).connectTimeoutMillis());
}
use of com.graphhopper.util.shapes.GHPoint in project graphhopper by graphhopper.
the class GHMatrixAbstractRequester method putPoints.
private void putPoints(ObjectNode requestJson, String name, List<GHPoint> pList) {
if (pList.isEmpty())
return;
ArrayNode outList = objectMapper.createArrayNode();
for (GHPoint p : pList) {
ArrayNode entry = objectMapper.createArrayNode();
entry.add(p.lon);
entry.add(p.lat);
outList.add(entry);
}
requestJson.putArray(name).addAll(outList);
}
use of com.graphhopper.util.shapes.GHPoint in project graphhopper by graphhopper.
the class GHMRequestTest method testCompact.
@Test
public void testCompact() {
GHMRequest request = new GHMRequest();
for (int i = 0; i < 3; i++) {
request.addFromPoint(new GHPoint());
request.addFromPointHint("");
}
request.addToPoint(new GHPoint());
request.addToPointHint("");
request.compactPointHints();
assertTrue(request.getToPointHints().isEmpty());
assertTrue(request.getFromPointHints().isEmpty());
}
use of com.graphhopper.util.shapes.GHPoint in project graphhopper by graphhopper.
the class GHRequestTest method testCorrectInit.
@Test
public void testCorrectInit() {
double lat0 = 51, lon0 = 1, lat1 = 52, lon1 = 2, lat2 = 53, lon2 = 3;
ArrayList<GHPoint> points = new ArrayList<>(3);
points.add(new GHPoint(lat0, lon0));
points.add(new GHPoint(lat1, lon1));
points.add(new GHPoint(lat2, lon2));
List<Double> favoredHeadings = Arrays.asList(3.14, 4.15, Double.NaN);
GHRequest instance;
instance = new GHRequest(points, favoredHeadings);
compareFavoredHeadings(instance, favoredHeadings);
comparePoints(instance, points);
instance = new GHRequest(points.get(0), points.get(1), favoredHeadings.get(0), favoredHeadings.get(1));
compareFavoredHeadings(instance, favoredHeadings.subList(0, 2));
comparePoints(instance, points.subList(0, 2));
instance = new GHRequest(lat0, lon0, lat1, lon1, favoredHeadings.get(0), favoredHeadings.get(1));
compareFavoredHeadings(instance, favoredHeadings.subList(0, 2));
comparePoints(instance, points.subList(0, 2));
// check init without favoredHeadings
instance = new GHRequest(points);
comparePoints(instance, points);
compareFavoredHeadings(instance, emptyList());
instance = new GHRequest(points.get(0), points.get(1));
comparePoints(instance, points.subList(0, 2));
compareFavoredHeadings(instance, emptyList());
instance = new GHRequest(lat0, lon0, lat1, lon1);
comparePoints(instance, points.subList(0, 2));
compareFavoredHeadings(instance, emptyList());
}
use of com.graphhopper.util.shapes.GHPoint in project graphhopper by graphhopper.
the class HeadingRoutingTest method headingTest1.
@Test
public void headingTest1() {
// Test enforce start direction
GraphHopperStorage graph = createSquareGraph();
Router router = createRouter(graph);
// Start in middle of edge 4-5
GHPoint start = new GHPoint(0.0015, 0.002);
// End at middle of edge 2-3
GHPoint end = new GHPoint(0.002, 0.0005);
GHRequest req = new GHRequest().setPoints(Arrays.asList(start, end)).setHeadings(Arrays.asList(180., Double.NaN)).setProfile("profile").setPathDetails(Collections.singletonList("edge_key"));
GHResponse response = router.route(req);
assertFalse(response.hasErrors(), response.getErrors().toString());
assertArrayEquals(new int[] { 4, 5, 8, 3, 2 }, calcNodes(graph, response.getAll().get(0)));
}
Aggregations