Merge branch 'master' into polylabel_center_point

This commit is contained in:
MadWasp79 2020-01-28 16:56:56 +02:00
commit ad6fa6ad7b
20 changed files with 610 additions and 376 deletions

File diff suppressed because it is too large Load diff

View file

@ -691,31 +691,21 @@ public class OsmandRegions {
}
}
public List<WorldRegion> getWoldRegionsAt(LatLon latLon) throws IOException {
List<WorldRegion> result = new ArrayList<>();
List<BinaryMapDataObject> mapDataObjects = getBinaryMapDataObjectsAt(latLon);
for (BinaryMapDataObject obj : mapDataObjects) {
String fullName = getFullName(obj);
if (fullName != null) {
WorldRegion reg = getRegionData(fullName);
if (reg != null) {
result.add(reg);
}
}
}
return result;
public List<WorldRegion> getWorldRegionsAt(LatLon latLon) throws IOException {
Map<WorldRegion, BinaryMapDataObject> mapDataObjects = getBinaryMapDataObjectsWithRegionsAt(latLon);
return new ArrayList<>(mapDataObjects.keySet());
}
public BinaryMapDataObject getSmallestBinaryMapDataObjectAt(LatLon latLon) throws IOException {
List<BinaryMapDataObject> mapDataObjects = getBinaryMapDataObjectsAt(latLon);
return getSmallestBinaryMapDataObjectAt(mapDataObjects);
public Map.Entry<WorldRegion, BinaryMapDataObject> getSmallestBinaryMapDataObjectAt(LatLon latLon) throws IOException {
Map<WorldRegion, BinaryMapDataObject> mapDataObjectsWithRegions = getBinaryMapDataObjectsWithRegionsAt(latLon);
return getSmallestBinaryMapDataObjectAt(mapDataObjectsWithRegions);
}
public BinaryMapDataObject getSmallestBinaryMapDataObjectAt(List<BinaryMapDataObject> mapDataObjects) {
BinaryMapDataObject res = null;
public Map.Entry<WorldRegion, BinaryMapDataObject> getSmallestBinaryMapDataObjectAt(Map<WorldRegion, BinaryMapDataObject> mapDataObjectsWithRegions) {
Map.Entry<WorldRegion, BinaryMapDataObject> res = null;
double smallestArea = -1;
for (BinaryMapDataObject o : mapDataObjects) {
double area = OsmandRegions.getArea(o);
for (Map.Entry<WorldRegion, BinaryMapDataObject> o : mapDataObjectsWithRegions.entrySet()) {
double area = OsmandRegions.getArea(o.getValue());
if (smallestArea == -1) {
smallestArea = area;
res = o;
@ -727,10 +717,10 @@ public class OsmandRegions {
return res;
}
private List<BinaryMapDataObject> getBinaryMapDataObjectsAt(LatLon latLon) throws IOException {
private Map<WorldRegion, BinaryMapDataObject> getBinaryMapDataObjectsWithRegionsAt(LatLon latLon) throws IOException {
int point31x = MapUtils.get31TileNumberX(latLon.getLongitude());
int point31y = MapUtils.get31TileNumberY(latLon.getLatitude());
Map<WorldRegion, BinaryMapDataObject> foundObjects = new LinkedHashMap<>();
List<BinaryMapDataObject> mapDataObjects;
try {
mapDataObjects = queryBboxNoInit(point31x, point31x, point31y, point31y, true);
@ -743,25 +733,18 @@ 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 ("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();
} else {
foundObjects.put(downloadRegion, o);
}
}
}
}
return mapDataObjects;
return foundObjects;
}

View file

@ -3401,8 +3401,8 @@ Indikas lokon: %1$s x %2$s"</string>
<string name="reset_all_profile_settings">Ĉu rekomencigi ĉiujn agordojn pri profiloj\?</string>
<string name="ltr_or_rtl_combine_via_colon">%1$s: %2$s</string>
<string name="ltr_or_rtl_combine_via_space">%1$s %2$s</string>
<string name="file_does_not_contain_routing_rules">La dosiero “%1$s” ne enhavas regulojn pri kursdifinado, bonvolu elekti alian dosieron.</string>
<string name="not_support_file_type_with_ext">Nesubtenata tipo de dosiero. Elektu dosieron kun la finaĵo %1$s.</string>
<string name="file_does_not_contain_routing_rules">Neniuj reguloj pri kursdifinado en “%1$s”. Bonvolu elekti alian dosieron.</string>
<string name="not_support_file_type_with_ext">Bonvolu elekti dosieron kun la subtenata finaĵo %1$s.</string>
<string name="import_from_file">Enporti el dosiero</string>
<string name="import_routing_file">Enporti dosieron de kursdifinado</string>
<string name="import_profile">Enporti profilon</string>
@ -3427,5 +3427,7 @@ Indikas lokon: %1$s x %2$s"</string>
<string name="app_mode_osm">OSM</string>
<string name="select_nav_icon_descr">La emblemo montriĝos nur dum navigi aŭ dum moviĝi.</string>
<string name="select_map_icon_descr">Mapemblemo montriĝas nur dum foliumi mapon kaj ŝanĝiĝas dum navigi al la emblemo de navigo.</string>
<string name="logcat_buffer_descr">Tie ĉi vi povas legi kaj kunhavigi protokolojn de la aplikaĵo</string>
<string name="logcat_buffer_descr">Legi kaj kunhavigi detalajn protokolojn de la aplikaĵo</string>
<string name="permission_is_required">Permeso estas necesa por uzi tiun ĉi eblaĵon.</string>
<string name="monitoring_min_speed_descr">Tiu ĉi filtrilo preventas registri punktojn sub difinita rapidlimo. Tiel registritaj spuroj aspektos pli glate dum vidiĝi sur la mapo.</string>
</resources>

View file

@ -3466,4 +3466,6 @@ Lon %2$s</string>
<string name="select_map_icon_descr">El icono del mapa sólo se muestra en el mapa.</string>
<string name="logcat_buffer_descr">Comprueba y comparte los registros detallados de la aplicación</string>
<string name="search_offline_geo_error">No se puede analizar la geointención «%s».</string>
<string name="permission_is_required">Se necesita permiso para usar esta opción.</string>
<string name="monitoring_min_speed_descr">Se trata de un filtro de corte de baja velocidad para no grabar puntos por debajo de una cierta velocidad. Esto puede hacer que las trazas grabadas se vean más suaves cuando se muestran en el mapa.</string>
</resources>

View file

@ -1434,7 +1434,7 @@ Ces informations sont visibles sur le Tableau de bord comme sur la carte. Un rap
<string name="rendering_attr_pisteGrooming_name">Damage des pistes</string>
<string name="free">%1$s libre</string>
<string name="device_memory">Mémoire de l\'appareil</string>
<string name="notes">Notes OSM</string>
<string name="notes">Notes audio / vidéo</string>
<string name="online_map">Carte en ligne</string>
<string name="roads_only">Routes uniquement</string>
<string name="rendering_attr_pisteRoutes_name">Pistes de ski</string>
@ -3441,4 +3441,7 @@ représentant la zone : %1$s x %2$s</string>
<string name="monitoring_min_speed_descr">Filtre interrompant l\'enregistrement en dessous d\'une certaines vitesse. Rend les traces enregistrées plus régulières lorsqu\'elles sont affichées sur la carte.</string>
<string name="live_monitoring_time_buffer">Durée de la mémoire tampon</string>
<string name="live_monitoring_adress_descr">Indiquez l\'adresse web avec la syntaxe suivante pour les paramètres : lat = {0}, lon = {1}, horodatage = {2}, hdop = {3}, altitude = {4}, vitesse = {5}, direction = {6}.</string>
<string name="monitoring_min_accuracy_descr_recommendation">Recommandation : il est difficile de prédire ce qui sera enregistré et ce qui ne le sera pas, il peut être préférable de désactiver ce filtre.</string>
<string name="monitoring_min_distance_descr">Ce filtre limite l\'enregistrement de points en double lorsque les déplacements sont très lents donnant une apparence plus régulière aux traces.</string>
<string name="monitoring_min_distance_descr_recommendation">Recommandation : un paramètre de 5 mètres est adapté si vous n\'avez pas besoin de détails et ne souhaitez pas enregistrer des points au repos.</string>
</resources>

View file

@ -2388,7 +2388,7 @@ Ha szereted az OsmAndot és az OSM-et, és szeretnéd támogatni a fejlődésük
<string name="ascendingly">AZ</string>
<string name="date_added">Hozzáadva</string>
<string name="order_by">Rendezés alapja:</string>
<string name="marker_show_distance_descr">"Válassza ki, hogyan jelenjék meg a térképen a térképjelölők távolsága és iránya:"</string>
<string name="marker_show_distance_descr">Válassza ki, hogyan jelenjék meg a térképen a térképjelölők távolsága és iránya:</string>
<string name="map_orientation_change_in_accordance_with_speed_descr">Válaszd ki, mekkora sebesség alatt váltson a térkép forgatása „Haladási irány”-ról „Iránytű”-re.</string>
<string name="all_markers_moved_to_history">Minden térképjelölő áthelyezve az előzményekbe</string>
<string name="marker_moved_to_history">Térképjelölő áthelyezve az előzményekhez</string>

View file

@ -344,7 +344,7 @@
<string name="copying_osmand_files">Copiando arquivos de dados…</string>
<string name="calculate_osmand_route_gpx">"Calcular rota off-line "</string>
<string name="app_mode_truck">Caminhão</string>
<string name="auto_zoom_far">Visão intermediária</string>
<string name="auto_zoom_far">Para nível intermediário</string>
<string name="local_index_tile_data_minzoom">Zoom mínimo: %1$s</string>
<string name="edit_tilesource_successfully">A fonte da quadrícula %1$s foi salva</string>
<string name="speak_traffic_warnings">Moderadores de tráfego</string>
@ -537,8 +537,8 @@
<string name="animate_routing_route">"Simular usando a rota calculada "</string>
<string name="animate_routing_gpx">Simular usando trilha GPX</string>
<string name="auto_zoom_none">Sem zoom automático</string>
<string name="auto_zoom_close">Aproximar</string>
<string name="auto_zoom_farthest">Afastar</string>
<string name="auto_zoom_close">Para nível aproximado</string>
<string name="auto_zoom_farthest">Para nível afastado</string>
<string name="map_magnifier">Lupa</string>
<string name="base_world_map">Mapa base mundial</string>
<string name="about_version">Versão:</string>

View file

@ -3448,4 +3448,22 @@ Pro praghere iscrie su còdighe intreu</string>
<string name="select_nav_icon_descr">As a bìdere s\'icona petzi durante sa navigatzione o su movimentu.</string>
<string name="select_map_icon_descr">S\'icona de sa mapa aparit in sa mapa ebbia, e divenit s\'icona de navigatzione durante sa navigatzione.</string>
<string name="logcat_buffer_descr">Inoghe podes pompiare e cumpartzire sos registros de s\'aplicatzione</string>
<string name="search_offline_geo_error">Anàlisi de su geo intent \'%s\' fallida.</string>
<string name="permission_is_required">Pro impreare custa optzione b\'at bisòngiu de unu permissu.</string>
<string name="monitoring_min_speed_descr">Custu est unu filtru pro non registrare puntos in suta de una lestresa isseberada. Faghet in modu chi sas rastas registradas pàrgiant prus regulares cando benint pompiadas in sa mapa.</string>
<string name="monitoring_min_speed_descr_side_effect">Efetu segundàriu: in sa rasta tua ant a mancare totu sas setziones in ue no as rispetadu su critèriu de sa lestresa mìnima (es. cando ispinghes sa bitzicleta tua cara a artu in unu montigru). Annotamala, non b\'ant a èssere informatziones a pitzu de sos perìodos de pasu, che a sas pàusas. Custu at a influentzare totu sas anàlisis o sos post-protzessamentos, a es. cando ses chirchende de determinare sa longària totale de su biàgiu tuo, su tempus in movimentu, o sa lestresa mèdia tua.</string>
<string name="live_monitoring_tracking_interval">Intervallu de arrastamentu</string>
<string name="live_monitoring_adress">Indiritzu web</string>
<string name="live_monitoring_adress_descr">Dislinda s\'indiritzu web cun sa sintassi de paràmetros: lat={0}, lon={1}, marcadesutempus={2}, hdop={3}, artària={4}, lestresa={5}, diretzione={6}.</string>
<string name="monitoring_notification">Notìfica</string>
<string name="monitoring_min_speed">Lestresa mìnima</string>
<string name="monitoring_min_accuracy">Acuradesa mìnima</string>
<string name="monitoring_min_distance">Movimentu mìnimu</string>
<string name="tracks_view_path">Menù — Logos meos — Rastas</string>
<string name="multimedia_notes_view_path">Menù — Logos meos — Notas</string>
<string name="osm_edits_view_path">Menù — Logos meos — Modìficas de OSM</string>
<string name="reset_plugin_to_default">Riprìstina sas impostatziones predefinidas de s\'estensione</string>
<string name="multimedia_use_system_camera">Imprea s\'aplicatzione de sistema</string>
<string name="multimedia_photo_play_sound">Sonu de s\'oturadore de sa fotocàmera</string>
<string name="osm_authorization_success">S\'autorizatzione est resèssida</string>
</resources>

View file

@ -1380,7 +1380,7 @@
<string name="shared_string_dismiss">Відхилити</string>
<string name="shared_string_audio">Аудіо</string>
<string name="share_note">Поділитись нотаткою</string>
<string name="notes">OSM примітки</string>
<string name="notes">A/V примітки</string>
<string name="online_map">Мережева мапа</string>
<string name="roads_only">Тільки дороги</string>
<string name="free">Вільно %1$s</string>

View file

@ -4179,4 +4179,6 @@
<string name="poi_memorial_ghost_bike">Ghost bike</string>
<string name="poi_paintball">Paintball</string>
</resources>

View file

@ -3,7 +3,6 @@ package net.osmand.data;
import java.io.Serializable;
import android.content.Context;
import android.content.res.Resources;
import android.support.annotation.DrawableRes;
import android.support.annotation.NonNull;
import android.support.annotation.StringRes;
@ -19,7 +18,6 @@ public class FavouritePoint implements Serializable, LocationPoint {
private static final String HIDDEN = "hidden";
private static final String ADDRESS_EXTENSION = "address";
private static final String DEFAULT_ICON_NAME = "special_star";
protected String name = "";
protected String description;
@ -139,6 +137,8 @@ public class FavouritePoint implements Serializable, LocationPoint {
public int getOverlayIconId() {
if (isSpecialPoint()) {
return specialPointType.getIconId();
} else if (iconId == 0) {
return R.drawable.mx_special_star;
}
return iconId;
}
@ -202,7 +202,6 @@ public class FavouritePoint implements Serializable, LocationPoint {
return "Favourite " + getName(); //$NON-NLS-1$
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
@ -253,7 +252,6 @@ public class FavouritePoint implements Serializable, LocationPoint {
return result;
}
public enum SpecialPointType {
HOME("home", R.string.home_button, R.drawable.mx_special_house),
WORK("work", R.string.work_button, R.drawable.mx_special_building),
@ -286,7 +284,6 @@ public class FavouritePoint implements Serializable, LocationPoint {
}
}
public static FavouritePoint fromWpt(@NonNull WptPt pt, @NonNull Context ctx) {
String name = pt.name;
String categoryName = pt.category != null ? pt.category : "";

View file

@ -1,5 +1,7 @@
package net.osmand.plus;
import android.location.GnssNavigationMessage;
import android.location.GnssStatus;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import java.util.ArrayList;
@ -17,7 +19,6 @@ import net.osmand.binary.GeocodingUtilities.GeocodingResult;
import net.osmand.binary.RouteDataObject;
import net.osmand.data.LatLon;
import net.osmand.data.QuadPoint;
import net.osmand.plus.OsmandSettings.OsmandPreference;
import net.osmand.plus.TargetPointsHelper.TargetPoint;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.router.RouteSegmentResult;
@ -127,7 +128,7 @@ public class OsmAndLocationProvider implements SensorEventListener {
private List<OsmAndLocationListener> locationListeners = new ArrayList<OsmAndLocationProvider.OsmAndLocationListener>();
private List<OsmAndCompassListener> compassListeners = new ArrayList<OsmAndLocationProvider.OsmAndCompassListener>();
private Listener gpsStatusListener;
private Object gpsStatusListener;
private float[] mRotationM = new float[9];
@ -249,7 +250,7 @@ public class OsmAndLocationProvider implements SensorEventListener {
}
}
if (isLocationPermissionAvailable(app)) {
service.addGpsStatusListener(getGpsStatusListener(service));
registerGpsStatusListener(service);
try {
service.requestLocationUpdates(LocationManager.GPS_PROVIDER, GPS_TIMEOUT_REQUEST, GPS_DIST_REQUEST, gpsListener);
} catch (IllegalArgumentException e) {
@ -291,17 +292,55 @@ public class OsmAndLocationProvider implements SensorEventListener {
}
}
private Listener getGpsStatusListener(final LocationManager service) {
gpsStatusListener = new Listener() {
private GpsStatus gpsStatus;
@Override
public void onGpsStatusChanged(int event) {
gpsStatus = service.getGpsStatus(gpsStatus);
updateGPSInfo(gpsStatus);
updateLocation(location);
}
};
return gpsStatusListener;
private void registerGpsStatusListener(final LocationManager service) {
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
gpsStatusListener = new GnssStatus.Callback() {
@Override
public void onStarted() {
}
@Override
public void onStopped() {
}
@Override
public void onFirstFix(int ttffMillis) {
}
@Override
public void onSatelliteStatusChanged(GnssStatus status) {
int satCount = 0;
boolean fixed = false;
int u = 0;
if(status != null) {
satCount = status.getSatelliteCount();
for (int i = 0; i < satCount; i++) {
if (status.usedInFix(i)) {
u++;
fixed = true;
}
}
}
gpsInfo.fixed = fixed;
gpsInfo.foundSatellites = satCount;
gpsInfo.usedSatellites = u;
updateLocation(location);
}
};
service.registerGnssStatusCallback((GnssStatus.Callback) gpsStatusListener);
} else {
gpsStatusListener = new Listener() {
private GpsStatus gpsStatus;
@Override
public void onGpsStatusChanged(int event) {
gpsStatus = service.getGpsStatus(gpsStatus);
updateGPSInfo(gpsStatus);
updateLocation(location);
}
};
service.addGpsStatusListener((Listener) gpsStatusListener);
}
}
private void updateGPSInfo(GpsStatus s) {
@ -642,7 +681,13 @@ public class OsmAndLocationProvider implements SensorEventListener {
private void stopLocationRequests() {
LocationManager service = (LocationManager) app.getSystemService(Context.LOCATION_SERVICE);
service.removeGpsStatusListener(gpsStatusListener);
if(gpsStatusListener != null) {
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
service.unregisterGnssStatusCallback((GnssStatus.Callback) gpsStatusListener);
} else {
service.removeGpsStatusListener((Listener) gpsStatusListener);
}
}
service.removeUpdates(gpsListener);
while(!networkListeners.isEmpty()) {
service.removeUpdates(networkListeners.poll());

View file

@ -1349,9 +1349,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;
}
@ -1373,6 +1372,29 @@ public class OsmandSettings {
public final OsmandPreference<AngularConstants> ANGULAR_UNITS = new EnumIntPreference<AngularConstants>(
"angular_measurement", AngularConstants.DEGREES, AngularConstants.values()).makeProfile();
public static final String LAST_START_LAT = "last_searched_lat"; //$NON-NLS-1$
public static final String LAST_START_LON = "last_searched_lon"; //$NON-NLS-1$
public LatLon getLastStartPoint() {
if (settingsAPI.contains(globalPreferences, LAST_START_LAT) && settingsAPI.contains(globalPreferences, LAST_START_LON)) {
return new LatLon(settingsAPI.getFloat(globalPreferences, LAST_START_LAT, 0),
settingsAPI.getFloat(globalPreferences, LAST_START_LON, 0));
}
return null;
}
public boolean setLastStartPoint(LatLon l) {
if (l == null) {
return settingsAPI.edit(globalPreferences).remove(LAST_START_LAT).remove(LAST_START_LON).commit();
} else {
return setLastStartPoint(l.getLatitude(), l.getLongitude());
}
}
public boolean setLastStartPoint(double lat, double lon) {
return settingsAPI.edit(globalPreferences).putFloat(LAST_START_LAT, (float) lat).
putFloat(LAST_START_LON, (float) lon).commit();
}
public final OsmandPreference<SpeedConstants> SPEED_SYSTEM = new EnumIntPreference<SpeedConstants>(
"default_speed_system", SpeedConstants.KILOMETERS_PER_HOUR, SpeedConstants.values()) {

View file

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

View file

@ -7,7 +7,6 @@ import android.view.WindowManager;
import net.osmand.Location;
import net.osmand.StateChangedListener;
import net.osmand.binary.BinaryMapDataObject;
import net.osmand.data.LatLon;
import net.osmand.data.RotatedTileBox;
import net.osmand.map.IMapLocationListener;
@ -28,6 +27,7 @@ import net.osmand.plus.views.AnimateDraggingMapThread;
import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.util.MapUtils;
import java.io.IOException;
import java.text.SimpleDateFormat;
@ -155,7 +155,7 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
return movingToMyLocation;
}
private void detectDrivingRegion(final LatLon latLon) {
public void detectDrivingRegion(final LatLon latLon) {
new DetectDrivingRegionTask(app).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, latLon);
}
@ -167,7 +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().checkAndUpdateStartLocation(location);
}
}
if (mapView != null) {
@ -444,7 +444,7 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
isUserZoomed = true;
}
private static class DetectDrivingRegionTask extends AsyncTask<LatLon, Void, BinaryMapDataObject> {
private static class DetectDrivingRegionTask extends AsyncTask<LatLon, Void, WorldRegion> {
private OsmandApplication app;
@ -453,10 +453,10 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
}
@Override
protected BinaryMapDataObject doInBackground(LatLon... latLons) {
protected WorldRegion doInBackground(LatLon... latLons) {
try {
if (latLons != null && latLons.length > 0) {
return app.getRegions().getSmallestBinaryMapDataObjectAt(latLons[0]);
return app.getRegions().getSmallestBinaryMapDataObjectAt(latLons[0]).getKey();
}
} catch (IOException e) {
// ignore
@ -465,13 +465,9 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
}
@Override
protected void onPostExecute(BinaryMapDataObject o) {
if (o != null) {
String fullName = app.getRegions().getFullName(o);
WorldRegion worldRegion = app.getRegions().getRegionData(fullName);
if (worldRegion != null) {
app.setupDrivingRegion(worldRegion);
}
protected void onPostExecute(WorldRegion worldRegion) {
if (worldRegion != null) {
app.setupDrivingRegion(worldRegion);
}
}
}

View file

@ -468,7 +468,7 @@ public class DownloadResources extends DownloadResourceGroup {
List<IndexItem> res = new ArrayList<>();
OsmandRegions regions = app.getRegions();
DownloadIndexesThread downloadThread = app.getDownloadThread();
List<WorldRegion> downloadRegions = regions.getWoldRegionsAt(latLon);
List<WorldRegion> downloadRegions = regions.getWorldRegionsAt(latLon);
for (WorldRegion downloadRegion : downloadRegions) {
if (includeDownloaded || !isIndexItemDownloaded(downloadThread, type, downloadRegion, res)) {
addIndexItem(downloadThread, type, downloadRegion, res);

View file

@ -1,7 +1,6 @@
package net.osmand.plus.download.ui;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.os.Bundle;
@ -32,7 +31,6 @@ import net.osmand.Collator;
import net.osmand.CollatorStringMatcher;
import net.osmand.OsmAndCollator;
import net.osmand.ResultMatcher;
import net.osmand.binary.BinaryMapDataObject;
import net.osmand.binary.BinaryMapIndexReader;
import net.osmand.binary.BinaryMapIndexReader.SearchRequest;
import net.osmand.data.Amenity;
@ -416,15 +414,13 @@ public class SearchDialogFragment extends DialogFragment implements DownloadEven
@Override
protected IndexItem doInBackground(Void... params) {
Amenity amenity = cityItem.getAmenity();
BinaryMapDataObject o = null;
WorldRegion downloadRegion = null;
try {
o = osmandRegions.getSmallestBinaryMapDataObjectAt(amenity.getLocation());
downloadRegion = osmandRegions.getSmallestBinaryMapDataObjectAt(amenity.getLocation()).getKey();
} catch (IOException e) {
// ignore
}
if (o != null) {
String selectedFullName = osmandRegions.getFullName(o);
WorldRegion downloadRegion = osmandRegions.getRegionData(selectedFullName);
if (downloadRegion != null) {
List<IndexItem> indexItems = ctx.getDownloadThread().getIndexes().getIndexItems(downloadRegion);
for (IndexItem item : indexItems) {
if (item.getType() == DownloadActivityType.NORMAL_FILE) {

View file

@ -39,6 +39,7 @@ public class RoutingHelper {
private static final org.apache.commons.logging.Log log = PlatformUtil.getLog(RoutingHelper.class);
private static final float POSITION_TOLERANCE = 60;
private static final int CACHE_RADIUS = 100000;
private List<WeakReference<IRouteInformationListener>> listeners = new LinkedList<>();
private List<WeakReference<IRoutingDataUpdateListener>> updateListeners = new LinkedList<>();
@ -173,6 +174,7 @@ public class RoutingHelper {
}
public synchronized void setFinalAndCurrentLocation(LatLon finalLocation, List<LatLon> intermediatePoints, Location currentLocation){
checkAndUpdateStartLocation(currentLocation);
RouteCalculationResult previousRoute = route;
clearCurrentRoute(finalLocation, intermediatePoints);
// to update route
@ -259,6 +261,17 @@ public class RoutingHelper {
public LatLon getFinalLocation() {
return finalLocation;
}
public void checkAndUpdateStartLocation(Location nextStartLocation) {
checkAndUpdateStartLocation(new LatLon(nextStartLocation.getLatitude(), nextStartLocation.getLongitude()));
}
public void checkAndUpdateStartLocation(LatLon newStartLocation) {
LatLon lastStartLocation = app.getSettings().getLastStartPoint();
if (lastStartLocation == null || MapUtils.getDistance(newStartLocation, lastStartLocation) > CACHE_RADIUS) {
app.getMapViewTrackingUtilities().detectDrivingRegion(newStartLocation);
app.getSettings().setLastStartPoint(newStartLocation);
}
}
public List<LatLon> getIntermediatePoints() {
return intermediatePoints;

View file

@ -45,8 +45,10 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
@ -250,7 +252,7 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements IContextMe
&& zoom >= ZOOM_MIN_TO_SHOW_DOWNLOAD_DIALOG && zoom <= ZOOM_MAX_TO_SHOW_DOWNLOAD_DIALOG
&& currentObjects != null) {
WorldRegion regionData;
List<BinaryMapDataObject> selectedObjects = new ArrayList<>();
Map<WorldRegion, BinaryMapDataObject> selectedObjects = new LinkedHashMap<>();
for (int i = 0; i < currentObjects.size(); i++) {
final BinaryMapDataObject o = currentObjects.get(i);
String fullName = osmandRegions.getFullName(o);
@ -262,7 +264,7 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements IContextMe
hideDownloadMapToolbar();
return;
} else {
selectedObjects.add(o);
selectedObjects.put(regionData, o);
}
}
}
@ -270,11 +272,8 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements IContextMe
IndexItem indexItem = null;
String name = null;
BinaryMapDataObject smallestRegion = app.getRegions().getSmallestBinaryMapDataObjectAt(selectedObjects);
if (smallestRegion != null) {
String fullName = osmandRegions.getFullName(smallestRegion);
regionData = osmandRegions.getRegionData(fullName);
regionData = app.getRegions().getSmallestBinaryMapDataObjectAt(selectedObjects).getKey();
if (regionData != null) {
DownloadIndexesThread downloadThread = app.getDownloadThread();
List<IndexItem> indexItems = downloadThread.getIndexes().getIndexItems(regionData);
if (indexItems.size() == 0) {

View file

@ -107,7 +107,7 @@ public class WikiArticleHelper {
List<WorldRegion> regions = null;
if (articleLatLon != null) {
try {
regions = application.getRegions().getWoldRegionsAt(articleLatLon);
regions = application.getRegions().getWorldRegionsAt(articleLatLon);
} catch (IOException e) {
Log.e(TAG, e.getMessage(), e);
}