Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade Graphhopper to match protobuf #1

Merged
merged 1 commit into from
May 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -60,6 +64,7 @@ public List<Coordinates> 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))
Expand All @@ -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()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -50,7 +50,7 @@ class GraphHopperRouterTest {
@Mock
private GHResponse ghResponse;
@Mock
private PathWrapper pathWrapper;
private ResponsePath pathWrapper;
@Mock
private GraphHopperStorage graphHopperStorage;

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
</modules>

<properties>
<version.com.graphhopper>0.13.0-pre13</version.com.graphhopper>
<version.com.graphhopper>1.0</version.com.graphhopper>
<version.com.neovisionaries>1.27</version.com.neovisionaries>
<version.frontend-maven-plugin>1.11.3</version.frontend-maven-plugin>
<version.node>v12.16.2</version.node>
Expand Down