Skip to content

Commit 17eb7fb

Browse files
authored
Merge pull request #942 from GIScience/bugfix#939-use_speed_limit_definitions_from_json_files
Address some issues in resolving speed for driving profiles.
2 parents b742818 + 1e0770c commit 17eb7fb

File tree

8 files changed

+245
-171
lines changed

8 files changed

+245
-171
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ RELEASING:
3939
- Option to disable edge-based routing in core for a single weighting ([#928](https://github.com/GIScience/openrouteservice/issues/928))
4040
### Fixed
4141
- Do not consider ill-defined "maxspeed = 0" OSM tags ([#940](https://github.com/GIScience/openrouteservice/issues/940))
42+
- Use JSON definitions of country-specific speed limits ([#939](https://github.com/GIScience/openrouteservice/issues/939))
4243
- Config file parameter to set the number of active landmarks for core routing ([#930](https://github.com/GIScience/openrouteservice/issues/930))
4344
- Make sure A* with beeline approximation is used as default fallback algorithm ([#926](https://github.com/GIScience/openrouteservice/issues/926))
4445
- Prioritize graph build date over data date in routing request ([#925](https://github.com/GIScience/openrouteservice/issues/925))

openrouteservice-api-tests/src/test/java/org/heigit/ors/v2/services/isochrones/ResultTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ public void testLocationType() {
221221
.when()
222222
.post(getEndPointPath() + "/{profile}/geojson")
223223
.then().log().ifValidationFails()
224-
.body("features[0].properties.area", is(1688618.6f))
224+
.body("features[0].properties.area", is(1699492.0f))
225225
.statusCode(200);
226226

227227
body.put("location_type", "destination");
@@ -233,7 +233,7 @@ public void testLocationType() {
233233
.when()
234234
.post(getEndPointPath() + "/{profile}/geojson")
235235
.then().log().ifValidationFails()
236-
.body("features[0].properties.area", is(1552274.2f))
236+
.body("features[0].properties.area", is(1561223.9f))
237237
.statusCode(200);
238238
}
239239

openrouteservice-api-tests/src/test/java/org/heigit/ors/v2/services/isochrones/fast/ResultTest.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -345,11 +345,9 @@ public void testIntersections() {
345345
.body("features[1].geometry.type", is("Polygon"))
346346
.body("features[2].type", is("Feature"))
347347
.body("features[2].geometry.type", is("Polygon"))
348-
//.body("features[2].geometry.coordinates[0].size()", is(26))
349-
.body("features[2].geometry.coordinates[0].size()", is(85))
348+
.body("features[2].geometry.coordinates[0].size()", is(86))
350349
.body("features[2].properties.contours.size()", is(2))
351350
.body("features[2].properties.containsKey('area')", is(true))
352-
//.body("features[2].properties.area", is(5824280.5f))
353351
.body("features[0].properties.area", is(both(greaterThan(12000000f)).and(lessThan(13000000f))))
354352
.body("features[2].properties.contours[0][0]", is(0))
355353
.body("features[2].properties.contours[0][1]", is(0))

openrouteservice-api-tests/src/test/java/org/heigit/ors/v2/services/routing/ResultTest.java

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3374,6 +3374,98 @@ public void testConditionalSpeed() {
33743374
.statusCode(200);
33753375
}
33763376

3377+
@Test
3378+
public void expectZoneMaxpeed() {
3379+
JSONArray coordinates = new JSONArray();
3380+
JSONArray coord1 = new JSONArray();
3381+
coord1.put(8.676031);
3382+
coord1.put(49.417011);
3383+
coordinates.put(coord1);
3384+
JSONArray coord2 = new JSONArray();
3385+
coord2.put(8.674965);
3386+
coord2.put(49.419587);
3387+
coordinates.put(coord2);
3388+
3389+
JSONObject body = new JSONObject();
3390+
body.put("coordinates", coordinates);
3391+
body.put("preference", getParameter("preference"));
3392+
3393+
// Test that "zone:maxspeed = DE:urban" overrides default "highway = residential" speed for both car and hgv
3394+
given()
3395+
.header("Accept", "application/json")
3396+
.header("Content-Type", "application/json")
3397+
.pathParam("profile", getParameter("carProfile"))
3398+
.body(body.toString())
3399+
.when()
3400+
.post(getEndPointPath() + "/{profile}")
3401+
.then()
3402+
.assertThat()
3403+
.body("any { it.key == 'routes' }", is(true))
3404+
.body("routes[0].summary.distance", is(367.9f))
3405+
.body("routes[0].summary.duration", is(53.0f))
3406+
.statusCode(200);
3407+
3408+
given()
3409+
.header("Accept", "application/json")
3410+
.header("Content-Type", "application/json")
3411+
.pathParam("profile", "driving-hgv")
3412+
.body(body.toString())
3413+
.when()
3414+
.post(getEndPointPath() + "/{profile}")
3415+
.then()
3416+
.assertThat()
3417+
.body("any { it.key == 'routes' }", is(true))
3418+
.body("routes[0].summary.distance", is(367.9f))
3419+
.body("routes[0].summary.duration", is(53.0f))
3420+
.statusCode(200);
3421+
}
3422+
3423+
@Test
3424+
public void expectMaxpeedHgvForward() {
3425+
JSONArray coordinates = new JSONArray();
3426+
JSONArray coord1 = new JSONArray();
3427+
coord1.put(8.696237);
3428+
coord1.put(49.37186);
3429+
coordinates.put(coord1);
3430+
JSONArray coord2 = new JSONArray();
3431+
coord2.put(8.693427);
3432+
coord2.put(49.367914);
3433+
coordinates.put(coord2);
3434+
3435+
JSONObject body = new JSONObject();
3436+
body.put("coordinates", coordinates);
3437+
body.put("preference", getParameter("preference"));
3438+
3439+
// Test that "maxspeed:hgv:forward = 30" when going downhill on Am Götzenberg is taken into account for hgv profile
3440+
given()
3441+
.header("Accept", "application/json")
3442+
.header("Content-Type", "application/json")
3443+
.pathParam("profile", getParameter("carProfile"))
3444+
.body(body.toString())
3445+
.when()
3446+
.post(getEndPointPath() + "/{profile}")
3447+
.then()
3448+
.assertThat()
3449+
.body("any { it.key == 'routes' }", is(true))
3450+
.body("routes[0].summary.distance", is(497.5f))
3451+
.body("routes[0].summary.duration", is(61.9f))
3452+
.statusCode(200);
3453+
3454+
given()
3455+
.header("Accept", "application/json")
3456+
.header("Content-Type", "application/json")
3457+
.pathParam("profile", "driving-hgv")
3458+
.body(body.toString())
3459+
.when()
3460+
.post(getEndPointPath() + "/{profile}")
3461+
.then()
3462+
.assertThat()
3463+
.body("any { it.key == 'routes' }", is(true))
3464+
.body("routes[0].summary.distance", is(497.5f))
3465+
.body("routes[0].summary.duration", is(81.1f))
3466+
.statusCode(200);
3467+
}
3468+
33773469
private JSONArray constructBearings(String coordString) {
33783470
JSONArray coordinates = new JSONArray();
33793471
String[] coordPairs = coordString.split("\\|");
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
package org.heigit.ors.routing.graphhopper.extensions.flagencoders;
22

33
public class FlagEncoderNames {
4-
public static final String CAR_ORS = "car-ors";
4+
private static final String ORS_SUFFIX = "-ors";
5+
6+
public static final String CAR_ORS = "car" + ORS_SUFFIX;
57
public static final String HEAVYVEHICLE = "heavyvehicle";
68
public static final String EMERGENCY = "emergency";
79
public static final String EVEHICLE = "evehicle"; // NOT IMPLEMENTED
810
public static final String RUNNING = "running"; // NOT IMPLEMENTED
911

1012
public static final String WHEELCHAIR = "wheelchair";
1113

12-
public static final String BIKE_ORS = "bike-ors";
13-
public static final String ROADBIKE_ORS = "roadbike-ors";
14-
public static final String MTB_ORS = "mtb-ors";
14+
public static final String BIKE_ORS = "bike" + ORS_SUFFIX;
15+
public static final String ROADBIKE_ORS = "roadbike" + ORS_SUFFIX;
16+
public static final String MTB_ORS = "mtb" + ORS_SUFFIX;
1517
public static final String BIKE_ELECTRO = "electrobike";
1618

17-
public static final String PEDESTRIAN_ORS = "pedestrian-ors";
18-
public static final String HIKING_ORS = "hiking-ors";
19+
public static final String PEDESTRIAN_ORS = "pedestrian" + ORS_SUFFIX;
20+
public static final String HIKING_ORS = "hiking" + ORS_SUFFIX;
1921

2022

2123
public static final String GH_CAR = "car";
@@ -29,4 +31,11 @@ public class FlagEncoderNames {
2931
public static final String GH_BIKE2 = "bike2";
3032

3133
private FlagEncoderNames() {}
34+
35+
public static String getBaseName(String name) {
36+
if (name.endsWith(ORS_SUFFIX))
37+
name = name.substring(0, name.indexOf(ORS_SUFFIX));
38+
39+
return name;
40+
}
3241
}

0 commit comments

Comments
 (0)