Skip to content

Commit

Permalink
optional parameter force_turn_costs
Browse files Browse the repository at this point in the history
  • Loading branch information
takb committed Oct 5, 2022
1 parent 5b3fe62 commit 5938659
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 7 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ RELEASING:

## [Unreleased]

## [6.7.1] - 2022-10-05
### Added
- optional `encoder_options` parameter `force_turn_costs` ([#1220](https://github.com/GIScience/openrouteservice/pull/1220))

## [6.7.0] - 2022-01-04
### Added
- add core matrix algorithm
Expand Down Expand Up @@ -539,7 +543,8 @@ are attached to roads. ([Issue #162](https://github.com/GIScience/openrouteservi
- Fix bug in RPHAST when location lies on a oneway road.
- Consider turn restrictions if optimized=false is passed.

[unreleased]: https://github.com/GIScience/openrouteservice/compare/v6.7.0...HEAD
[unreleased]: https://github.com/GIScience/openrouteservice/compare/v6.7.1...HEAD
[6.7.1]: https://github.com/GIScience/openrouteservice/compare/v6.7.0...v6.7.1
[6.7.0]: https://github.com/GIScience/openrouteservice/compare/v6.6.4...v6.7.0
[6.6.4]: https://github.com/GIScience/openrouteservice/compare/v6.6.3...v6.6.4
[6.6.3]: https://github.com/GIScience/openrouteservice/compare/v6.6.2...v6.6.3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ public void testSmoothingFactor() {
.then()
.body("any { it.key == 'type' }", is(true))
.body("any { it.key == 'features' }", is(true))
.body("features[0].geometry.coordinates[0].size", is(75))
.body("features[0].geometry.coordinates[0].size()", is(75))
.statusCode(200);

body.put("smoothing", "100");
Expand All @@ -393,7 +393,7 @@ public void testSmoothingFactor() {
.then()
.body("any { it.key == 'type' }", is(true))
.body("any { it.key == 'features' }", is(true))
.body("features[0].geometry.coordinates[0].size", is(89))
.body("features[0].geometry.coordinates[0].size()", is(89))
.statusCode(200);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2681,8 +2681,8 @@ public void testSkipSegments() {
.body("routes[0].containsKey('warnings')", is(true))
.body("routes[0].warnings[0].containsKey('code')", is(true))
.body("routes[0].warnings[0].code", is(3))
.body("routes[0].segments.size", is(4))
.body("routes[0].way_points.size", is(5))
.body("routes[0].segments.size()", is(4))
.body("routes[0].way_points.size()", is(5))
.body("routes[0].bbox[0]", is(0.0f))
.body("routes[0].bbox[1]", is(0.0f))
.statusCode(200);
Expand Down
2 changes: 1 addition & 1 deletion openrouteservice/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.heigit.ors</groupId>
<artifactId>openrouteservice</artifactId>
<version>6.7.0</version>
<version>6.7.1</version>
<packaging>war</packaging>
<name>openrouteservice</name>
<url>openrouteservice.org</url>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,7 @@ public GHResponse computeRoute(double lat0, double lon0, double lat1, double lon
int weightingMethod = searchParams.getWeightingMethod();
RouteSearchContext searchCntx = createSearchContext(searchParams);

int flexibleMode = searchParams.getFlexibleMode() ? KEY_FLEX_PREPROCESSED : KEY_FLEX_STATIC;
int flexibleMode = searchParams.getFlexibleMode() || config.isEnforceTurnCosts() ? KEY_FLEX_PREPROCESSED : KEY_FLEX_STATIC;
boolean optimized = searchParams.getOptimized();

GHRequest req;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ public class RouteProfileConfiguration {

private int trafficExpirationMin = 15;

private boolean enforceTurnCosts = false;

public RouteProfileConfiguration() {
extStorages = new HashMap<>();
graphBuilders = new HashMap<>();
Expand All @@ -83,6 +85,8 @@ public RouteProfileConfiguration(RouteProfileConfiguration rpc) {

encoderFlagsSize = rpc.encoderFlagsSize;
encoderOptions = rpc.encoderOptions;
enforceTurnCosts = hasEnforceTurnCosts(rpc.encoderOptions);

isochronePreparationOpts = rpc.isochronePreparationOpts;
preparationOpts = rpc.preparationOpts;
executionOpts = rpc.executionOpts;
Expand Down Expand Up @@ -212,6 +216,15 @@ public Double getMaximumDistanceDynamicWeights()
{
return maximumDistanceDynamicWeights;
}
private static boolean hasEnforceTurnCosts(String encoderOptions) {
for (String option : encoderOptions.split("\\|")) {
String[] keyValuePair = option.split("=");
if (keyValuePair.length > 0 && keyValuePair[0].equals("force_turn_costs")) {
return keyValuePair[1].equals("true");
}
}
return false;
}

public void setMaximumDistanceAvoidAreas(Double value)
{
Expand Down Expand Up @@ -261,6 +274,7 @@ public Integer getEncoderFlagsSize()
public void setEncoderOptions(String value)
{
encoderOptions = value;
enforceTurnCosts = hasEnforceTurnCosts(value);
}

public String getEncoderOptions()
Expand Down Expand Up @@ -403,6 +417,10 @@ public double getMaximumSpeedLowerBound(){
return maximumSpeedLowerBound;
}

public boolean isEnforceTurnCosts() {
return enforceTurnCosts;
}

public void setTrafficExpirationMin(int trafficExpirationMin) {
this.trafficExpirationMin = trafficExpirationMin;
}
Expand Down

0 comments on commit 5938659

Please sign in to comment.