Skip to content

Commit

Permalink
Merge tag 'tags/9.1' into osm-reader-callbacks-9.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Nakaner committed May 8, 2024
2 parents 770f047 + 73e6b7c commit e151767
Show file tree
Hide file tree
Showing 360 changed files with 8,386 additions and 6,874 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: [ 22, 23-ea ]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-github-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
jobs:
publish:
if: github.repository_owner == 'graphhopper'
runs-on: ubuntu-20.04
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
17 changes: 16 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
### 8.0 [not yet released]
### 9.0 [not yet released]

- max_slope is now a signed decimal, see #2955
- move sac_scale handling out of foot_access parser and made foot safer via lowering to sac_scale<2, same for hike sac_scale<5
- removed shortest+fastest weightings, #2938
- u_turn_costs information is no longer stored in profile. Use the TurnCostsConfig instead
- the custom models do no longer include the speed, access and priority encoded values only implicitly, see docs/migration/config-migration-08-09.md
- conditional access restriction tags are no longer considered from vehicle tag parsers and instead a car_temporal_access encoded value (similarly for bike + foot) can be used in a custom model. This fixes #2477. More details are accessible via path details named according to the OSM tags e.g. for access:conditional it is "access_conditional" (i.e. converted from OSM access:conditional). See #2863 and #2965.
- 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
Expand Down
3 changes: 2 additions & 1 deletion CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Here is an overview:
* Janekdererste, GUI for public transit
* jansoe, many improvements regarding A* algorithm, forcing direction, roundabouts etc
* jansonhanson, general host config
* jessLryan, max elevation can now be negative
* joe-akeem, improvements like #2158
* JohannesPelzer, improved GPX information and various other things
* karussell, one of the core developers
Expand Down Expand Up @@ -89,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)
21 changes: 15 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ Released versions of the fork follow this naming schema: `<upstream_version>-osm

![Build Status](https://github.com/graphhopper/graphhopper/actions/workflows/build.yml/badge.svg?branch=master)

GraphHopper is a fast and memory-efficient routing engine released under Apache License 2.0. It can be used as a Java library or standalone web server to calculate the distance, time, turn-by-turn instructions and many road attributes for a route between two or more points. Beyond this "A-to-B" routing it supports ["snap to road"](README.md#Map-Matching), [Isochrone calculation](README.md#Analysis), [mobile navigation](README.md#mobile-apps) and [more](README.md#Features). GraphHopper uses OpenStreetMap and GTFS data by default and it can import [other data sources too](README.md#OpenStreetMap-Support).
GraphHopper is a fast and memory-efficient routing engine released under Apache License 2.0.
It can be used as a Java library or standalone web server to calculate the distance, time,
turn-by-turn instructions and many road attributes for a route between two or more points.
Beyond this "A-to-B" routing it supports ["snap to road"](README.md#Map-Matching),
[Isochrone calculation](README.md#Analysis), [mobile navigation](README.md#mobile-apps) and
[more](README.md#Features). GraphHopper uses OpenStreetMap and GTFS data by default and it
can import [other data sources too](README.md#OpenStreetMap-Support).

# Community

Expand All @@ -39,15 +45,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.

* 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/)
* 9.x: [documentation](https://github.com/graphhopper/graphhopper/blob/9.x/docs/index.md)
, [web service jar](https://repo1.maven.org/maven2/com/graphhopper/graphhopper-web/9.1/graphhopper-web-9.1.jar)
, [announcement](https://www.graphhopper.com/blog/2024/04/23/graphhopper-routing-engine-9-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.

* 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/)
* 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/)
Expand Down Expand Up @@ -102,7 +111,7 @@ 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/8.0/graphhopper-web-8.0.jar https://raw.githubusercontent.com/graphhopper/graphhopper/8.x/config-example.yml http://download.geofabrik.de/europe/germany/berlin-latest.osm.pbf
Expand Down Expand Up @@ -253,7 +262,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
6 changes: 3 additions & 3 deletions benchmark/benchmark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ set -o xtrace
defaultGraphDir=measurements/
defaultResultsDir=measurements/results/$(date '+%d-%m-%Y-%s%N')/
defaultSummaryDir=measurements/
defaultSmallMap=core/files/andorra.osm.pbf
defaultBigMap=core/files/andorra.osm.pbf
defaultSmallMap=map-matching/files/leipzig_germany.osm.pbf
defaultBigMap=map-matching/files/leipzig_germany.osm.pbf
defaultUseMeasurementTimeAsRefTime=false

GRAPH_DIR=${1:-$defaultGraphDir}
Expand Down Expand Up @@ -105,7 +105,7 @@ measurement.repeats=1 \
measurement.run_slow_routing=false \
measurement.weighting=custom \
measurement.custom_model_file=benchmark/very_custom.json \
graph.encoded_values=max_width,max_height,toll,hazmat \
graph.encoded_values=max_width,max_height,toll,hazmat,road_access,road_class \
measurement.ch.node=true \
measurement.ch.edge=false \
measurement.lm=true \
Expand Down
4 changes: 3 additions & 1 deletion benchmark/very_custom.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// this is a heavily customized model used to benchmark routing with a custom weighting
{
"speed": [
{ "if": "true", "limit_to": "car_average_speed" },
{ "if": "road_class == MOTORWAY", "multiply_by": "0.85" },
{ "else_if": "road_class == PRIMARY", "multiply_by": "0.9" },
{ "if": "true", "limit_to": "110" }
],
"priority": [
{ "if": "!car_access", "multiply_by": "0" },
{ "if": "road_access == PRIVATE", "multiply_by": "0" },
{ "if": "max_height < 3.8", "multiply_by": "0" },
{ "if": "max_width < 2.5", "multiply_by": "0" },
Expand All @@ -14,4 +16,4 @@
{ "if": "toll != NO", "multiply_by": "0.5" },
{ "if": "hazmat == NO", "multiply_by": "0" }
]
}
}
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-osm-reader-callbacks</version>
<version>9.1-osm-reader-callbacks-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-osm-reader-callbacks</version>
<version>9.1-osm-reader-callbacks-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 {
protected record JsonResult(String body, int statusCode, Map<String, List<String>> headers) {
}

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(), rsp.headers().toMultimap());
} finally {
Helper.close(body);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@
package com.graphhopper.api;

import com.fasterxml.jackson.databind.JsonNode;
import com.graphhopper.jackson.ResponsePathDeserializer;
import com.graphhopper.jackson.ResponsePathDeserializerHelper;
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,22 @@ public MatrixResponse route(GHMRequest ghRequest) {
withTimes, withDistances, withWeights);
try {
String postUrl = buildURLNoHints("/calculate", ghRequest);
String postResponseStr = postJson(postUrl, requestJson);
JsonResult jsonResult = postJson(postUrl, requestJson);
matrixResponse.setHeaders(jsonResult.headers());
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.addErrors(ResponsePathDeserializer.readErrors(objectMapper, responseJson));
matrixResponse.setStatusCode(jsonResult.statusCode());
matrixResponse.addErrors(ResponsePathDeserializerHelper.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 +112,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.addErrors(ResponsePathDeserializerHelper.readErrors(objectMapper, getResponseJson));
matrixResponse.setStatusCode(rsp.statusCode());
if (matrixResponse.hasErrors()) {
break;
}
Expand Down Expand Up @@ -155,14 +159,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(), rsp.headers().toMultimap());
} finally {
Helper.close(body);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.graphhopper.api;

import com.fasterxml.jackson.databind.JsonNode;
import com.graphhopper.jackson.ResponsePathDeserializer;
import com.graphhopper.jackson.ResponsePathDeserializerHelper;
import okhttp3.OkHttpClient;

import java.io.IOException;
Expand Down Expand Up @@ -40,13 +40,16 @@ 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.setHeaders(jsonResult.headers());
matrixResponse.setStatusCode(jsonResult.statusCode());
if (responseJson.has("message")) {
matrixResponse.addErrors(ResponsePathDeserializer.readErrors(objectMapper, responseJson));
matrixResponse.addErrors(ResponsePathDeserializerHelper.readErrors(objectMapper, responseJson));
return matrixResponse;
}

matrixResponse.addErrors(ResponsePathDeserializer.readErrors(objectMapper, responseJson));
matrixResponse.addErrors(ResponsePathDeserializerHelper.readErrors(objectMapper, responseJson));
if (!matrixResponse.hasErrors())
matrixResponse.addErrors(readUsableEntityError(ghRequest.getOutArrays(), responseJson));

Expand Down
Loading

0 comments on commit e151767

Please sign in to comment.