fix defining driving region #7668

This commit is contained in:
MadWasp79 2020-01-23 10:19:06 +02:00
parent 9b010305b9
commit e5ca877802
3 changed files with 19 additions and 4 deletions

View file

@ -746,9 +746,11 @@ public class OsmandRegions {
boolean isRegion = true; boolean isRegion = true;
for (int i = 0; i < o.getTypes().length; i++) { for (int i = 0; i < o.getTypes().length; i++) {
TagValuePair tp = o.getMapIndex().decodeType(o.getTypes()[i]); TagValuePair tp = o.getMapIndex().decodeType(o.getTypes()[i]);
if ("boundary".equals(tp.value)) { if (o.getTypes().length > 1) {
isRegion = false; if ("boundary".equals(tp.value)) {
break; isRegion = false;
break;
}
} }
} }
WorldRegion downloadRegion = getRegionData(getFullName(o)); WorldRegion downloadRegion = getRegionData(getFullName(o));

View file

@ -155,7 +155,7 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
return movingToMyLocation; return movingToMyLocation;
} }
private void detectDrivingRegion(final LatLon latLon) { public void detectDrivingRegion(final LatLon latLon) {
new DetectDrivingRegionTask(app).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, latLon); new DetectDrivingRegionTask(app).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, latLon);
} }

View file

@ -57,6 +57,7 @@ public class RoutingHelper {
private List<LatLon> intermediatePoints; private List<LatLon> intermediatePoints;
private Location lastProjection; private Location lastProjection;
private Location lastFixedLocation; private Location lastFixedLocation;
private LatLon lastStartingLocation = null;
private static final int RECALCULATE_THRESHOLD_COUNT_CAUSING_FULL_RECALCULATE = 3; private static final int RECALCULATE_THRESHOLD_COUNT_CAUSING_FULL_RECALCULATE = 3;
private static final int RECALCULATE_THRESHOLD_CAUSING_FULL_RECALCULATE_INTERVAL = 2*60*1000; private static final int RECALCULATE_THRESHOLD_CAUSING_FULL_RECALCULATE_INTERVAL = 2*60*1000;
@ -174,6 +175,7 @@ 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){
RouteCalculationResult previousRoute = route; RouteCalculationResult previousRoute = route;
setLastStartingLocation(currentLocation);
clearCurrentRoute(finalLocation, intermediatePoints); clearCurrentRoute(finalLocation, intermediatePoints);
// to update route // to update route
setCurrentLocation(currentLocation, false, previousRoute, true); setCurrentLocation(currentLocation, false, previousRoute, true);
@ -260,6 +262,17 @@ public class RoutingHelper {
return finalLocation; return finalLocation;
} }
public void setLastStartingLocation(Location nextStartLocation) {
LatLon start = new LatLon(nextStartLocation.getLatitude(), nextStartLocation.getLongitude());
if (lastStartingLocation == null) {
lastStartingLocation = new LatLon(nextStartLocation.getLatitude(), nextStartLocation.getLongitude());
app.getMapViewTrackingUtilities().detectDrivingRegion(lastStartingLocation);
} else if (MapUtils.getDistance(start, lastStartingLocation) > 100000) {
lastStartingLocation = start;
app.getMapViewTrackingUtilities().detectDrivingRegion(lastStartingLocation);
}
}
public List<LatLon> getIntermediatePoints() { public List<LatLon> getIntermediatePoints() {
return intermediatePoints; return intermediatePoints;
} }