Lefthand routes are not shown correctly in automatic mode

This commit is contained in:
androiddevkotlin 2021-01-17 21:24:12 +02:00
parent 128c08ca7f
commit a6adf50553
5 changed files with 21 additions and 12 deletions

View file

@ -445,7 +445,7 @@ public class TargetPointsHelper {
Location lastKnownLocation = ctx.getLocationProvider().getLastKnownLocation();
LatLon latLon = lastKnownLocation != null ?
new LatLon(lastKnownLocation.getLatitude(), lastKnownLocation.getLongitude()) : null;
RoutingHelperUtils.checkAndUpdateStartLocation(ctx, latLon);
RoutingHelperUtils.checkAndUpdateStartLocation(ctx, latLon, false);
setMyLocationPoint(latLon, false, null);
}
}

View file

@ -1408,6 +1408,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
updateMapSettings();
app.getPoiFilters().loadSelectedPoiFilters();
mapViewTrackingUtilities.updateSettings();
mapViewTrackingUtilities.resetDrivingRegionUpdate();
//app.getRoutingHelper().setAppMode(settings.getApplicationMode());
if (mapLayers.getMapInfoLayer() != null) {
mapLayers.getMapInfoLayer().recreateControls();

View file

@ -13,8 +13,6 @@ import net.osmand.data.LatLon;
import net.osmand.data.RotatedTileBox;
import net.osmand.map.IMapLocationListener;
import net.osmand.map.WorldRegion;
import net.osmand.plus.mapmarkers.MapMarker;
import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarkerChangedListener;
import net.osmand.plus.OsmAndConstants;
import net.osmand.plus.OsmAndLocationProvider;
import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener;
@ -22,10 +20,14 @@ import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.dashboard.DashboardOnMap;
import net.osmand.plus.helpers.enums.DrivingRegion;
import net.osmand.plus.mapcontextmenu.MapContextMenu;
import net.osmand.plus.mapcontextmenu.other.TrackDetailsMenu;
import net.osmand.plus.mapmarkers.MapMarker;
import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarkerChangedListener;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.routing.RoutingHelperUtils;
import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.views.AnimateDraggingMapThread;
import net.osmand.plus.views.OsmandMapTileView;
@ -176,7 +178,7 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
locationProvider = location.getProvider();
if (settings.DRIVING_REGION_AUTOMATIC.get() && !drivingRegionUpdated && !app.isApplicationInitializing()) {
drivingRegionUpdated = true;
RoutingHelperUtils.checkAndUpdateStartLocation(app, location);
RoutingHelperUtils.checkAndUpdateStartLocation(app, location, true);
}
}
if (mapView != null) {
@ -489,7 +491,15 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
@Override
protected void onPostExecute(WorldRegion worldRegion) {
if (worldRegion != null) {
DrivingRegion oldRegion = app.getSettings().DRIVING_REGION.get();
app.setupDrivingRegion(worldRegion);
DrivingRegion currentRegion = app.getSettings().DRIVING_REGION.get();
if (oldRegion.leftHandDriving != currentRegion.leftHandDriving) {
ApplicationMode mode = app.getRoutingHelper().getAppMode();
app.getRoutingHelper().onSettingsChanged(mode, true);
}
}
}
}

View file

@ -194,7 +194,7 @@ public class RoutingHelper {
}
public synchronized void setFinalAndCurrentLocation(LatLon finalLocation, List<LatLon> intermediatePoints, Location currentLocation) {
RoutingHelperUtils.checkAndUpdateStartLocation(app, currentLocation);
RoutingHelperUtils.checkAndUpdateStartLocation(app, currentLocation, false);
RouteCalculationResult previousRoute = route;
clearCurrentRoute(finalLocation, intermediatePoints);
// to update route

View file

@ -8,9 +8,6 @@ import net.osmand.data.LatLon;
import net.osmand.data.QuadRect;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.TargetPointsHelper;
import net.osmand.plus.helpers.enums.MetricsConstants;
import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.util.MapUtils;
import java.util.List;
@ -164,19 +161,20 @@ public class RoutingHelperUtils {
}
public static void checkAndUpdateStartLocation(@NonNull OsmandApplication app, LatLon newStartLocation) {
public static void checkAndUpdateStartLocation(@NonNull OsmandApplication app, LatLon newStartLocation, boolean force) {
if (newStartLocation != null) {
LatLon lastStartLocation = app.getSettings().getLastStartPoint();
if (lastStartLocation == null || MapUtils.getDistance(newStartLocation, lastStartLocation) > CACHE_RADIUS) {
if (lastStartLocation == null || MapUtils.getDistance(newStartLocation, lastStartLocation) > CACHE_RADIUS || force) {
app.getMapViewTrackingUtilities().detectDrivingRegion(newStartLocation);
app.getSettings().setLastStartPoint(newStartLocation);
}
}
}
public static void checkAndUpdateStartLocation(@NonNull OsmandApplication app, Location nextStartLocation) {
public static void checkAndUpdateStartLocation(@NonNull OsmandApplication app, Location nextStartLocation, boolean force) {
if (nextStartLocation != null) {
checkAndUpdateStartLocation(app, new LatLon(nextStartLocation.getLatitude(), nextStartLocation.getLongitude()));
LatLon newStartLocation = new LatLon(nextStartLocation.getLatitude(), nextStartLocation.getLongitude());
checkAndUpdateStartLocation(app, newStartLocation, force);
}
}
}