New change for fast route recalculation
This commit is contained in:
parent
a6342996e3
commit
0055c3edd0
9 changed files with 123 additions and 24 deletions
|
@ -4,6 +4,7 @@ import gnu.trove.map.hash.TLongObjectHashMap;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -65,12 +66,15 @@ public class BinaryRoutePlanner {
|
||||||
* return list of segments
|
* return list of segments
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
FinalRouteSegment searchRouteInternal(final RoutingContext ctx, RouteSegmentPoint start, RouteSegmentPoint end) throws InterruptedException, IOException {
|
FinalRouteSegment searchRouteInternal(final RoutingContext ctx, RouteSegmentPoint start, RouteSegmentPoint end,
|
||||||
|
RouteSegment recalculationEnd ) throws InterruptedException, IOException {
|
||||||
// measure time
|
// measure time
|
||||||
ctx.timeToLoad = 0;
|
ctx.timeToLoad = 0;
|
||||||
ctx.visitedSegments = 0;
|
ctx.visitedSegments = 0;
|
||||||
ctx.memoryOverhead = 1000;
|
ctx.memoryOverhead = 1000;
|
||||||
ctx.timeToCalculate = System.nanoTime();
|
ctx.timeToCalculate = System.nanoTime();
|
||||||
|
|
||||||
|
|
||||||
// Initializing priority queue to visit way segments
|
// Initializing priority queue to visit way segments
|
||||||
Comparator<RouteSegment> nonHeuristicSegmentsComparator = new NonHeuristicSegmentsComparator();
|
Comparator<RouteSegment> nonHeuristicSegmentsComparator = new NonHeuristicSegmentsComparator();
|
||||||
PriorityQueue<RouteSegment> graphDirectSegments = new PriorityQueue<RouteSegment>(50, new SegmentsComparator(ctx));
|
PriorityQueue<RouteSegment> graphDirectSegments = new PriorityQueue<RouteSegment>(50, new SegmentsComparator(ctx));
|
||||||
|
@ -80,8 +84,7 @@ public class BinaryRoutePlanner {
|
||||||
TLongObjectHashMap<RouteSegment> visitedDirectSegments = new TLongObjectHashMap<RouteSegment>();
|
TLongObjectHashMap<RouteSegment> visitedDirectSegments = new TLongObjectHashMap<RouteSegment>();
|
||||||
TLongObjectHashMap<RouteSegment> visitedOppositeSegments = new TLongObjectHashMap<RouteSegment>();
|
TLongObjectHashMap<RouteSegment> visitedOppositeSegments = new TLongObjectHashMap<RouteSegment>();
|
||||||
|
|
||||||
|
initQueuesWithStartEnd(ctx, start, end, recalculationEnd, graphDirectSegments, graphReverseSegments);
|
||||||
initQueuesWithStartEnd(ctx, start, end, graphDirectSegments, graphReverseSegments);
|
|
||||||
|
|
||||||
// Extract & analyze segment with min(f(x)) from queue while final segment is not found
|
// Extract & analyze segment with min(f(x)) from queue while final segment is not found
|
||||||
boolean forwardSearch = true;
|
boolean forwardSearch = true;
|
||||||
|
@ -90,7 +93,7 @@ public class BinaryRoutePlanner {
|
||||||
|
|
||||||
FinalRouteSegment finalSegment = null;
|
FinalRouteSegment finalSegment = null;
|
||||||
boolean onlyBackward = ctx.getPlanRoadDirection() < 0;
|
boolean onlyBackward = ctx.getPlanRoadDirection() < 0;
|
||||||
boolean onlyForward = ctx.getPlanRoadDirection() > 0;
|
boolean onlyForward = ctx.getPlanRoadDirection() > 0 ;
|
||||||
while (!graphSegments.isEmpty()) {
|
while (!graphSegments.isEmpty()) {
|
||||||
RouteSegment segment = graphSegments.poll();
|
RouteSegment segment = graphSegments.poll();
|
||||||
// use accumulative approach
|
// use accumulative approach
|
||||||
|
@ -169,6 +172,9 @@ public class BinaryRoutePlanner {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected void checkIfGraphIsEmpty(final RoutingContext ctx, boolean allowDirection,
|
protected void checkIfGraphIsEmpty(final RoutingContext ctx, boolean allowDirection,
|
||||||
PriorityQueue<RouteSegment> graphSegments, RouteSegmentPoint pnt, TLongObjectHashMap<RouteSegment> visited,
|
PriorityQueue<RouteSegment> graphSegments, RouteSegmentPoint pnt, TLongObjectHashMap<RouteSegment> visited,
|
||||||
String msg) {
|
String msg) {
|
||||||
|
@ -238,7 +244,7 @@ public class BinaryRoutePlanner {
|
||||||
|
|
||||||
|
|
||||||
private void initQueuesWithStartEnd(final RoutingContext ctx, RouteSegment start, RouteSegment end,
|
private void initQueuesWithStartEnd(final RoutingContext ctx, RouteSegment start, RouteSegment end,
|
||||||
PriorityQueue<RouteSegment> graphDirectSegments, PriorityQueue<RouteSegment> graphReverseSegments) {
|
RouteSegment recalculationEnd, PriorityQueue<RouteSegment> graphDirectSegments, PriorityQueue<RouteSegment> graphReverseSegments) {
|
||||||
RouteSegment startPos = initRouteSegment(ctx, start, true);
|
RouteSegment startPos = initRouteSegment(ctx, start, true);
|
||||||
RouteSegment startNeg = initRouteSegment(ctx, start, false);
|
RouteSegment startNeg = initRouteSegment(ctx, start, false);
|
||||||
RouteSegment endPos = initRouteSegment(ctx, end, true);
|
RouteSegment endPos = initRouteSegment(ctx, end, true);
|
||||||
|
@ -258,6 +264,10 @@ public class BinaryRoutePlanner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(recalculationEnd != null) {
|
||||||
|
ctx.targetX = recalculationEnd.getRoad().getPoint31XTile(recalculationEnd.getSegmentStart());
|
||||||
|
ctx.targetY = recalculationEnd.getRoad().getPoint31YTile(recalculationEnd.getSegmentStart());
|
||||||
|
}
|
||||||
float estimatedDistance = (float) estimatedDistance(ctx, ctx.targetX, ctx.targetY, ctx.startX, ctx.startY);
|
float estimatedDistance = (float) estimatedDistance(ctx, ctx.targetX, ctx.targetY, ctx.startX, ctx.startY);
|
||||||
if(startPos != null) {
|
if(startPos != null) {
|
||||||
startPos.distanceToEnd = estimatedDistance;
|
startPos.distanceToEnd = estimatedDistance;
|
||||||
|
@ -267,15 +277,19 @@ public class BinaryRoutePlanner {
|
||||||
startNeg.distanceToEnd = estimatedDistance;
|
startNeg.distanceToEnd = estimatedDistance;
|
||||||
graphDirectSegments.add(startNeg);
|
graphDirectSegments.add(startNeg);
|
||||||
}
|
}
|
||||||
if(endPos != null) {
|
if(recalculationEnd != null) {
|
||||||
|
graphReverseSegments.add(recalculationEnd);
|
||||||
|
} else {
|
||||||
|
if (endPos != null) {
|
||||||
endPos.distanceToEnd = estimatedDistance;
|
endPos.distanceToEnd = estimatedDistance;
|
||||||
graphReverseSegments.add(endPos);
|
graphReverseSegments.add(endPos);
|
||||||
}
|
}
|
||||||
if(endNeg != null) {
|
if (endNeg != null) {
|
||||||
endNeg.distanceToEnd = estimatedDistance;
|
endNeg.distanceToEnd = estimatedDistance;
|
||||||
graphReverseSegments.add(endNeg);
|
graphReverseSegments.add(endNeg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void printMemoryConsumption( String string) {
|
private void printMemoryConsumption( String string) {
|
||||||
|
|
|
@ -16,6 +16,7 @@ import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteRegion;
|
||||||
import net.osmand.binary.RouteDataObject;
|
import net.osmand.binary.RouteDataObject;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
import net.osmand.data.QuadPoint;
|
import net.osmand.data.QuadPoint;
|
||||||
|
import net.osmand.router.BinaryRoutePlanner.RouteSegment;
|
||||||
import net.osmand.router.BinaryRoutePlanner.RouteSegmentPoint;
|
import net.osmand.router.BinaryRoutePlanner.RouteSegmentPoint;
|
||||||
import net.osmand.util.MapUtils;
|
import net.osmand.util.MapUtils;
|
||||||
|
|
||||||
|
@ -25,6 +26,7 @@ public class RoutePlannerFrontEnd {
|
||||||
|
|
||||||
private boolean useOldVersion;
|
private boolean useOldVersion;
|
||||||
protected static final Log log = PlatformUtil.getLog(RoutePlannerFrontEnd.class);
|
protected static final Log log = PlatformUtil.getLog(RoutePlannerFrontEnd.class);
|
||||||
|
public boolean useSmartRouteRecalculation = true;
|
||||||
|
|
||||||
public RoutePlannerFrontEnd(boolean useOldVersion) {
|
public RoutePlannerFrontEnd(boolean useOldVersion) {
|
||||||
this.useOldVersion = useOldVersion;
|
this.useOldVersion = useOldVersion;
|
||||||
|
@ -100,6 +102,10 @@ public class RoutePlannerFrontEnd {
|
||||||
return searchRoute(ctx, start, end, intermediates, null);
|
return searchRoute(ctx, start, end, intermediates, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setUseFastRecalculation(boolean use) {
|
||||||
|
useSmartRouteRecalculation = use;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
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 {
|
||||||
|
@ -127,10 +133,14 @@ public class RoutePlannerFrontEnd {
|
||||||
ctx.startY = MapUtils.get31TileNumberY(start.getLatitude());
|
ctx.startY = MapUtils.get31TileNumberY(start.getLatitude());
|
||||||
ctx.targetX = MapUtils.get31TileNumberX(end.getLongitude());
|
ctx.targetX = MapUtils.get31TileNumberX(end.getLongitude());
|
||||||
ctx.targetY = MapUtils.get31TileNumberY(end.getLatitude());
|
ctx.targetY = MapUtils.get31TileNumberY(end.getLatitude());
|
||||||
|
RouteSegment recalculationEnd = getRecalculationEnd(ctx);
|
||||||
|
if(recalculationEnd != null) {
|
||||||
|
ctx.initTargetPoint(recalculationEnd);
|
||||||
|
}
|
||||||
if(routeDirection != null) {
|
if(routeDirection != null) {
|
||||||
ctx.precalculatedRouteDirection = routeDirection.adopt(ctx);
|
ctx.precalculatedRouteDirection = routeDirection.adopt(ctx);
|
||||||
}
|
}
|
||||||
List<RouteSegmentResult> res = runNativeRouting(ctx);
|
List<RouteSegmentResult> res = runNativeRouting(ctx, recalculationEnd);
|
||||||
if(res != null) {
|
if(res != null) {
|
||||||
new RouteResultPreparation().printResults(ctx, start, end, res);
|
new RouteResultPreparation().printResults(ctx, start, end, res);
|
||||||
}
|
}
|
||||||
|
@ -283,25 +293,63 @@ public class RoutePlannerFrontEnd {
|
||||||
|
|
||||||
private List<RouteSegmentResult> searchRouteInternalPrepare(final RoutingContext ctx, RouteSegmentPoint start, RouteSegmentPoint end,
|
private List<RouteSegmentResult> searchRouteInternalPrepare(final RoutingContext ctx, RouteSegmentPoint start, RouteSegmentPoint end,
|
||||||
PrecalculatedRouteDirection routeDirection) throws IOException, InterruptedException {
|
PrecalculatedRouteDirection routeDirection) throws IOException, InterruptedException {
|
||||||
|
RouteSegment recalculationEnd = getRecalculationEnd(ctx);
|
||||||
|
if(recalculationEnd != null) {
|
||||||
|
ctx.initStartAndTargetPoints(start, recalculationEnd);
|
||||||
|
} else {
|
||||||
ctx.initStartAndTargetPoints(start, end);
|
ctx.initStartAndTargetPoints(start, end);
|
||||||
|
}
|
||||||
if(routeDirection != null) {
|
if(routeDirection != null) {
|
||||||
ctx.precalculatedRouteDirection = routeDirection.adopt(ctx);
|
ctx.precalculatedRouteDirection = routeDirection.adopt(ctx);
|
||||||
}
|
}
|
||||||
if (ctx.nativeLib != null) {
|
if (ctx.nativeLib != null) {
|
||||||
return runNativeRouting(ctx);
|
return runNativeRouting(ctx, recalculationEnd);
|
||||||
} else {
|
} else {
|
||||||
refreshProgressDistance(ctx);
|
refreshProgressDistance(ctx);
|
||||||
// Split into 2 methods to let GC work in between
|
// Split into 2 methods to let GC work in between
|
||||||
if(useOldVersion) {
|
if(useOldVersion) {
|
||||||
new BinaryRoutePlannerOld().searchRouteInternal(ctx, start, end);
|
new BinaryRoutePlannerOld().searchRouteInternal(ctx, start, end);
|
||||||
} else {
|
} else {
|
||||||
ctx.finalRouteSegment = new BinaryRoutePlanner().searchRouteInternal(ctx, start, end);
|
ctx.finalRouteSegment = new BinaryRoutePlanner().searchRouteInternal(ctx, start, end, recalculationEnd);
|
||||||
}
|
}
|
||||||
// 4. Route is found : collect all segments and prepare result
|
// 4. Route is found : collect all segments and prepare result
|
||||||
return new RouteResultPreparation().prepareResult(ctx, ctx.finalRouteSegment);
|
return new RouteResultPreparation().prepareResult(ctx, ctx.finalRouteSegment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private RouteSegment getRecalculationEnd(final RoutingContext ctx) {
|
||||||
|
RouteSegment recalculationEnd = null;
|
||||||
|
boolean runRecalculation = ctx.previouslyCalculatedRoute != null && ctx.previouslyCalculatedRoute.size() > 0
|
||||||
|
&& ctx.config.recalculateDistance != 0;
|
||||||
|
if (runRecalculation) {
|
||||||
|
List<RouteSegmentResult> rlist = new ArrayList<RouteSegmentResult>();
|
||||||
|
float distanceThreshold = ctx.config.recalculateDistance;
|
||||||
|
float threshold = 0;
|
||||||
|
for (RouteSegmentResult rr : ctx.previouslyCalculatedRoute) {
|
||||||
|
threshold += rr.getDistance();
|
||||||
|
if (threshold > distanceThreshold) {
|
||||||
|
rlist.add(rr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
runRecalculation = rlist.size() > 0;
|
||||||
|
if (rlist.size() > 0) {
|
||||||
|
RouteSegment previous = null;
|
||||||
|
for (int i = 0; i < rlist.size() - 1; i++) {
|
||||||
|
RouteSegmentResult rr = rlist.get(i);
|
||||||
|
RouteSegment segment = new RouteSegment(rr.getObject(), rr.getEndPointIndex());
|
||||||
|
if (previous != null) {
|
||||||
|
previous.setParentRoute(segment);
|
||||||
|
previous.setParentSegmentEnd(rr.getStartPointIndex());
|
||||||
|
} else {
|
||||||
|
recalculationEnd = segment;
|
||||||
|
}
|
||||||
|
previous = segment;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return recalculationEnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void refreshProgressDistance(RoutingContext ctx) {
|
private void refreshProgressDistance(RoutingContext ctx) {
|
||||||
if(ctx.calculationProgress != null) {
|
if(ctx.calculationProgress != null) {
|
||||||
|
@ -316,16 +364,26 @@ public class RoutePlannerFrontEnd {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<RouteSegmentResult> runNativeRouting(final RoutingContext ctx) throws IOException {
|
private List<RouteSegmentResult> runNativeRouting(final RoutingContext ctx, RouteSegment recalculationEnd) throws IOException {
|
||||||
refreshProgressDistance(ctx);
|
refreshProgressDistance(ctx);
|
||||||
RouteRegion[] regions = ctx.reverseMap.keySet().toArray(new BinaryMapRouteReaderAdapter.RouteRegion[ctx.reverseMap.size()]);
|
RouteRegion[] regions = ctx.reverseMap.keySet().toArray(new BinaryMapRouteReaderAdapter.RouteRegion[ctx.reverseMap.size()]);
|
||||||
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);
|
||||||
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) {
|
||||||
|
log.info("Native routing use precalculated route");
|
||||||
|
RouteSegment current = recalculationEnd;
|
||||||
|
while(current.getParentRoute() != null) {
|
||||||
|
RouteSegment pr = current.getParentRoute();
|
||||||
|
result.add(new RouteSegmentResult(pr.getRoad(), current.getParentSegmentEnd(), pr.getSegmentStart()));
|
||||||
|
current = pr;
|
||||||
|
}
|
||||||
|
}
|
||||||
ctx.routingTime = ctx.calculationProgress.routingCalculatedTime;
|
ctx.routingTime = ctx.calculationProgress.routingCalculatedTime;
|
||||||
ctx.visitedSegments = ctx.calculationProgress.visitedSegments;
|
ctx.visitedSegments = ctx.calculationProgress.visitedSegments;
|
||||||
ctx.loadedTiles = ctx.calculationProgress.loadedTiles;
|
ctx.loadedTiles = ctx.calculationProgress.loadedTiles;
|
||||||
|
@ -336,7 +394,9 @@ public class RoutePlannerFrontEnd {
|
||||||
private List<RouteSegmentResult> searchRoute(final RoutingContext ctx, List<RouteSegmentPoint> points, PrecalculatedRouteDirection routeDirection)
|
private List<RouteSegmentResult> searchRoute(final RoutingContext ctx, List<RouteSegmentPoint> points, PrecalculatedRouteDirection routeDirection)
|
||||||
throws IOException, InterruptedException {
|
throws IOException, InterruptedException {
|
||||||
if (points.size() <= 2) {
|
if (points.size() <= 2) {
|
||||||
|
if(!useSmartRouteRecalculation) {
|
||||||
ctx.previouslyCalculatedRoute = null;
|
ctx.previouslyCalculatedRoute = null;
|
||||||
|
}
|
||||||
return searchRoute(ctx, points.get(0), points.get(1), routeDirection);
|
return searchRoute(ctx, points.get(0), points.get(1), routeDirection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -372,7 +432,9 @@ public class RoutePlannerFrontEnd {
|
||||||
for (int i = 0; i < points.size() - 1; i++) {
|
for (int i = 0; i < points.size() - 1; i++) {
|
||||||
RoutingContext local = new RoutingContext(ctx);
|
RoutingContext local = new RoutingContext(ctx);
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
//local.previouslyCalculatedRoute = firstPartRecalculatedRoute;
|
if (useSmartRouteRecalculation) {
|
||||||
|
local.previouslyCalculatedRoute = firstPartRecalculatedRoute;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
local.visitor = ctx.visitor;
|
local.visitor = ctx.visitor;
|
||||||
local.calculationProgress = ctx.calculationProgress;
|
local.calculationProgress = ctx.calculationProgress;
|
||||||
|
|
|
@ -47,7 +47,7 @@ public class RoutingConfiguration {
|
||||||
public Double initialDirection;
|
public Double initialDirection;
|
||||||
|
|
||||||
// 1.5 Recalculate distance help
|
// 1.5 Recalculate distance help
|
||||||
public float recalculateDistance = 10000f;
|
public float recalculateDistance = 20000f;
|
||||||
|
|
||||||
|
|
||||||
public static class Builder {
|
public static class Builder {
|
||||||
|
|
|
@ -207,12 +207,16 @@ public class RoutingContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initStartAndTargetPoints(RouteSegment start, RouteSegment end) {
|
public void initStartAndTargetPoints(RouteSegment start, RouteSegment end) {
|
||||||
targetX = end.road.getPoint31XTile(end.getSegmentStart());
|
initTargetPoint(end);
|
||||||
targetY = end.road.getPoint31YTile(end.getSegmentStart());
|
|
||||||
startX = start.road.getPoint31XTile(start.getSegmentStart());
|
startX = start.road.getPoint31XTile(start.getSegmentStart());
|
||||||
startY = start.road.getPoint31YTile(start.getSegmentStart());
|
startY = start.road.getPoint31YTile(start.getSegmentStart());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void initTargetPoint(RouteSegment end) {
|
||||||
|
targetX = end.road.getPoint31XTile(end.getSegmentStart());
|
||||||
|
targetY = end.road.getPoint31YTile(end.getSegmentStart());
|
||||||
|
}
|
||||||
|
|
||||||
public void unloadAllData() {
|
public void unloadAllData() {
|
||||||
unloadAllData(null);
|
unloadAllData(null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -199,6 +199,7 @@ public class MapRendererContext implements RendererRegistry.IRendererLoadedEvent
|
||||||
|
|
||||||
private void recreateRasterAndSymbolsProvider() {
|
private void recreateRasterAndSymbolsProvider() {
|
||||||
// Create new map primitiviser
|
// Create new map primitiviser
|
||||||
|
// TODO Victor ask MapPrimitiviser, ObfMapObjectsProvider
|
||||||
MapPrimitiviser mapPrimitiviser = new MapPrimitiviser(mapPresentationEnvironment);
|
MapPrimitiviser mapPrimitiviser = new MapPrimitiviser(mapPresentationEnvironment);
|
||||||
ObfMapObjectsProvider obfMapObjectsProvider = new ObfMapObjectsProvider(obfsCollection);
|
ObfMapObjectsProvider obfMapObjectsProvider = new ObfMapObjectsProvider(obfsCollection);
|
||||||
// Create new map primitives provider
|
// Create new map primitives provider
|
||||||
|
|
|
@ -623,7 +623,7 @@ public class OsmandSettings {
|
||||||
registeredPreferences.put(id, p);
|
registeredPreferences.put(id, p);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
public final CommonPreference<Boolean> USE_FAST_RECALCULATION = new BooleanPreference("use_fast_recalculation", true).makeGlobal().cache();
|
||||||
|
|
||||||
// this value string is synchronized with settings_pref.xml preference name
|
// this value string is synchronized with settings_pref.xml preference name
|
||||||
public final CommonPreference<Boolean> USE_INTERNET_TO_DOWNLOAD_TILES = new BooleanPreference("use_internet_to_download_tiles", true).makeGlobal().cache();
|
public final CommonPreference<Boolean> USE_INTERNET_TO_DOWNLOAD_TILES = new BooleanPreference("use_internet_to_download_tiles", true).makeGlobal().cache();
|
||||||
|
|
|
@ -89,6 +89,17 @@ public abstract class SettingsBaseActivity extends ActionBarPreferenceActivity
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CheckBoxPreference createCheckBoxPreference(OsmandPreference<Boolean> b, String title, String summary) {
|
||||||
|
CheckBoxPreference p = new CheckBoxPreference(this);
|
||||||
|
p.setTitle(title);
|
||||||
|
p.setKey(b.getId());
|
||||||
|
p.setSummary(summary);
|
||||||
|
p.setOnPreferenceChangeListener(this);
|
||||||
|
screenPreferences.put(b.getId(), p);
|
||||||
|
booleanPreferences.put(b.getId(), b);
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
public CheckBoxPreference createCheckBoxPreference(OsmandPreference<Boolean> b) {
|
public CheckBoxPreference createCheckBoxPreference(OsmandPreference<Boolean> b) {
|
||||||
CheckBoxPreference p = new CheckBoxPreference(this);
|
CheckBoxPreference p = new CheckBoxPreference(this);
|
||||||
p.setKey(b.getId());
|
p.setKey(b.getId());
|
||||||
|
|
|
@ -41,6 +41,9 @@ public class SettingsDevelopmentActivity extends SettingsBaseActivity {
|
||||||
|
|
||||||
cat.addPreference(createCheckBoxPreference(settings.DISABLE_COMPLEX_ROUTING, R.string.disable_complex_routing, R.string.disable_complex_routing_descr));
|
cat.addPreference(createCheckBoxPreference(settings.DISABLE_COMPLEX_ROUTING, R.string.disable_complex_routing, R.string.disable_complex_routing_descr));
|
||||||
|
|
||||||
|
cat.addPreference(createCheckBoxPreference(settings.USE_FAST_RECALCULATION, "Smart route recalculation", "Recalculate only initial part of the route for long trips"));
|
||||||
|
|
||||||
|
|
||||||
cat.addPreference(createCheckBoxPreference(settings.USE_MAGNETIC_FIELD_SENSOR_COMPASS, R.string.use_magnetic_sensor, R.string.use_magnetic_sensor_descr));
|
cat.addPreference(createCheckBoxPreference(settings.USE_MAGNETIC_FIELD_SENSOR_COMPASS, R.string.use_magnetic_sensor, R.string.use_magnetic_sensor_descr));
|
||||||
|
|
||||||
Preference pref = new Preference(this);
|
Preference pref = new Preference(this);
|
||||||
|
|
|
@ -630,6 +630,7 @@ public class RouteProvider {
|
||||||
BinaryMapIndexReader[] files = params.ctx.getResourceManager().getRoutingMapFiles();
|
BinaryMapIndexReader[] files = params.ctx.getResourceManager().getRoutingMapFiles();
|
||||||
RoutePlannerFrontEnd router = new RoutePlannerFrontEnd(false);
|
RoutePlannerFrontEnd router = new RoutePlannerFrontEnd(false);
|
||||||
OsmandSettings settings = params.ctx.getSettings();
|
OsmandSettings settings = params.ctx.getSettings();
|
||||||
|
router.setUseFastRecalculation(settings.USE_FAST_RECALCULATION.get());
|
||||||
|
|
||||||
RoutingConfiguration.Builder config = params.ctx.getDefaultRoutingConfig();
|
RoutingConfiguration.Builder config = params.ctx.getDefaultRoutingConfig();
|
||||||
GeneralRouter generalRouter = SettingsNavigationActivity.getRouter(config, params.mode);
|
GeneralRouter generalRouter = SettingsNavigationActivity.getRouter(config, params.mode);
|
||||||
|
@ -666,6 +667,9 @@ public class RouteProvider {
|
||||||
RouteCalculationMode.COMPLEX);
|
RouteCalculationMode.COMPLEX);
|
||||||
complexCtx.calculationProgress = params.calculationProgress;
|
complexCtx.calculationProgress = params.calculationProgress;
|
||||||
complexCtx.leftSideNavigation = params.leftSide;
|
complexCtx.leftSideNavigation = params.leftSide;
|
||||||
|
if(params.previousToRecalculate != null && params.onlyStartPointChanged) {
|
||||||
|
complexCtx.previouslyCalculatedRoute = params.previousToRecalculate.getOriginalRoute();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ctx.leftSideNavigation = params.leftSide;
|
ctx.leftSideNavigation = params.leftSide;
|
||||||
ctx.calculationProgress = params.calculationProgress;
|
ctx.calculationProgress = params.calculationProgress;
|
||||||
|
|
Loading…
Reference in a new issue