Skip to content

Commit

Permalink
fix: only initialize SpeedyALT data once (#222)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebhoerl authored Apr 25, 2024
1 parent 514572a commit 68333f4
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class RoadRouterService {

private final QuadTree<? extends Link> linkIndex;

private final SpeedyALTFactory routerFactory = new SpeedyALTFactory();
private final ConcurrentLinkedQueue<LeastCostPathCalculator> routerPool = new ConcurrentLinkedQueue<>();

RoadRouterService(Network network, QuadTree<? extends Link> linkIndex, WalkParameters walkParameters, int threads) {
Expand All @@ -50,7 +51,7 @@ public class RoadRouterService {
}

private LeastCostPathCalculator createRouterInstance(Network network) {
return new SpeedyALTFactory().createPathCalculator(network, travelDisutility, travelTime);
return routerFactory.createPathCalculator(network, travelDisutility, travelTime);
}

public RoadRouterResponse processRequest(RoadRouterRequest request) {
Expand All @@ -63,7 +64,8 @@ public RoadRouterResponse processRequest(RoadRouterRequest request) {
List<Link> toLinks = new LinkedList<>();

if (request.accessEgressRadius_km != null) {
fromLinks.addAll(linkIndex.getDisk(fromCoord.getX(), fromCoord.getY(), request.accessEgressRadius_km * 1e3));
fromLinks
.addAll(linkIndex.getDisk(fromCoord.getX(), fromCoord.getY(), request.accessEgressRadius_km * 1e3));
toLinks.addAll(linkIndex.getDisk(toCoord.getX(), toCoord.getY(), request.accessEgressRadius_km * 1e3));
}

Expand Down

0 comments on commit 68333f4

Please sign in to comment.