Skip to content

Commit

Permalink
Merge tag '6.2' into osm-reader-callbacks-6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Philip Beelmann committed Apr 11, 2024
2 parents 19f9f0d + 6d3da37 commit c3e4aae
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ To get started you can try [GraphHopper Maps](README.md#graphhopper-maps), read

* 6.x: [documentation](https://github.com/graphhopper/graphhopper/blob/6.x/docs/index.md)
, [web service jar](https://github.com/graphhopper/graphhopper/releases/download/6.0/graphhopper-web-6.0.jar)
, [announcement](https://www.graphhopper.com/blog/2022/09/20/graphhopper-routing-engine-6-0-released/)
, [announcement](https://www.graphhopper.com/blog/2022/09/19/graphhopper-routing-engine-6-0-released/)
* unstable master: [documentation](https://github.com/graphhopper/graphhopper/blob/master/docs/index.md)

<details><summary>Click to see older releases</summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ public OkHttpClient getDownloader() {
protected JsonNode createPostRequest(GHMRequest ghRequest) {
if (ghRequest.getHints().getObject("profile", null) != null)
throw new IllegalArgumentException("use setProfile instead of hint 'profile'");
if (ghRequest.getProfile() == null)
throw new IllegalArgumentException("profile cannot be empty");
if (ghRequest.getHints().getObject("fail_fast", null) != null)
throw new IllegalArgumentException("use setFailFast instead of hint 'fail_fast'");

Expand Down Expand Up @@ -114,6 +116,7 @@ protected JsonNode createPostRequest(GHMRequest ghRequest) {
putStrings(requestJson, "snap_preventions", ghRequest.getSnapPreventions());
putStrings(requestJson, "out_arrays", ghRequest.getOutArrays());
requestJson.put("fail_fast", ghRequest.getFailFast());
requestJson.put("profile", ghRequest.getProfile());

Map<String, Object> hintsMap = ghRequest.getHints().toMap();
for (String hintKey : hintsMap.keySet()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public static GHMRequest createRequest() {
new GHPoint(51.473685, -0.211487)
));
req.setOutArrays(Arrays.asList("weights"));
req.setProfile("car");
return req;
}

Expand Down Expand Up @@ -80,6 +81,7 @@ public void testReadingMatrixConnectionsNotFound_noFailFast() throws IOException
));
req.setOutArrays(Arrays.asList("weights", "distances", "times"));
req.setFailFast(false);
req.setProfile("car");

MatrixResponse rsp = matrixWeb.route(req);
assertFalse(rsp.hasErrors());
Expand Down Expand Up @@ -108,6 +110,7 @@ public void testReadingMatrixPointsNotFound_noFailFast() throws IOException {
new GHPoint(2, 3),
new GHPoint(4, 5)
));
req.setProfile("car");
req.setOutArrays(Arrays.asList("weights", "distances", "times"));
req.setFailFast(false);

Expand Down Expand Up @@ -187,19 +190,32 @@ public void testReadingWeights_TimesAndDistances() throws IOException {
@Test
public void noProfileWhenNotSpecified() {
GHMatrixBatchRequester requester = new GHMatrixBatchRequester("url");
JsonNode json = requester.createPostRequest(new GHMRequest().setOutArrays(Collections.singletonList("weights")).setPoints(Arrays.asList(new GHPoint(11, 12))));
assertEquals("{\"points\":[[12.0,11.0]],\"out_arrays\":[\"weights\"],\"fail_fast\":true}", json.toString());
JsonNode json = requester.createPostRequest(new GHMRequest().setOutArrays(Collections.singletonList("weights")).
setPoints(Arrays.asList(new GHPoint(11, 12))).setProfile("car"));
assertEquals("{\"points\":[[12.0,11.0]],\"out_arrays\":[\"weights\"],\"fail_fast\":true,\"profile\":\"car\"}", json.toString());
}

@Test
public void hasProfile() {
GHMatrixAbstractRequester requester = createRequester("url");
GHMRequest ghmRequest = new GHMRequest();
ghmRequest.setOutArrays(Collections.singletonList("weights"));
ghmRequest.setPoints(Arrays.asList(new GHPoint(11, 12)));
ghmRequest.setProfile("bike");
JsonNode json = requester.createPostRequest(ghmRequest);
assertEquals("{\"points\":[[12.0,11.0]],\"out_arrays\":[\"weights\"],\"fail_fast\":true,\"profile\":\"bike\"}", json.toString());
}

@Test
public void hasHintsWhenSpecified() {
GHMatrixAbstractRequester requester = createRequester("url");
GHMRequest ghmRequest = new GHMRequest();
ghmRequest.setProfile("car");
ghmRequest.putHint("some_property", "value");
ghmRequest.setOutArrays(Collections.singletonList("weights"));
ghmRequest.setPoints(Arrays.asList(new GHPoint(11, 12)));
JsonNode json = requester.createPostRequest(ghmRequest);
assertEquals("{\"points\":[[12.0,11.0]],\"out_arrays\":[\"weights\"],\"fail_fast\":true,\"some_property\":\"value\"}", json.toString());
assertEquals("{\"points\":[[12.0,11.0]],\"out_arrays\":[\"weights\"],\"fail_fast\":true,\"profile\":\"car\",\"some_property\":\"value\"}", json.toString());

ghmRequest.putHint("profile", "car");
Exception ex = assertThrows(IllegalArgumentException.class, () -> requester.createPostRequest(ghmRequest));
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-dependencies</artifactId>
<version>2.0.21</version>
<version>2.0.34</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down

0 comments on commit c3e4aae

Please sign in to comment.