Skip to content

Commit 4546904

Browse files
committed
Add creator method for LMApproximator
1 parent 41b0c28 commit 4546904

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

core/src/main/java/com/graphhopper/routing/lm/LMApproximator.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ public class LMApproximator implements WeightApproximator {
4949
private final WeightApproximator fallBackApproximation;
5050
private boolean fallback = false;
5151

52+
public static LMApproximator forLandmarks(Graph g, LandmarkStorage lms, int activeLM) {
53+
return new LMApproximator(g, lms.getWeighting(), lms.getBaseNodes(), lms, activeLM, lms.getFactor(), false);
54+
}
55+
5256
public LMApproximator(Graph graph, Weighting weighting, int maxBaseNodes, LandmarkStorage lms, int activeCount,
5357
double factor, boolean reverse) {
5458
this.reverse = reverse;

core/src/main/java/com/graphhopper/routing/lm/LMRoutingAlgorithmFactory.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,10 @@
3030

3131
public class LMRoutingAlgorithmFactory implements RoutingAlgorithmFactory {
3232
private final LandmarkStorage lms;
33-
private final Weighting prepareWeighting;
34-
private final int numBaseNodes;
3533
private int defaultActiveLandmarks;
3634

3735
public LMRoutingAlgorithmFactory(LandmarkStorage lms) {
3836
this.lms = lms;
39-
this.prepareWeighting = lms.getWeighting();
40-
this.numBaseNodes = lms.getBaseNodes();
4137
this.defaultActiveLandmarks = Math.max(1, Math.min(lms.getLandmarkCount() / 2, 12));
4238
}
4339

@@ -85,7 +81,6 @@ public RoutingAlgorithm createAlgo(Graph g, AlgorithmOptions opts) {
8581
}
8682

8783
private LMApproximator getApproximator(Graph g, int activeLM, double epsilon) {
88-
return new LMApproximator(g, prepareWeighting, numBaseNodes, lms, activeLM, lms.getFactor(), false).
89-
setEpsilon(epsilon);
84+
return LMApproximator.forLandmarks(g, lms, activeLM).setEpsilon(epsilon);
9085
}
9186
}

0 commit comments

Comments
 (0)