Fix #5175
This commit is contained in:
parent
26c4bd276b
commit
bd81e430b9
3 changed files with 25 additions and 47 deletions
|
@ -11,6 +11,7 @@ import java.util.PriorityQueue;
|
|||
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.binary.RouteDataObject;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.osm.MapRenderingTypes;
|
||||
import net.osmand.util.MapUtils;
|
||||
|
||||
|
@ -859,6 +860,12 @@ public class BinaryRoutePlanner {
|
|||
public int preciseX;
|
||||
public int preciseY;
|
||||
public List<RouteSegmentPoint> others;
|
||||
|
||||
public LatLon getPreciseLatLon() {
|
||||
return new LatLon(MapUtils.get31LatitudeY(preciseY), MapUtils.get31LongitudeX(preciseX));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class RouteSegment {
|
||||
|
|
|
@ -243,9 +243,7 @@ public class RoutePlannerFrontEnd {
|
|||
return null;
|
||||
}
|
||||
ctx.calculationProgress.nextIteration();
|
||||
List<RouteSegmentResult> res = searchRoute(ctx, points, routeDirection);
|
||||
// make start and end more precise
|
||||
makeStartEndPointsPrecise(res, start, end, intermediates);
|
||||
List<RouteSegmentResult> res = searchRouteImpl(ctx, points, routeDirection);
|
||||
if (res != null) {
|
||||
new RouteResultPreparation().printResults(ctx, start, end, res);
|
||||
}
|
||||
|
@ -256,33 +254,6 @@ public class RoutePlannerFrontEnd {
|
|||
if (res.size() > 0) {
|
||||
updateResult(res.get(0), start, true);
|
||||
updateResult(res.get(res.size() - 1), end, false);
|
||||
if (intermediates != null) {
|
||||
int k = 1;
|
||||
for (int i = 0; i < intermediates.size(); i++) {
|
||||
LatLon ll = intermediates.get(i);
|
||||
int px = MapUtils.get31TileNumberX(ll.getLongitude());
|
||||
int py = MapUtils.get31TileNumberY(ll.getLatitude());
|
||||
for (; k < res.size(); k++) {
|
||||
double currentsDist = projectDistance(res, k, px, py);
|
||||
if (currentsDist < 500 * 500) {
|
||||
for (int k1 = k + 1; k1 < res.size(); k1++) {
|
||||
double c2 = projectDistance(res, k1, px, py);
|
||||
if (c2 < currentsDist) {
|
||||
k = k1;
|
||||
currentsDist = c2;
|
||||
} else if (k1 - k > 15) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
updateResult(res.get(k), ll, false);
|
||||
if (k < res.size() - 1) {
|
||||
updateResult(res.get(k + 1), ll, true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -474,13 +445,18 @@ public class RoutePlannerFrontEnd {
|
|||
}
|
||||
|
||||
|
||||
private List<RouteSegmentResult> searchRoute(final RoutingContext ctx, List<RouteSegmentPoint> points, PrecalculatedRouteDirection routeDirection)
|
||||
private List<RouteSegmentResult> searchRouteImpl(final RoutingContext ctx, List<RouteSegmentPoint> points, PrecalculatedRouteDirection routeDirection)
|
||||
throws IOException, InterruptedException {
|
||||
if (points.size() <= 2) {
|
||||
// simple case 2 points only
|
||||
if (!useSmartRouteRecalculation) {
|
||||
ctx.previouslyCalculatedRoute = null;
|
||||
}
|
||||
return searchRoute(ctx, points.get(0), points.get(1), routeDirection);
|
||||
pringGC(ctx, true);
|
||||
List<RouteSegmentResult> res = searchRouteInternalPrepare(ctx, points.get(0), points.get(1), routeDirection);
|
||||
pringGC(ctx, false);
|
||||
makeStartEndPointsPrecise(res, points.get(0).getPreciseLatLon(), points.get(1).getPreciseLatLon(), null);
|
||||
return res;
|
||||
}
|
||||
|
||||
ArrayList<RouteSegmentResult> firstPartRecalculatedRoute = null;
|
||||
|
@ -522,7 +498,7 @@ public class RoutePlannerFrontEnd {
|
|||
local.visitor = ctx.visitor;
|
||||
local.calculationProgress = ctx.calculationProgress;
|
||||
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);
|
||||
results.addAll(res);
|
||||
ctx.distinctLoadedTiles += local.distinctLoadedTiles;
|
||||
ctx.loadedTiles += local.loadedTiles;
|
||||
|
@ -545,27 +521,22 @@ public class RoutePlannerFrontEnd {
|
|||
|
||||
}
|
||||
|
||||
@SuppressWarnings("static-access")
|
||||
private List<RouteSegmentResult> searchRoute(final RoutingContext ctx, RouteSegmentPoint start, RouteSegmentPoint end,
|
||||
PrecalculatedRouteDirection routeDirection) throws IOException, InterruptedException {
|
||||
if (ctx.SHOW_GC_SIZE) {
|
||||
long h1 = ctx.runGCUsedMemory();
|
||||
private void pringGC(final RoutingContext ctx, boolean before) {
|
||||
if (RoutingContext.SHOW_GC_SIZE && before) {
|
||||
long h1 = RoutingContext.runGCUsedMemory();
|
||||
float mb = (1 << 20);
|
||||
log.warn("Used before routing " + h1 / mb + " actual");
|
||||
}
|
||||
List<RouteSegmentResult> result = searchRouteInternalPrepare(ctx, start, end, routeDirection);
|
||||
if (RoutingContext.SHOW_GC_SIZE) {
|
||||
} else if (RoutingContext.SHOW_GC_SIZE && !before) {
|
||||
int sz = ctx.global.size;
|
||||
log.warn("Subregion size " + ctx.subregionTiles.size() + " " + " tiles " + ctx.indexedSubregions.size());
|
||||
ctx.runGCUsedMemory();
|
||||
long h1 = ctx.runGCUsedMemory();
|
||||
RoutingContext.runGCUsedMemory();
|
||||
long h1 = RoutingContext.runGCUsedMemory();
|
||||
ctx.unloadAllData();
|
||||
ctx.runGCUsedMemory();
|
||||
long h2 = ctx.runGCUsedMemory();
|
||||
RoutingContext.runGCUsedMemory();
|
||||
long h2 = RoutingContext.runGCUsedMemory();
|
||||
float mb = (1 << 20);
|
||||
log.warn("Unload context : estimated " + sz / mb + " ?= " + (h1 - h2) / mb + " actual");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ import net.osmand.router.RoutePlannerFrontEnd.RouteCalculationMode;
|
|||
|
||||
public class RoutingContext {
|
||||
|
||||
public static final boolean SHOW_GC_SIZE = false;
|
||||
public static boolean SHOW_GC_SIZE = false;
|
||||
|
||||
|
||||
private final static Log log = PlatformUtil.getLog(RoutingContext.class);
|
||||
|
|
Loading…
Reference in a new issue