Refactor field names

This commit is contained in:
Victor Shcherb 2020-07-10 19:54:50 +02:00
parent 06af1bf71b
commit 2b23c7e8ca
6 changed files with 143 additions and 97 deletions

View file

@ -68,7 +68,6 @@ public class BinaryRoutePlanner {
FinalRouteSegment searchRouteInternal(final RoutingContext ctx, RouteSegmentPoint start, RouteSegmentPoint end, FinalRouteSegment searchRouteInternal(final RoutingContext ctx, RouteSegmentPoint start, RouteSegmentPoint end,
RouteSegment recalculationEnd ) throws InterruptedException, IOException { RouteSegment recalculationEnd ) throws InterruptedException, IOException {
// measure time // measure time
ctx.timeToLoad = 0;
ctx.memoryOverhead = 1000; ctx.memoryOverhead = 1000;
// Initializing priority queue to visit way segments // Initializing priority queue to visit way segments
@ -120,7 +119,9 @@ public class BinaryRoutePlanner {
if (ctx.memoryOverhead > ctx.config.memoryLimitation * 0.95) { if (ctx.memoryOverhead > ctx.config.memoryLimitation * 0.95) {
throw new IllegalStateException("There is not enough memory " + ctx.config.memoryLimitation / (1 << 20) + " Mb"); throw new IllegalStateException("There is not enough memory " + ctx.config.memoryLimitation / (1 << 20) + " Mb");
} }
ctx.visitedSegments ++; if (ctx.calculationProgress != null) {
ctx.calculationProgress.visitedSegments++;
}
if (forwardSearch) { if (forwardSearch) {
boolean doNotAddIntersections = onlyBackward; boolean doNotAddIntersections = onlyBackward;
processRouteSegment(ctx, false, graphDirectSegments, visitedDirectSegments, processRouteSegment(ctx, false, graphDirectSegments, visitedDirectSegments,
@ -164,12 +165,14 @@ public class BinaryRoutePlanner {
throw new InterruptedException("Route calculation interrupted"); throw new InterruptedException("Route calculation interrupted");
} }
} }
ctx.visitedSegments += visitedDirectSegments.size() + visitedOppositeSegments.size(); if (ctx.calculationProgress != null) {
ctx.visitedDirectSegments += visitedDirectSegments.size(); ctx.calculationProgress.visitedDirectSegments += visitedDirectSegments.size();
ctx.visitedOppositeSegments += visitedOppositeSegments.size(); ctx.calculationProgress.visitedOppositeSegments += visitedOppositeSegments.size();
ctx.directQueueSize = graphDirectSegments.size(); // Math.max(ctx.directQueueSize, graphDirectSegments.size()); ctx.calculationProgress.directQueueSize = graphDirectSegments.size(); // Math.max(ctx.directQueueSize,
ctx.oppositeQueueSize = graphReverseSegments.size(); // graphDirectSegments.size());
ctx.visitedOppositeSegments += visitedOppositeSegments.size(); ctx.calculationProgress.oppositeQueueSize = graphReverseSegments.size();
ctx.calculationProgress.visitedOppositeSegments += visitedOppositeSegments.size();
}
return finalSegment; return finalSegment;
} }
@ -371,18 +374,21 @@ public class BinaryRoutePlanner {
} }
public static void printDebugMemoryInformation(RoutingContext ctx) { public static void printDebugMemoryInformation(RoutingContext ctx) {
printInfo(String.format("Time. Total: %.2f, to load: %.2f, to load headers: %.2f, to calc dev: %.2f ", if (ctx.calculationProgress != null) {
(System.nanoTime() - ctx.timeToCalculate) / 1e6, ctx.timeToLoad / 1e6, RouteCalculationProgress p = ctx.calculationProgress;
ctx.timeToLoadHeaders / 1e6, ctx.timeNanoToCalcDeviation / 1e6)); printInfo(String.format("Time. Total: %.2f, to load: %.2f, to load headers: %.2f, to calc dev: %.2f ",
// GeneralRouter.TIMER = 0; p.timeToCalculate / 1e6, p.timeToLoad / 1e6, p.timeToLoadHeaders / 1e6,
int maxLoadedTiles = Math.max(ctx.maxLoadedTiles, ctx.getCurrentlyLoadedTiles()); p.timeNanoToCalcDeviation / 1e6));
printInfo("Current loaded tiles : " + ctx.getCurrentlyLoadedTiles() + ", maximum loaded tiles " + maxLoadedTiles); // GeneralRouter.TIMER = 0;
printInfo("Loaded tiles " + ctx.loadedTiles + " (distinct " + ctx.distinctLoadedTiles + "), unloaded tiles " + ctx.unloadedTiles + int maxLoadedTiles = Math.max(p.maxLoadedTiles, ctx.getCurrentlyLoadedTiles());
", loaded more than once same tiles " printInfo("Current loaded tiles : " + ctx.getCurrentlyLoadedTiles() + ", maximum loaded tiles "
+ ctx.loadedPrevUnloadedTiles); + maxLoadedTiles);
printInfo("Visited segments " + ctx.visitedSegments + ", relaxed roads " + ctx.relaxedSegments); printInfo("Loaded tiles " + p.loadedTiles + " (distinct " + p.distinctLoadedTiles + "), unloaded tiles "
printInfo("Priority queues sizes : " + ctx.directQueueSize + "/" + ctx.oppositeQueueSize); + p.unloadedTiles + ", loaded more than once same tiles " + p.loadedPrevUnloadedTiles);
printInfo("Visited interval sizes: " + ctx.visitedDirectSegments + "/" + ctx.visitedOppositeSegments); printInfo("Visited segments: " + ctx.getVisitedSegments() + ", relaxed roads " + p.relaxedSegments);
printInfo("Priority queues sizes : " + p.directQueueSize + "/" + p.oppositeQueueSize);
printInfo("Visited interval sizes: " + p.visitedDirectSegments + "/" + p.visitedOppositeSegments);
}
} }
@ -849,6 +855,7 @@ public class BinaryRoutePlanner {
} }
public static class RouteSegmentPoint extends RouteSegment { public static class RouteSegmentPoint extends RouteSegment {
public RouteSegmentPoint(RouteDataObject road, int segmentStart, double distSquare) { public RouteSegmentPoint(RouteDataObject road, int segmentStart, double distSquare) {
super(road, segmentStart); super(road, segmentStart);
this.distSquare = distSquare; this.distSquare = distSquare;
@ -873,6 +880,11 @@ public class BinaryRoutePlanner {
} }
@Override
public String toString() {
return String.format("%d (%s): %s", segStart, getPreciseLatLon(), road);
}
} }
public static class RouteSegment { public static class RouteSegment {

View file

@ -12,12 +12,29 @@ public class RouteCalculationProgress {
public float totalEstimatedDistance = 0; public float totalEstimatedDistance = 0;
public float routingCalculatedTime = 0; public float routingCalculatedTime = 0;
public int loadedTiles = 0;
public int relaxedSegments = 0;
public int visitedSegments = 0; public int visitedSegments = 0;
public int visitedDirectSegments = 0;
public int visitedOppositeSegments = 0;
public int directQueueSize = 0;
public int oppositeQueueSize = 0;
public int totalIterations = 1; public int totalIterations = 1;
public int iteration = -1; public int iteration = -1;
public long timeNanoToCalcDeviation = 0;
public long timeToLoad = 0;
public long timeToLoadHeaders = 0;
public long timeToFindInitialSegments = 0;
public long timeToCalculate = 0;
public int distinctLoadedTiles = 0;
public int maxLoadedTiles = 0;
public int loadedPrevUnloadedTiles = 0;
public int unloadedTiles = 0;
public int loadedTiles = 0;
public boolean isCancelled; public boolean isCancelled;
public boolean requestPrivateAccessRouting; public boolean requestPrivateAccessRouting;

View file

@ -208,9 +208,8 @@ public class RoutePlannerFrontEnd {
useSmartRouteRecalculation = use; useSmartRouteRecalculation = use;
} }
// TODO native matches less roads
public GpxRouteApproximation searchGpxRoute(GpxRouteApproximation gctx, List<LatLon> points) throws IOException, InterruptedException { public GpxRouteApproximation searchGpxRoute(GpxRouteApproximation gctx, List<LatLon> points) throws IOException, InterruptedException {
gctx.ctx.timeToCalculate = System.nanoTime(); long timeToCalculate = System.nanoTime();
if (gctx.ctx.calculationProgress == null) { if (gctx.ctx.calculationProgress == null) {
gctx.ctx.calculationProgress = new RouteCalculationProgress(); gctx.ctx.calculationProgress = new RouteCalculationProgress();
} }
@ -275,6 +274,10 @@ public class RoutePlannerFrontEnd {
} }
start = next; start = next;
} }
if(gctx.ctx.calculationProgress != null) {
// TODO
gctx.ctx.calculationProgress.timeToCalculate = System.nanoTime() - timeToCalculate;
}
BinaryRoutePlanner.printDebugMemoryInformation(gctx.ctx); BinaryRoutePlanner.printDebugMemoryInformation(gctx.ctx);
calculateGpxRoute(gctx, gpxPoints); calculateGpxRoute(gctx, gpxPoints);
if (!gctx.res.isEmpty()) { if (!gctx.res.isEmpty()) {
@ -529,7 +532,9 @@ public class RoutePlannerFrontEnd {
// start point could shift to +-1 due to direction // start point could shift to +-1 due to direction
res.get(0).setStartPointIndex(start.pnt.getSegmentStart()); res.get(0).setStartPointIndex(start.pnt.getSegmentStart());
} else { } else {
//throw new IllegalStateException("TODO"); // for native routing this is possible when point lies on intersection of 2 lines
// solution here could be to pass to native routing id of the route
// though it should not create any issue
} }
} }
start.routeToTarget = res; start.routeToTarget = res;
@ -590,7 +595,7 @@ public class RoutePlannerFrontEnd {
public List<RouteSegmentResult> searchRoute(final RoutingContext ctx, LatLon start, LatLon end, List<LatLon> intermediates, public List<RouteSegmentResult> searchRoute(final RoutingContext ctx, LatLon start, LatLon end, List<LatLon> intermediates,
PrecalculatedRouteDirection routeDirection) throws IOException, InterruptedException { PrecalculatedRouteDirection routeDirection) throws IOException, InterruptedException {
ctx.timeToCalculate = System.nanoTime(); long timeToCalculate = System.nanoTime();
if (ctx.calculationProgress == null) { if (ctx.calculationProgress == null) {
ctx.calculationProgress = new RouteCalculationProgress(); ctx.calculationProgress = new RouteCalculationProgress();
} }
@ -622,6 +627,7 @@ public class RoutePlannerFrontEnd {
} }
routeDirection = PrecalculatedRouteDirection.build(ls, ctx.config.DEVIATION_RADIUS, ctx.getRouter().getMaxSpeed()); routeDirection = PrecalculatedRouteDirection.build(ls, ctx.config.DEVIATION_RADIUS, ctx.getRouter().getMaxSpeed());
} }
List<RouteSegmentResult> res ;
if (intermediatesEmpty && ctx.nativeLib != null) { if (intermediatesEmpty && ctx.nativeLib != null) {
ctx.startX = MapUtils.get31TileNumberX(start.getLongitude()); ctx.startX = MapUtils.get31TileNumberX(start.getLongitude());
ctx.startY = MapUtils.get31TileNumberY(start.getLatitude()); ctx.startY = MapUtils.get31TileNumberY(start.getLatitude());
@ -635,31 +641,33 @@ public class RoutePlannerFrontEnd {
ctx.precalculatedRouteDirection = routeDirection.adopt(ctx); ctx.precalculatedRouteDirection = routeDirection.adopt(ctx);
} }
ctx.calculationProgress.nextIteration(); ctx.calculationProgress.nextIteration();
List<RouteSegmentResult> res = runNativeRouting(ctx, recalculationEnd); res = runNativeRouting(ctx, recalculationEnd);
if (res != null) {
new RouteResultPreparation().printResults(ctx, start, end, res);
}
makeStartEndPointsPrecise(res, start, end, intermediates); makeStartEndPointsPrecise(res, start, end, intermediates);
return res; } else {
} int indexNotFound = 0;
int indexNotFound = 0; List<RouteSegmentPoint> points = new ArrayList<RouteSegmentPoint>();
List<RouteSegmentPoint> points = new ArrayList<RouteSegmentPoint>(); if (!addSegment(start, ctx, indexNotFound++, points, ctx.startTransportStop)) {
if (!addSegment(start, ctx, indexNotFound++, points, ctx.startTransportStop)) { return null;
return null; }
} if (intermediates != null) {
if (intermediates != null) { for (LatLon l : intermediates) {
for (LatLon l : intermediates) { if (!addSegment(l, ctx, indexNotFound++, points, false)) {
if (!addSegment(l, ctx, indexNotFound++, points, false)) { System.out.println(points.get(points.size() - 1).getRoad().toString());
System.out.println(points.get(points.size() - 1).getRoad().toString()); return null;
return null; }
} }
} }
if (!addSegment(end, ctx, indexNotFound++, points, ctx.targetTransportStop)) {
return null;
}
ctx.calculationProgress.nextIteration();
res = searchRouteImpl(ctx, points, routeDirection);
} }
if (!addSegment(end, ctx, indexNotFound++, points, ctx.targetTransportStop)) { if (ctx.calculationProgress != null) {
return null; // TODO
ctx.calculationProgress.timeToCalculate = System.nanoTime() - timeToCalculate;
} }
ctx.calculationProgress.nextIteration(); BinaryRoutePlanner.printDebugMemoryInformation(ctx);
List<RouteSegmentResult> res = searchRouteImpl(ctx, points, routeDirection);
if (res != null) { if (res != null) {
new RouteResultPreparation().printResults(ctx, start, end, res); new RouteResultPreparation().printResults(ctx, start, end, res);
} }
@ -839,11 +847,11 @@ public class RoutePlannerFrontEnd {
ctx.checkOldRoutingFiles(ctx.startX, ctx.startY); ctx.checkOldRoutingFiles(ctx.startX, ctx.startY);
ctx.checkOldRoutingFiles(ctx.targetX, ctx.targetY); ctx.checkOldRoutingFiles(ctx.targetX, ctx.targetY);
long time = System.currentTimeMillis(); // long time = System.currentTimeMillis();
RouteSegmentResult[] res = ctx.nativeLib.runNativeRouting(ctx.startX, ctx.startY, ctx.targetX, ctx.targetY, RouteSegmentResult[] res = ctx.nativeLib.runNativeRouting(ctx.startX, ctx.startY, ctx.targetX, ctx.targetY,
ctx.config, regions, ctx.calculationProgress, ctx.precalculatedRouteDirection, ctx.calculationMode == RouteCalculationMode.BASE, ctx.config, regions, ctx.calculationProgress, ctx.precalculatedRouteDirection, ctx.calculationMode == RouteCalculationMode.BASE,
ctx.publicTransport, ctx.startTransportStop, ctx.targetTransportStop); ctx.publicTransport, ctx.startTransportStop, ctx.targetTransportStop);
log.info("Native routing took " + (System.currentTimeMillis() - time) / 1000f + " seconds"); // log.info("Native routing took " + (System.currentTimeMillis() - time) / 1000f + " seconds");
ArrayList<RouteSegmentResult> result = new ArrayList<RouteSegmentResult>(Arrays.asList(res)); ArrayList<RouteSegmentResult> result = new ArrayList<RouteSegmentResult>(Arrays.asList(res));
if (recalculationEnd != null) { if (recalculationEnd != null) {
log.info("Native routing use precalculated route"); log.info("Native routing use precalculated route");
@ -855,8 +863,6 @@ public class RoutePlannerFrontEnd {
} }
} }
ctx.routingTime = ctx.calculationProgress.routingCalculatedTime; ctx.routingTime = ctx.calculationProgress.routingCalculatedTime;
ctx.visitedSegments = ctx.calculationProgress.visitedSegments;
ctx.loadedTiles = ctx.calculationProgress.loadedTiles;
return new RouteResultPreparation().prepareResult(ctx, result, recalculationEnd != null); return new RouteResultPreparation().prepareResult(ctx, result, recalculationEnd != null);
} }
@ -870,7 +876,6 @@ public class RoutePlannerFrontEnd {
} }
pringGC(ctx, true); pringGC(ctx, true);
List<RouteSegmentResult> res = searchRouteInternalPrepare(ctx, points.get(0), points.get(1), routeDirection); List<RouteSegmentResult> res = searchRouteInternalPrepare(ctx, points.get(0), points.get(1), routeDirection);
BinaryRoutePlanner.printDebugMemoryInformation(ctx);
pringGC(ctx, false); pringGC(ctx, false);
makeStartEndPointsPrecise(res, points.get(0).getPreciseLatLon(), points.get(1).getPreciseLatLon(), null); makeStartEndPointsPrecise(res, points.get(0).getPreciseLatLon(), points.get(1).getPreciseLatLon(), null);
return res; return res;
@ -917,14 +922,11 @@ public class RoutePlannerFrontEnd {
List<RouteSegmentResult> res = searchRouteInternalPrepare(local, points.get(i), points.get(i + 1), routeDirection); List<RouteSegmentResult> res = searchRouteInternalPrepare(local, points.get(i), points.get(i + 1), routeDirection);
makeStartEndPointsPrecise(res, points.get(i).getPreciseLatLon(), points.get(i + 1).getPreciseLatLon(), null); makeStartEndPointsPrecise(res, points.get(i).getPreciseLatLon(), points.get(i + 1).getPreciseLatLon(), null);
results.addAll(res); results.addAll(res);
ctx.distinctLoadedTiles += local.distinctLoadedTiles; if(ctx.calculationProgress != null) {
ctx.loadedTiles += local.loadedTiles; ctx.calculationProgress.distinctLoadedTiles += local.calculationProgress.distinctLoadedTiles;
ctx.visitedSegments += local.visitedSegments; ctx.calculationProgress.loadedTiles += local.calculationProgress.loadedTiles;
ctx.loadedPrevUnloadedTiles += local.loadedPrevUnloadedTiles; ctx.calculationProgress.loadedPrevUnloadedTiles += local.calculationProgress.loadedPrevUnloadedTiles;
ctx.timeToCalculate += local.timeToCalculate; }
ctx.timeToLoad += local.timeToLoad;
ctx.timeToLoadHeaders += local.timeToLoadHeaders;
ctx.relaxedSegments += local.relaxedSegments;
ctx.routingTime += local.routingTime; ctx.routingTime += local.routingTime;
// local.unloadAllData(ctx); // local.unloadAllData(ctx);

View file

@ -394,7 +394,7 @@ public class RouteResultPreparation {
private List<RouteSegmentResult> convertFinalSegmentToResults(RoutingContext ctx, FinalRouteSegment finalSegment) { private List<RouteSegmentResult> convertFinalSegmentToResults(RoutingContext ctx, FinalRouteSegment finalSegment) {
List<RouteSegmentResult> result = new ArrayList<RouteSegmentResult>(); List<RouteSegmentResult> result = new ArrayList<RouteSegmentResult>();
if (finalSegment != null) { if (finalSegment != null) {
ctx.routingTime = finalSegment.distanceFromStart; ctx.routingTime += finalSegment.distanceFromStart;
println("Routing calculated time distance " + finalSegment.distanceFromStart); println("Routing calculated time distance " + finalSegment.distanceFromStart);
// Get results from opposite direction roads // Get results from opposite direction roads
RouteSegment segment = finalSegment.reverseWaySearch ? finalSegment : RouteSegment segment = finalSegment.reverseWaySearch ? finalSegment :
@ -496,8 +496,9 @@ public class RouteResultPreparation {
String msg = String.format("<test regions=\"\" description=\"\" best_percent=\"\" vehicle=\"%s\" \n" String msg = String.format("<test regions=\"\" description=\"\" best_percent=\"\" vehicle=\"%s\" \n"
+ " start_lat=\"%.5f\" start_lon=\"%.5f\" target_lat=\"%.5f\" target_lon=\"%.5f\" " + " start_lat=\"%.5f\" start_lon=\"%.5f\" target_lat=\"%.5f\" target_lon=\"%.5f\" "
+ " routing_time=\"%.2f\" loadedTiles=\"%d\" visitedSegments=\"%d\" complete_distance=\"%.2f\" complete_time=\"%.2f\" >", + " routing_time=\"%.2f\" loadedTiles=\"%d\" visitedSegments=\"%d\" complete_distance=\"%.2f\" complete_time=\"%.2f\" >",
ctx.config.routerName, startLat, startLon, endLat, endLon, ctx.routingTime, ctx.loadedTiles, ctx.config.routerName, startLat, startLon, endLat, endLon, ctx.routingTime,
ctx.visitedSegments, completeDistance, completeTime); ctx.getLoadedTiles(),
ctx.getVisitedSegments(), completeDistance, completeTime);
// String msg = MessageFormat.format("<test regions=\"\" description=\"\" best_percent=\"\" vehicle=\"{4}\" \n" // String msg = MessageFormat.format("<test regions=\"\" description=\"\" best_percent=\"\" vehicle=\"{4}\" \n"
// + " start_lat=\"{0}\" start_lon=\"{1}\" target_lat=\"{2}\" target_lon=\"{3}\" {5} >", // + " start_lat=\"{0}\" start_lon=\"{1}\" target_lat=\"{2}\" target_lon=\"{3}\" {5} >",
// startLat + "", startLon + "", endLat + "", endLon + "", ctx.config.routerName, // startLat + "", startLon + "", endLat + "", endLon + "", ctx.config.routerName,

View file

@ -41,8 +41,6 @@ public class RoutingContext {
private final static Log log = PlatformUtil.getLog(RoutingContext.class); private final static Log log = PlatformUtil.getLog(RoutingContext.class);
// Final context variables // Final context variables
public final RoutingConfiguration config; public final RoutingConfiguration config;
public final RouteCalculationMode calculationMode; public final RouteCalculationMode calculationMode;
@ -82,26 +80,8 @@ public class RoutingContext {
public TileStatistics global = new TileStatistics(); public TileStatistics global = new TileStatistics();
// updated by route planner in bytes // updated by route planner in bytes
public int memoryOverhead = 0; public int memoryOverhead = 0;
long timeNanoToCalcDeviation = 0;
long timeToLoad = 0;
long timeToLoadHeaders = 0;
long timeToFindInitialSegments = 0;
public long timeToCalculate = 0;
int distinctLoadedTiles = 0;
int maxLoadedTiles = 0;
int loadedPrevUnloadedTiles = 0;
int unloadedTiles = 0;
public float routingTime = 0; public float routingTime = 0;
public int loadedTiles = 0;
public int visitedSegments = 0;
public int relaxedSegments = 0;
public int visitedDirectSegments = 0;
public int visitedOppositeSegments = 0;
public int directQueueSize = 0;
public int oppositeQueueSize = 0;
// callback of processing segments // callback of processing segments
RouteSegmentVisitor visitor = null; RouteSegmentVisitor visitor = null;
@ -224,7 +204,9 @@ public class RoutingContext {
if (tl.isLoaded()) { if (tl.isLoaded()) {
if(except == null || except.searchSubregionTile(tl.subregion) < 0){ if(except == null || except.searchSubregionTile(tl.subregion) < 0){
tl.unload(); tl.unload();
unloadedTiles ++; if(calculationProgress != null) {
calculationProgress.unloadedTiles ++;
}
global.size -= tl.tileStatistics.size; global.size -= tl.tileStatistics.size;
} }
} }
@ -308,27 +290,37 @@ public class RoutingContext {
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException("Loading data exception", e); throw new RuntimeException("Loading data exception", e);
} }
if (calculationProgress != null) {
timeToLoad += (System.nanoTime() - now); calculationProgress.timeToLoad += (System.nanoTime() - now);
}
} else { } else {
long now = System.nanoTime(); long now = System.nanoTime();
NativeRouteSearchResult ns = nativeLib.loadRouteRegion(ts.subregion, loadObjectsInMemory); NativeRouteSearchResult ns = nativeLib.loadRouteRegion(ts.subregion, loadObjectsInMemory);
// System.out.println(ts.subregion.shiftToData + " " + Arrays.toString(ns.objects)); // System.out.println(ts.subregion.shiftToData + " " + Arrays.toString(ns.objects));
ts.setLoadedNative(ns, this); ts.setLoadedNative(ns, this);
timeToLoad += (System.nanoTime() - now); if (calculationProgress != null) {
calculationProgress.timeToLoad += (System.nanoTime() - now);
}
} }
loadedTiles++; if (calculationProgress != null) {
calculationProgress.loadedTiles++;
}
if (wasUnloaded) { if (wasUnloaded) {
if(ucount == 1) { if(ucount == 1) {
loadedPrevUnloadedTiles++; if(calculationProgress != null) {
calculationProgress.loadedPrevUnloadedTiles++;
}
} }
} else { } else {
if(global != null) { if(global != null) {
global.allRoutes += ts.tileStatistics.allRoutes; global.allRoutes += ts.tileStatistics.allRoutes;
global.coordinates += ts.tileStatistics.coordinates; global.coordinates += ts.tileStatistics.coordinates;
} }
distinctLoadedTiles++; if(calculationProgress != null) {
calculationProgress.distinctLoadedTiles++;
}
} }
global.size += ts.tileStatistics.size; global.size += ts.tileStatistics.size;
} }
@ -402,7 +394,9 @@ public class RoutingContext {
} }
collection.add(found); collection.add(found);
} }
timeToLoadHeaders += (System.nanoTime() - now); if (calculationProgress != null) {
calculationProgress.timeToLoadHeaders += (System.nanoTime() - now);
}
} }
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException("Loading data exception", e); throw new RuntimeException("Loading data exception", e);
@ -440,7 +434,9 @@ public class RoutingContext {
excludeDuplications.clear(); excludeDuplications.clear();
} }
} }
timeToFindInitialSegments += (System.nanoTime() - now); if (calculationProgress != null) {
calculationProgress.timeToFindInitialSegments += (System.nanoTime() - now);
}
} }
@SuppressWarnings("unused") @SuppressWarnings("unused")
@ -523,7 +519,9 @@ public class RoutingContext {
loaded++; loaded++;
} }
} }
maxLoadedTiles = Math.max(maxLoadedTiles, getCurrentlyLoadedTiles()); if(calculationProgress != null) {
calculationProgress.maxLoadedTiles = Math.max(calculationProgress.maxLoadedTiles, getCurrentlyLoadedTiles());
}
Collections.sort(list, new Comparator<RoutingSubregionTile>() { Collections.sort(list, new Comparator<RoutingSubregionTile>() {
private int pow(int base, int pw) { private int pow(int base, int pw) {
int r = 1; int r = 1;
@ -545,7 +543,9 @@ public class RoutingContext {
i++; i++;
// System.out.println("Unload " + unload); // System.out.println("Unload " + unload);
unload.unload(); unload.unload();
unloadedTiles ++; if(calculationProgress != null) {
calculationProgress.unloadedTiles ++;
}
global.size -= unload.tileStatistics.size; global.size -= unload.tileStatistics.size;
// tile could be cleaned from routing tiles and deleted from whole list // tile could be cleaned from routing tiles and deleted from whole list
@ -796,6 +796,20 @@ public class RoutingContext {
return map.keySet().toArray(new BinaryMapIndexReader[map.size()]); return map.keySet().toArray(new BinaryMapIndexReader[map.size()]);
} }
public int getVisitedSegments() {
if(calculationProgress != null) {
return calculationProgress.visitedSegments;
}
return 0;
}
public int getLoadedTiles() {
if (calculationProgress != null) {
return calculationProgress.loadedTiles;
}
return 0;
}

View file

@ -236,13 +236,13 @@ public class TestRouting {
throw new IllegalArgumentException(MessageFormat.format("Complete routing time (expected) {0} != {1} (original) : {2}", routing_time, calcRoutingTime, testDescription)); throw new IllegalArgumentException(MessageFormat.format("Complete routing time (expected) {0} != {1} (original) : {2}", routing_time, calcRoutingTime, testDescription));
} }
if (visitedSegments > 0 && !isInOrLess(visitedSegments, ctx.visitedSegments, percent)) { if (visitedSegments > 0 && !isInOrLess(visitedSegments, ctx.getVisitedSegments(), percent)) {
throw new IllegalArgumentException(MessageFormat.format("Visited segments (expected) {0} != {1} (original) : {2}", visitedSegments, throw new IllegalArgumentException(MessageFormat.format("Visited segments (expected) {0} != {1} (original) : {2}", visitedSegments,
ctx.visitedSegments, testDescription)); ctx.getVisitedSegments(), testDescription));
} }
if (loadedTiles > 0 && !isInOrLess(loadedTiles, ctx.loadedTiles, percent)) { if (loadedTiles > 0 && !isInOrLess(loadedTiles, ctx.getLoadedTiles(), percent)) {
throw new IllegalArgumentException(MessageFormat.format("Loaded tiles (expected) {0} != {1} (original) : {2}", loadedTiles, throw new IllegalArgumentException(MessageFormat.format("Loaded tiles (expected) {0} != {1} (original) : {2}", loadedTiles,
ctx.loadedTiles, testDescription)); ctx.getLoadedTiles(), testDescription));
} }
if(TEST_BOTH_DIRECTION){ if(TEST_BOTH_DIRECTION){