Recalculate for online

This commit is contained in:
vshcherb 2014-04-01 01:21:30 +02:00
parent 91b3eb56d8
commit 870f337f0d
3 changed files with 12 additions and 13 deletions

View file

@ -146,11 +146,11 @@ public class TargetPointsHelper {
Location lastKnownLocation = ctx.getLocationProvider().getLastKnownLocation(); Location lastKnownLocation = ctx.getLocationProvider().getLastKnownLocation();
if((routingHelper.isFollowingMode() && lastKnownLocation != null) || start == null) { if((routingHelper.isFollowingMode() && lastKnownLocation != null) || start == null) {
routingHelper.setFinalAndCurrentLocation(settings.getPointToNavigate(), routingHelper.setFinalAndCurrentLocation(settings.getPointToNavigate(),
settings.getIntermediatePoints(), lastKnownLocation, routingHelper.getCurrentGPXRoute()); settings.getIntermediatePoints(), lastKnownLocation);
} else { } else {
Location loc = wrap(start); Location loc = wrap(start);
routingHelper.setFinalAndCurrentLocation(settings.getPointToNavigate(), routingHelper.setFinalAndCurrentLocation(settings.getPointToNavigate(),
settings.getIntermediatePoints(), loc, routingHelper.getCurrentGPXRoute()); settings.getIntermediatePoints(), loc);
} }
} }

View file

@ -834,8 +834,7 @@ public class MapActivityActions implements DialogProvider {
if(getMyApplication().getLocationProvider().getLocationSimulation().isRouteAnimating()) { if(getMyApplication().getLocationProvider().getLocationSimulation().isRouteAnimating()) {
getMyApplication().getLocationProvider().getLocationSimulation().startStopRouteAnimation(mapActivity); getMyApplication().getLocationProvider().getLocationSimulation().startStopRouteAnimation(mapActivity);
} }
routingHelper.setFinalAndCurrentLocation(null, new ArrayList<LatLon>(), getLastKnownLocation(), routingHelper.clearCurrentRoute(null, new ArrayList<LatLon>());
routingHelper.getCurrentGPXRoute());
routingHelper.setRoutePlanningMode(false); routingHelper.setRoutePlanningMode(false);
settings.APPLICATION_MODE.set(settings.DEFAULT_APPLICATION_MODE.get()); settings.APPLICATION_MODE.set(settings.DEFAULT_APPLICATION_MODE.get());
mapActivity.updateApplicationModeSettings(); mapActivity.updateApplicationModeSettings();

View file

@ -116,14 +116,11 @@ public class RoutingHelper {
public synchronized void setFinalAndCurrentLocation(LatLon finalLocation, List<LatLon> intermediatePoints, Location currentLocation, public synchronized void setFinalAndCurrentLocation(LatLon finalLocation, List<LatLon> intermediatePoints, Location currentLocation){
GPXRouteParamsBuilder gpxRoute){ RouteCalculationResult previousRoute = route;
clearCurrentRoute(finalLocation, intermediatePoints); clearCurrentRoute(finalLocation, intermediatePoints);
setGpxParams(gpxRoute);
// to update route // to update route
setCurrentLocation(currentLocation, false); setCurrentLocation(currentLocation, false, previousRoute);
} }
public synchronized void clearCurrentRoute(LatLon newFinalLocation, List<LatLon> newIntermediatePoints) { public synchronized void clearCurrentRoute(LatLon newFinalLocation, List<LatLon> newIntermediatePoints) {
@ -210,8 +207,11 @@ public class RoutingHelper {
} }
} }
public Location setCurrentLocation(Location currentLocation, boolean returnUpdatedLocation) {
return setCurrentLocation(currentLocation, returnUpdatedLocation, route);
}
public Location setCurrentLocation(Location currentLocation, boolean returnUpdatedLocation ) { private Location setCurrentLocation(Location currentLocation, boolean returnUpdatedLocation, RouteCalculationResult previousRoute) {
Location locationProjection = currentLocation; Location locationProjection = currentLocation;
if (finalLocation == null || currentLocation == null) { if (finalLocation == null || currentLocation == null) {
makeUturnWhenPossible = false; makeUturnWhenPossible = false;
@ -286,8 +286,8 @@ public class RoutingHelper {
} }
if (calculateRoute) { if (calculateRoute) {
recalculateRouteInBackground(false, currentLocation, finalLocation, intermediatePoints, currentGPXRoute, route.isCalculated() ? route recalculateRouteInBackground(false, currentLocation, finalLocation, intermediatePoints, currentGPXRoute,
: null); previousRoute.isCalculated() ? previousRoute : null);
} }
double projectDist = mode.hasFastSpeed() ? posTolerance : posTolerance / 2; double projectDist = mode.hasFastSpeed() ? posTolerance : posTolerance / 2;
if(returnUpdatedLocation && locationProjection != null && currentLocation.distanceTo(locationProjection) < projectDist) { if(returnUpdatedLocation && locationProjection != null && currentLocation.distanceTo(locationProjection) < projectDist) {