Skip to content

Commit 45fad0a

Browse files
committed
PathMerger builds ResponsePath
1 parent 5620ea0 commit 45fad0a

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

core/src/main/java/com/graphhopper/routing/Router.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,8 @@ protected List<Path> routeAlt(GHRequest request, GHResponse ghRsp, AlgorithmOpti
195195
// each path represents a different alternative and we do the path merging for each of them
196196
PathMerger pathMerger = createPathMerger(request, weighting, queryGraph);
197197
for (Path path : result.paths) {
198-
ResponsePath responsePath = new ResponsePath();
199-
responsePath.setWaypoints(getWaypoints(qResults));
200-
pathMerger.doWork(responsePath, Collections.singletonList(path), encodingManager, translationMap.getWithFallBack(request.getLocale()));
198+
PointList waypoints = getWaypoints(qResults);
199+
ResponsePath responsePath = pathMerger.doWork(waypoints, Collections.singletonList(path), encodingManager, translationMap.getWithFallBack(request.getLocale()));
201200
ghRsp.add(responsePath);
202201
}
203202
ghRsp.getHints().putObject("visited_nodes.sum", result.visitedNodes);
@@ -305,11 +304,8 @@ private PathMerger createPathMerger(GHRequest request, Weighting weighting, Grap
305304
}
306305

307306
private ResponsePath concatenatePaths(GHRequest request, Weighting weighting, QueryGraph queryGraph, List<Path> paths, PointList waypoints) {
308-
ResponsePath responsePath = new ResponsePath();
309-
responsePath.setWaypoints(waypoints);
310307
PathMerger pathMerger = createPathMerger(request, weighting, queryGraph);
311-
pathMerger.doWork(responsePath, paths, encodingManager, translationMap.getWithFallBack(request.getLocale()));
312-
return responsePath;
308+
return pathMerger.doWork(waypoints, paths, encodingManager, translationMap.getWithFallBack(request.getLocale()));
313309
}
314310

315311
private PointList getWaypoints(List<QueryResult> queryResults) {

core/src/main/java/com/graphhopper/routing/util/TestAlgoCollector.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ public TestAlgoCollector assertDistance(EncodingManager encodingManager, AlgoHel
6666
setCalcPoints(true).
6767
setSimplifyResponse(false).
6868
setEnableInstructions(true);
69-
ResponsePath responsePath = new ResponsePath();
70-
pathMerger.doWork(responsePath, altPaths, encodingManager, trMap.getWithFallBack(Locale.US));
69+
ResponsePath responsePath = pathMerger.doWork(new PointList(), altPaths, encodingManager, trMap.getWithFallBack(Locale.US));
7170

7271
if (responsePath.hasErrors()) {
7372
errors.add("response for " + algoEntry + " contains errors. Expected distance: " + oneRun.getDistance()

core/src/main/java/com/graphhopper/util/PathMerger.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ public PathMerger setEnableInstructions(boolean enableInstructions) {
8888
return this;
8989
}
9090

91-
public void doWork(ResponsePath responsePath, List<Path> paths, EncodedValueLookup evLookup, Translation tr) {
92-
// todo: this method should return the/a new response path and not take it as a parameter
91+
public ResponsePath doWork(PointList waypoints, List<Path> paths, EncodedValueLookup evLookup, Translation tr) {
92+
ResponsePath responsePath = new ResponsePath();
9393
int origPoints = 0;
9494
long fullTimeInMillis = 0;
9595
double fullWeight = 0;
@@ -161,11 +161,13 @@ public void doWork(ResponsePath responsePath, List<Path> paths, EncodedValueLook
161161
setPoints(fullPoints).
162162
setRouteWeight(fullWeight).
163163
setDistance(fullDistance).
164-
setTime(fullTimeInMillis);
164+
setTime(fullTimeInMillis).
165+
setWaypoints(waypoints);
165166

166167
if (allFound && simplifyResponse && (calcPoints || enableInstructions)) {
167168
PathSimplification.simplify(responsePath, douglasPeucker, enableInstructions);
168169
}
170+
return responsePath;
169171
}
170172

171173
/**

0 commit comments

Comments
 (0)