Skip to content

Commit 042bacb

Browse files
committed
Explicitly disable turn costs for /isochrone so there is no error if the encoder supports turn costs
1 parent 04d6a44 commit 042bacb

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

web-bundle/src/main/java/com/graphhopper/resources/IsochroneResource.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ public Response doGet(
7676
RouteResource.initHints(hintsMap, uriInfo.getQueryParameters());
7777
hintsMap.putObject(Parameters.CH.DISABLE, true);
7878
hintsMap.putObject(Parameters.Landmark.DISABLE, true);
79+
// make sure to explicitly disable turn costs when resolving the profile, otherwise it might be true depending
80+
// on the encoder
81+
hintsMap.putObject(Parameters.Routing.EDGE_BASED, false);
7982
ProfileConfig profile = graphHopper.resolveProfile(hintsMap);
8083
if (profile.isTurnCosts()) {
8184
throw new IllegalArgumentException("Isochrone calculation does not support turn costs yet");

web-bundle/src/main/java/com/graphhopper/resources/SPTResource.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ public Response doGet(
6464
RouteResource.initHints(hintsMap, uriInfo.getQueryParameters());
6565
hintsMap.putObject(Parameters.CH.DISABLE, true);
6666
hintsMap.putObject(Parameters.Landmark.DISABLE, true);
67+
// make sure to explicitly disable turn costs when resolving the profile, otherwise it might be true depending
68+
// on the encoder
69+
hintsMap.putObject(Parameters.Routing.EDGE_BASED, false);
6770
ProfileConfig profile = graphHopper.resolveProfile(hintsMap);
6871
if (profile.isTurnCosts()) {
6972
throw new IllegalArgumentException("SPT calculation does not support turn costs yet");

web/src/test/java/com/graphhopper/http/resources/IsochroneResourceTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import com.fasterxml.jackson.databind.JsonNode;
2222
import com.graphhopper.http.GraphHopperApplication;
2323
import com.graphhopper.http.util.GraphHopperServerTestConfiguration;
24-
import static com.graphhopper.http.util.TestUtils.clientTarget;
2524
import com.graphhopper.json.geo.JsonFeatureCollection;
2625
import com.graphhopper.util.Helper;
2726
import io.dropwizard.testing.junit.DropwizardAppRule;
@@ -35,6 +34,7 @@
3534
import javax.ws.rs.core.Response;
3635
import java.io.File;
3736

37+
import static com.graphhopper.http.util.TestUtils.clientTarget;
3838
import static com.graphhopper.util.Parameters.Routing.BLOCK_AREA;
3939
import static junit.framework.TestCase.assertFalse;
4040
import static junit.framework.TestCase.assertTrue;
@@ -47,7 +47,8 @@ public class IsochroneResourceTest {
4747

4848
static {
4949
config.getGraphHopperConfiguration().
50-
putObject("graph.flag_encoders", "car").
50+
// isochrone does not support turn costs yet, but use it anyway to make sure this is handled correctly
51+
putObject("graph.flag_encoders", "car|turn_costs=true").
5152
putObject("datareader.file", "../core/files/andorra.osm.pbf").
5253
putObject("graph.location", DIR);
5354
}

0 commit comments

Comments
 (0)