fix defining driving region 3 #7668

This commit is contained in:
MadWasp79 2020-01-23 18:31:04 +02:00
parent d0aaddf28c
commit 42a7a5d88d
4 changed files with 13 additions and 26 deletions

View file

@ -743,19 +743,8 @@ public class OsmandRegions {
while (it.hasNext()) {
BinaryMapDataObject o = it.next();
if (o.getTypes() != null) {
boolean isRegion = true;
for (int i = 0; i < o.getTypes().length; i++) {
TagValuePair tp = o.getMapIndex().decodeType(o.getTypes()[i]);
if (o.getTypes().length > 1) {
if ("boundary".equals(tp.value)) {
isRegion = false;
break;
}
}
}
WorldRegion downloadRegion = getRegionData(getFullName(o));
if (!isRegion
|| downloadRegion == null
if ( downloadRegion == null
|| !downloadRegion.isRegionMapDownload()
|| !contain(o, point31x, point31y)) {
it.remove();

View file

@ -1319,9 +1319,8 @@ public class OsmandSettings {
return DrivingRegion.JAPAN;
} else if (df.getCountry().equalsIgnoreCase("au")) {
return DrivingRegion.AUSTRALIA;
// potentially wrong in Europe
// } else if(df.getCountry().equalsIgnoreCase(Locale.UK.getCountry())) {
// return DrivingRegion.UK_AND_OTHERS;
} else if(df.getCountry().equalsIgnoreCase(Locale.UK.getCountry())) {
return DrivingRegion.UK_AND_OTHERS;
}
return DrivingRegion.EUROPE_ASIA;
}

View file

@ -167,8 +167,7 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
locationProvider = location.getProvider();
if (settings.DRIVING_REGION_AUTOMATIC.get() && !drivingRegionUpdated && !app.isApplicationInitializing()) {
drivingRegionUpdated = true;
detectDrivingRegion(new LatLon(location.getLatitude(), location.getLongitude()));
app.getRoutingHelper().setLastStartingLocation(location);
app.getRoutingHelper().cacheStartLocation(location);
}
}
if (mapView != null) {

View file

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