Skip to content

Commit 853a1cb

Browse files
committed
append point hints for client-hc, graphhopper#1405
1 parent b8d8019 commit 853a1cb

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

client-hc/src/main/java/com/graphhopper/api/GraphHopperWeb.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ PathWrapper createPathWrapper(JsonNode path, boolean tmpElevation, boolean turnD
128128
JsonNode descriptionNode = path.get("description");
129129
if (descriptionNode.isArray()) {
130130
List<String> description = new ArrayList<>(descriptionNode.size());
131-
for (JsonNode descNode: descriptionNode) {
131+
for (JsonNode descNode : descriptionNode) {
132132
description.add(descNode.asText());
133133
}
134134
pathWrapper.setDescription(description);
@@ -431,6 +431,10 @@ private Request createRequest(GHRequest request) {
431431
url += "&" + Parameters.DETAILS.PATH_DETAILS + "=" + details;
432432
}
433433

434+
for (String hint : request.getPointHints()) {
435+
url += "&point_hint=" + WebHelper.encodeURL(hint);
436+
}
437+
434438
if (!key.isEmpty()) {
435439
url += "&key=" + WebHelper.encodeURL(key);
436440
}

client-hc/src/test/java/com/graphhopper/api/GraphHopperWebIT.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ public void testCannotFindPointException() {
169169
assertTrue(res.getErrors().get(0) instanceof PointNotFoundException);
170170
}
171171

172-
173172
@Test
174173
public void testOutOfBoundsException() {
175174
GHRequest req = new GHRequest().
@@ -332,4 +331,15 @@ public void testPathDetails() {
332331
assertTrue((Double) details.get(0).getValue() > 20);
333332
assertTrue((Double) details.get(0).getValue() < 70);
334333
}
334+
335+
@Test
336+
public void testPointHints() {
337+
GHRequest ghRequest = new GHRequest();
338+
ghRequest.addPoint(new GHPoint(52.50977, 13.371971));
339+
ghRequest.addPoint(new GHPoint(52.509842, 13.369761));
340+
341+
ghRequest.setPointHints(Arrays.asList("Ben-Gurion", ""));
342+
GHResponse response = gh.route(ghRequest);
343+
assertTrue(response.getBest().getDistance() + "m", response.getBest().getDistance() < 500);
344+
}
335345
}

0 commit comments

Comments
 (0)