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:
Victor Shcherb 2010-06-26 12:16:50 +00:00
parent 4b28955204
commit 703e2a2789
8 changed files with 48 additions and 15 deletions

View file

@ -17,14 +17,14 @@ public class ToDoConstants {
// TODO ANDROID
// 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).
// 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
// 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
// [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]
@ -58,6 +58,8 @@ public class ToDoConstants {
// 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)
// 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

View file

@ -211,9 +211,9 @@ public class MapUtils {
if(meters >= 100000){
return meters / 1000 + " " + Messages.getMessage(Messages.KEY_KM); //$NON-NLS-1$
} 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){
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 {
return meters + " "+Messages.getMessage(Messages.KEY_M); //$NON-NLS-1$
}

View file

@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="max_level_download_tile">Уровень детализация</string>
<string name="max_level_download_tile_descr">Выберите максимальный уровень для загрузки из интернета</string>
<string name="route_about">О маршруте</string>
<string name="route_general_information">Общая протяженность = {0}, время в пути = ''{1}''.</string>
<string name="router_service_descr">Выберите сервис для прокладки маршрута</string>

View file

@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<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_general_information">Overall distance = {0}, travelling time = ''{1}''.</string>
<string name="router_service_descr">Choose routing service</string>

View file

@ -7,6 +7,7 @@
<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>
<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: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>

View file

@ -191,6 +191,14 @@ public class OsmandSettings {
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
public static final String MAP_VIEW_3D = "map_view_3d"; //$NON-NLS-1$

View file

@ -48,6 +48,7 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
private Preference reloadIndexes;
private Preference downloadIndexes;
private ListPreference routerPreference;
private ListPreference maxLevelToDownload;
@Override
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.setOnPreferenceChangeListener(this);
maxLevelToDownload =(ListPreference) screen.findPreference(OsmandSettings.MAX_LEVEL_TO_DOWNLOAD_TILE);
maxLevelToDownload.setOnPreferenceChangeListener(this);
tileSourcePreference =(ListPreference) screen.findPreference(OsmandSettings.MAP_TILE_SOURCES);
tileSourcePreference.setOnPreferenceChangeListener(this);
routerPreference =(ListPreference) screen.findPreference(OsmandSettings.ROUTER_SERVICE);
@ -156,6 +159,16 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
routerPreference.setEntryValues(entries);
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();
entries = new String[list.size()];
@ -220,6 +233,9 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
} else if(preference == positionOnMap){
edit.putInt(OsmandSettings.POSITION_ON_MAP, positionOnMap.findIndexOfValue((String) newValue));
edit.commit();
} else if (preference == maxLevelToDownload) {
edit.putInt(OsmandSettings.MAX_LEVEL_TO_DOWNLOAD_TILE, Integer.parseInt((String) newValue));
edit.commit();
} else if (preference == routerPreference) {
RouteService s = null;
for(RouteService r : RouteService.values()){

View file

@ -373,6 +373,7 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
if (canvas != null) {
ResourceManager mgr = ResourceManager.getResourceManager();
boolean useInternet = OsmandSettings.isUsingInternetToDownloadTiles(getContext());
int maxLevel = OsmandSettings.getMaximumLevelToDownloadTile(getContext());
canvas.save();
canvas.rotate(rotate, w , h);
boundsRect.set(0, 0, getWidth(), getHeight());
@ -390,7 +391,8 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
// asking tile image async
boolean imgExist = mgr.tileExistOnFileSystem(ordImgTile);
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);
}
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)
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);
if(useInternet || imgExist){
if(originalBeLoaded || imgExist){
bmp = mgr.getTileImageFromCache(imgTile2);
div = 2;
if(bmp == null){
@ -406,12 +408,12 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
div = 4;
}
}
if(!useInternet && !imgExist){
if(mgr.tileExistOnFileSystem(imgTile2)){
bmp = mgr.getTileImageForMapAsync(imgTile2, map, (left + i) / 2, (top + j) / 2, zoom - 1, false);
if(!originalBeLoaded && !imgExist){
if (mgr.tileExistOnFileSystem(imgTile2) || (useInternet && zoom - 1 <= maxLevel)) {
bmp = mgr.getTileImageForMapAsync(imgTile2, map, (left + i) / 2, (top + j) / 2, zoom - 1, useInternet);
div = 2;
} else if(mgr.tileExistOnFileSystem(imgTile4)){
bmp = mgr.getTileImageForMapAsync(imgTile4, map, (left + i) / 4, (top + j) / 4, zoom - 2, false);
} else if (mgr.tileExistOnFileSystem(imgTile4) || (useInternet && zoom - 2 <= maxLevel)) {
bmp = mgr.getTileImageForMapAsync(imgTile4, map, (left + i) / 4, (top + j) / 4, zoom - 2, useInternet);
div = 4;
}
}