diff --git a/optaweb-vehicle-routing-backend/src/main/java/org/optaweb/vehiclerouting/plugin/routing/GraphHopperRouter.java b/optaweb-vehicle-routing-backend/src/main/java/org/optaweb/vehiclerouting/plugin/routing/GraphHopperRouter.java index 0ff0add42..695cae602 100644 --- a/optaweb-vehicle-routing-backend/src/main/java/org/optaweb/vehiclerouting/plugin/routing/GraphHopperRouter.java +++ b/optaweb-vehicle-routing-backend/src/main/java/org/optaweb/vehiclerouting/plugin/routing/GraphHopperRouter.java @@ -33,6 +33,7 @@ import com.graphhopper.GHRequest; import com.graphhopper.GHResponse; +import com.graphhopper.config.Profile; import com.graphhopper.reader.osm.GraphHopperOSM; import com.graphhopper.util.PointList; import com.graphhopper.util.shapes.BBox; @@ -46,11 +47,14 @@ @IfBuildProperty(name = "app.routing.engine", stringValue = "GRAPHHOPPER", enableIfMissing = true) class GraphHopperRouter implements Router, DistanceCalculator, Region { + private static final String CAR_PROFILE = "car"; + private final GraphHopperOSM graphHopper; @Inject GraphHopperRouter(GraphHopperOSM graphHopper) { this.graphHopper = graphHopper; + this.graphHopper.setProfiles(new Profile(CAR_PROFILE)); } @Override @@ -60,6 +64,7 @@ public List getPath(Coordinates from, Coordinates to) { from.longitude().doubleValue(), to.latitude().doubleValue(), to.longitude().doubleValue()); + ghRequest.setProfile(CAR_PROFILE); PointList points = graphHopper.route(ghRequest).getBest().getPoints(); return StreamSupport.stream(points.spliterator(), false) .map(ghPoint3D -> Coordinates.of(ghPoint3D.lat, ghPoint3D.lon)) @@ -73,6 +78,7 @@ public long travelTimeMillis(Coordinates from, Coordinates to) { from.longitude().doubleValue(), to.latitude().doubleValue(), to.longitude().doubleValue()); + ghRequest.setProfile(CAR_PROFILE); GHResponse ghResponse = graphHopper.route(ghRequest); // TODO return wrapper that can hold both the result and error explanation instead of throwing exception if (ghResponse.hasErrors()) { diff --git a/optaweb-vehicle-routing-backend/src/test/java/org/optaweb/vehiclerouting/plugin/routing/GraphHopperRouterTest.java b/optaweb-vehicle-routing-backend/src/test/java/org/optaweb/vehiclerouting/plugin/routing/GraphHopperRouterTest.java index af6c87da7..eaab25e63 100644 --- a/optaweb-vehicle-routing-backend/src/test/java/org/optaweb/vehiclerouting/plugin/routing/GraphHopperRouterTest.java +++ b/optaweb-vehicle-routing-backend/src/test/java/org/optaweb/vehiclerouting/plugin/routing/GraphHopperRouterTest.java @@ -33,7 +33,7 @@ import com.graphhopper.GHRequest; import com.graphhopper.GHResponse; -import com.graphhopper.PathWrapper; +import com.graphhopper.ResponsePath; import com.graphhopper.reader.osm.GraphHopperOSM; import com.graphhopper.storage.GraphHopperStorage; import com.graphhopper.util.PointList; @@ -50,7 +50,7 @@ class GraphHopperRouterTest { @Mock private GHResponse ghResponse; @Mock - private PathWrapper pathWrapper; + private ResponsePath pathWrapper; @Mock private GraphHopperStorage graphHopperStorage; diff --git a/pom.xml b/pom.xml index 304e7213e..99f5f87ee 100644 --- a/pom.xml +++ b/pom.xml @@ -43,7 +43,7 @@ - 0.13.0-pre13 + 1.0 1.27 1.11.3 v12.16.2