implement max level to download
git-svn-id: https://osmand.googlecode.com/svn/trunk@207 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
This commit is contained in:
parent
4b28955204
commit
703e2a2789
8 changed files with 48 additions and 15 deletions
|
@ -17,14 +17,14 @@ public class ToDoConstants {
|
||||||
// TODO ANDROID
|
// TODO ANDROID
|
||||||
// 42. Revise UI (icons/layouts). Support different devices. Add inactive/focus(!) icon versions.
|
// 42. Revise UI (icons/layouts). Support different devices. Add inactive/focus(!) icon versions.
|
||||||
// Some icons are not fine (as back menu from map - it is blured).
|
// Some icons are not fine (as back menu from map - it is blured).
|
||||||
|
// Got by Andrei
|
||||||
|
|
||||||
// 46. Implement downloading strategy for tiles : select max zoom to download [16,15,14,...]
|
|
||||||
// That means you can save internet because from [16 -> zoom -> 18], [14 -> zoom -> 16 - suitable for speed > 40], ...
|
|
||||||
|
|
||||||
// 61. Provide route information for YOURS (calclate turns/angle/expected time)
|
|
||||||
// 60. Audio guidance for routing
|
|
||||||
// 58. Upload/Download zip-index from site & unzip them on phone
|
|
||||||
// 50. Invent opening hours editor in order to edit POI hours better on device
|
// 50. Invent opening hours editor in order to edit POI hours better on device
|
||||||
|
// GOT by Olga
|
||||||
|
|
||||||
|
// 60. Audio guidance for routing
|
||||||
|
// 61. Provide route information for YOURS (calclate turns/angle/expected time)
|
||||||
|
// 58. Upload/Download zip-index from site & unzip them on phone
|
||||||
// 53. Add progress bars : to internet communication activities [editing/commiting/deleting poi], do not hide edit poi dialog if operation failed
|
// 53. Add progress bars : to internet communication activities [editing/commiting/deleting poi], do not hide edit poi dialog if operation failed
|
||||||
// [move close buttons from alertdialog to own view]
|
// [move close buttons from alertdialog to own view]
|
||||||
// 55. Update POI data from internet for selected area [suggest to create new POI index or extend exising of none exist]
|
// 55. Update POI data from internet for selected area [suggest to create new POI index or extend exising of none exist]
|
||||||
|
@ -58,6 +58,8 @@ public class ToDoConstants {
|
||||||
// 57. Implement routing information about expected time arriving
|
// 57. Implement routing information about expected time arriving
|
||||||
// 58. Implement difference about show route/follow route (show travel time/arrival time, show mini map/next turn, etc)
|
// 58. Implement difference about show route/follow route (show travel time/arrival time, show mini map/next turn, etc)
|
||||||
// 59. Show route information (directions/time, ....). Now is shown in context menu route (about route)
|
// 59. Show route information (directions/time, ....). Now is shown in context menu route (about route)
|
||||||
|
// 46. Implement downloading strategy for tiles : select max zoom to download [16,15,14,...]
|
||||||
|
// That means you can save internet because from [16 -> zoom -> 18], [14 -> zoom -> 16 - suitable for speed > 40], ...
|
||||||
|
|
||||||
// DONE SWING
|
// DONE SWING
|
||||||
|
|
||||||
|
|
|
@ -211,9 +211,9 @@ public class MapUtils {
|
||||||
if(meters >= 100000){
|
if(meters >= 100000){
|
||||||
return meters / 1000 + " " + Messages.getMessage(Messages.KEY_KM); //$NON-NLS-1$
|
return meters / 1000 + " " + Messages.getMessage(Messages.KEY_KM); //$NON-NLS-1$
|
||||||
} else if(meters >= 10000){
|
} else if(meters >= 10000){
|
||||||
return MessageFormat.format("{0, number, #.#} "+Messages.getMessage(Messages.KEY_KM), ((float) meters) / 1000); //$NON-NLS-1$
|
return MessageFormat.format("{0,number,#.#} "+Messages.getMessage(Messages.KEY_KM), ((float) meters) / 1000); //$NON-NLS-1$
|
||||||
} else if(meters > 1500){
|
} else if(meters > 1500){
|
||||||
return MessageFormat.format("{0, number, #.##}"+Messages.getMessage(Messages.KEY_KM), ((float) meters) / 1000); //$NON-NLS-1$
|
return MessageFormat.format("{0,number,#.##}"+Messages.getMessage(Messages.KEY_KM), ((float) meters) / 1000); //$NON-NLS-1$
|
||||||
} else {
|
} else {
|
||||||
return meters + " "+Messages.getMessage(Messages.KEY_M); //$NON-NLS-1$
|
return meters + " "+Messages.getMessage(Messages.KEY_M); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
<string name="max_level_download_tile">Уровень детализация</string>
|
||||||
|
<string name="max_level_download_tile_descr">Выберите максимальный уровень для загрузки из интернета</string>
|
||||||
<string name="route_about">О маршруте</string>
|
<string name="route_about">О маршруте</string>
|
||||||
<string name="route_general_information">Общая протяженность = {0}, время в пути = ''{1}''.</string>
|
<string name="route_general_information">Общая протяженность = {0}, время в пути = ''{1}''.</string>
|
||||||
<string name="router_service_descr">Выберите сервис для прокладки маршрута</string>
|
<string name="router_service_descr">Выберите сервис для прокладки маршрута</string>
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
<string name="max_level_download_tile">Max zoom level</string>
|
||||||
|
<string name="max_level_download_tile_descr">Choose max zoom level to download using internet</string>
|
||||||
<string name="route_about">About route</string>
|
<string name="route_about">About route</string>
|
||||||
<string name="route_general_information">Overall distance = {0}, travelling time = ''{1}''.</string>
|
<string name="route_general_information">Overall distance = {0}, travelling time = ''{1}''.</string>
|
||||||
<string name="router_service_descr">Choose routing service</string>
|
<string name="router_service_descr">Choose routing service</string>
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
<PreferenceScreen android:title="@string/map_preferences" android:summary="@string/map_preferences_descr">
|
<PreferenceScreen android:title="@string/map_preferences" android:summary="@string/map_preferences_descr">
|
||||||
<CheckBoxPreference android:key="use_internet_to_download_tiles" android:title="@string/use_internet" android:summary="@string/use_internet_to_download_tile"></CheckBoxPreference>
|
<CheckBoxPreference android:key="use_internet_to_download_tiles" android:title="@string/use_internet" android:summary="@string/use_internet_to_download_tile"></CheckBoxPreference>
|
||||||
<ListPreference android:title="@string/map_tile_source" android:summary="@string/map_tile_source_descr" android:key="map_tile_sources"></ListPreference>
|
<ListPreference android:title="@string/map_tile_source" android:summary="@string/map_tile_source_descr" android:key="map_tile_sources"></ListPreference>
|
||||||
|
<ListPreference android:title="@string/max_level_download_tile" android:summary="@string/max_level_download_tile_descr" android:key="max_level_download_tile"></ListPreference>
|
||||||
<CheckBoxPreference android:key="show_poi_over_map" android:title="@string/show_poi_over_map" android:summary="@string/show_poi_over_map_description"></CheckBoxPreference>
|
<CheckBoxPreference android:key="show_poi_over_map" android:title="@string/show_poi_over_map" android:summary="@string/show_poi_over_map_description"></CheckBoxPreference>
|
||||||
<CheckBoxPreference android:title="@string/auto_zoom_map" android:summary="@string/auto_zoom_map_descr" android:key="auto_zoom_map"></CheckBoxPreference>
|
<CheckBoxPreference android:title="@string/auto_zoom_map" android:summary="@string/auto_zoom_map_descr" android:key="auto_zoom_map"></CheckBoxPreference>
|
||||||
<CheckBoxPreference android:key="show_view_angle" android:title="@string/show_view_angle" android:summary="@string/show_view_angle_descr"></CheckBoxPreference>
|
<CheckBoxPreference android:key="show_view_angle" android:title="@string/show_view_angle" android:summary="@string/show_view_angle_descr"></CheckBoxPreference>
|
||||||
|
|
|
@ -190,6 +190,14 @@ public class OsmandSettings {
|
||||||
SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE);
|
SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE);
|
||||||
return prefs.getInt(POSITION_ON_MAP, CENTER_CONSTANT);
|
return prefs.getInt(POSITION_ON_MAP, CENTER_CONSTANT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// this value string is synchronized with settings_pref.xml preference name
|
||||||
|
public static final String MAX_LEVEL_TO_DOWNLOAD_TILE = "max_level_download_tile"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
public static int getMaximumLevelToDownloadTile(Context ctx) {
|
||||||
|
SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE);
|
||||||
|
return prefs.getInt(MAX_LEVEL_TO_DOWNLOAD_TILE, 18);
|
||||||
|
}
|
||||||
|
|
||||||
// this value string is synchronized with settings_pref.xml preference name
|
// this value string is synchronized with settings_pref.xml preference name
|
||||||
public static final String MAP_VIEW_3D = "map_view_3d"; //$NON-NLS-1$
|
public static final String MAP_VIEW_3D = "map_view_3d"; //$NON-NLS-1$
|
||||||
|
|
|
@ -48,6 +48,7 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
|
||||||
private Preference reloadIndexes;
|
private Preference reloadIndexes;
|
||||||
private Preference downloadIndexes;
|
private Preference downloadIndexes;
|
||||||
private ListPreference routerPreference;
|
private ListPreference routerPreference;
|
||||||
|
private ListPreference maxLevelToDownload;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -93,6 +94,8 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
|
||||||
|
|
||||||
positionOnMap =(ListPreference) screen.findPreference(OsmandSettings.POSITION_ON_MAP);
|
positionOnMap =(ListPreference) screen.findPreference(OsmandSettings.POSITION_ON_MAP);
|
||||||
positionOnMap.setOnPreferenceChangeListener(this);
|
positionOnMap.setOnPreferenceChangeListener(this);
|
||||||
|
maxLevelToDownload =(ListPreference) screen.findPreference(OsmandSettings.MAX_LEVEL_TO_DOWNLOAD_TILE);
|
||||||
|
maxLevelToDownload.setOnPreferenceChangeListener(this);
|
||||||
tileSourcePreference =(ListPreference) screen.findPreference(OsmandSettings.MAP_TILE_SOURCES);
|
tileSourcePreference =(ListPreference) screen.findPreference(OsmandSettings.MAP_TILE_SOURCES);
|
||||||
tileSourcePreference.setOnPreferenceChangeListener(this);
|
tileSourcePreference.setOnPreferenceChangeListener(this);
|
||||||
routerPreference =(ListPreference) screen.findPreference(OsmandSettings.ROUTER_SERVICE);
|
routerPreference =(ListPreference) screen.findPreference(OsmandSettings.ROUTER_SERVICE);
|
||||||
|
@ -156,6 +159,16 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
|
||||||
routerPreference.setEntryValues(entries);
|
routerPreference.setEntryValues(entries);
|
||||||
routerPreference.setValue(entry);
|
routerPreference.setValue(entry);
|
||||||
|
|
||||||
|
int startZoom = 12;
|
||||||
|
int endZoom = 19;
|
||||||
|
entries = new String[endZoom - startZoom + 1];
|
||||||
|
for (int i = startZoom; i <= endZoom; i++) {
|
||||||
|
entries[i - startZoom] = i + ""; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
maxLevelToDownload.setEntries(entries);
|
||||||
|
maxLevelToDownload.setEntryValues(entries);
|
||||||
|
maxLevelToDownload.setValue(OsmandSettings.getMaximumLevelToDownloadTile(this)+""); //$NON-NLS-1$
|
||||||
|
|
||||||
|
|
||||||
List<TileSourceTemplate> list = TileSourceManager.getKnownSourceTemplates();
|
List<TileSourceTemplate> list = TileSourceManager.getKnownSourceTemplates();
|
||||||
entries = new String[list.size()];
|
entries = new String[list.size()];
|
||||||
|
@ -220,6 +233,9 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
|
||||||
} else if(preference == positionOnMap){
|
} else if(preference == positionOnMap){
|
||||||
edit.putInt(OsmandSettings.POSITION_ON_MAP, positionOnMap.findIndexOfValue((String) newValue));
|
edit.putInt(OsmandSettings.POSITION_ON_MAP, positionOnMap.findIndexOfValue((String) newValue));
|
||||||
edit.commit();
|
edit.commit();
|
||||||
|
} else if (preference == maxLevelToDownload) {
|
||||||
|
edit.putInt(OsmandSettings.MAX_LEVEL_TO_DOWNLOAD_TILE, Integer.parseInt((String) newValue));
|
||||||
|
edit.commit();
|
||||||
} else if (preference == routerPreference) {
|
} else if (preference == routerPreference) {
|
||||||
RouteService s = null;
|
RouteService s = null;
|
||||||
for(RouteService r : RouteService.values()){
|
for(RouteService r : RouteService.values()){
|
||||||
|
|
|
@ -373,6 +373,7 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
||||||
if (canvas != null) {
|
if (canvas != null) {
|
||||||
ResourceManager mgr = ResourceManager.getResourceManager();
|
ResourceManager mgr = ResourceManager.getResourceManager();
|
||||||
boolean useInternet = OsmandSettings.isUsingInternetToDownloadTiles(getContext());
|
boolean useInternet = OsmandSettings.isUsingInternetToDownloadTiles(getContext());
|
||||||
|
int maxLevel = OsmandSettings.getMaximumLevelToDownloadTile(getContext());
|
||||||
canvas.save();
|
canvas.save();
|
||||||
canvas.rotate(rotate, w , h);
|
canvas.rotate(rotate, w , h);
|
||||||
boundsRect.set(0, 0, getWidth(), getHeight());
|
boundsRect.set(0, 0, getWidth(), getHeight());
|
||||||
|
@ -390,7 +391,8 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
||||||
// asking tile image async
|
// asking tile image async
|
||||||
boolean imgExist = mgr.tileExistOnFileSystem(ordImgTile);
|
boolean imgExist = mgr.tileExistOnFileSystem(ordImgTile);
|
||||||
Bitmap bmp = null;
|
Bitmap bmp = null;
|
||||||
if (imgExist || useInternet) {
|
boolean originalBeLoaded = useInternet && zoom <= maxLevel;
|
||||||
|
if (imgExist || originalBeLoaded) {
|
||||||
bmp = mgr.getTileImageForMapAsync(ordImgTile, map, left + i, top + j, zoom, useInternet);
|
bmp = mgr.getTileImageForMapAsync(ordImgTile, map, left + i, top + j, zoom, useInternet);
|
||||||
}
|
}
|
||||||
if (bmp == null) {
|
if (bmp == null) {
|
||||||
|
@ -398,7 +400,7 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
||||||
// asking if there is small version of the map (in cache)
|
// asking if there is small version of the map (in cache)
|
||||||
String imgTile2 = mgr.calculateTileId(map, (left + i) / 2, (top + j) / 2, zoom - 1);
|
String imgTile2 = mgr.calculateTileId(map, (left + i) / 2, (top + j) / 2, zoom - 1);
|
||||||
String imgTile4 = mgr.calculateTileId(map, (left + i) / 4, (top + j) / 4, zoom - 2);
|
String imgTile4 = mgr.calculateTileId(map, (left + i) / 4, (top + j) / 4, zoom - 2);
|
||||||
if(useInternet || imgExist){
|
if(originalBeLoaded || imgExist){
|
||||||
bmp = mgr.getTileImageFromCache(imgTile2);
|
bmp = mgr.getTileImageFromCache(imgTile2);
|
||||||
div = 2;
|
div = 2;
|
||||||
if(bmp == null){
|
if(bmp == null){
|
||||||
|
@ -406,12 +408,12 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
||||||
div = 4;
|
div = 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!useInternet && !imgExist){
|
if(!originalBeLoaded && !imgExist){
|
||||||
if(mgr.tileExistOnFileSystem(imgTile2)){
|
if (mgr.tileExistOnFileSystem(imgTile2) || (useInternet && zoom - 1 <= maxLevel)) {
|
||||||
bmp = mgr.getTileImageForMapAsync(imgTile2, map, (left + i) / 2, (top + j) / 2, zoom - 1, false);
|
bmp = mgr.getTileImageForMapAsync(imgTile2, map, (left + i) / 2, (top + j) / 2, zoom - 1, useInternet);
|
||||||
div = 2;
|
div = 2;
|
||||||
} else if(mgr.tileExistOnFileSystem(imgTile4)){
|
} else if (mgr.tileExistOnFileSystem(imgTile4) || (useInternet && zoom - 2 <= maxLevel)) {
|
||||||
bmp = mgr.getTileImageForMapAsync(imgTile4, map, (left + i) / 4, (top + j) / 4, zoom - 2, false);
|
bmp = mgr.getTileImageForMapAsync(imgTile4, map, (left + i) / 4, (top + j) / 4, zoom - 2, useInternet);
|
||||||
div = 4;
|
div = 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue