Issue 293. Suggest user to use vector maps

This commit is contained in:
Victor Shcherb 2011-06-13 14:06:15 +02:00
parent b8599506d4
commit 6527eba2f4
10 changed files with 71 additions and 17 deletions

View file

@ -126,6 +126,19 @@ public class BinaryMapIndexReader {
return mapIndexes.size() > 0;
}
public boolean containsMapData(int tile31x, int tile31y, int zoom){
for(MapIndex mapIndex : mapIndexes){
for(MapRoot root : mapIndex.getRoots()){
if (root.minZoom <= zoom && root.maxZoom >= zoom) {
if (tile31x >= root.left && tile31x <= root.right && root.top <= tile31y && root.bottom >= tile31y) {
return true;
}
}
}
}
return false;
}
public boolean containsAddressData(){
return addressIndexes.size() > 0;
}

View file

@ -2,7 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.osmand.plus" android:installLocation="auto" android:versionName="0.6.5" android:versionCode="34">
<application android:icon="@drawable/icon" android:label="@string/app_name"
android:debuggable="false" android:name=".activities.OsmandApplication" android:description="@string/app_description">
android:debuggable="true" android:name=".activities.OsmandApplication" android:description="@string/app_description">
<activity android:name=".activities.MainMenuActivity"
android:label="@string/app_name">
<intent-filter>

View file

@ -1,6 +1,8 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<resources>
<string name="switch_to_raster_map_to_see">Vector maps doesn\'t contain that place, you can switch source in menu (Layers -> Map Source... -> Vector OSM maps) to see the map.</string>
<string name="switch_to_vector_map_to_see">You can switch to vector maps using menu (Layers -> Map Source... -> Vector OSM maps) to see the map.</string>
<string name="binary_map_download_success">Successful. You can switch to vector maps on menu Layers -> Map Source... -> Vector OSM maps.</string>
<string name="choose_audio_stream">Voice guidance stream</string>
<string name="choose_audio_stream_descr">Choose channel to provide voice guidance (depends on system configuration)</string>
<string name="voice_stream_voice_call">Voice call stream</string>

View file

@ -545,7 +545,7 @@ public class DownloadIndexActivity extends ListActivity {
is.close();
}
}
if(length != fileread){
if(length != fileread || length == 0){
throw new IOException("File was not fully read"); //$NON-NLS-1$
}
@ -643,6 +643,11 @@ public class DownloadIndexActivity extends ListActivity {
manager.indexingPoi(progress, warnings, toIndex);
} else if (toIndex.getName().endsWith(IndexConstants.BINARY_MAP_INDEX_EXT)) {
warnings.addAll(manager.indexingMaps(progress));
if(warnings.isEmpty() && !OsmandSettings.getOsmandSettings(getApplicationContext()).MAP_VECTOR_DATA.get()){
warnings.add(getString(R.string.binary_map_download_success));
// Is it proper way to switch every tome to vector data?
OsmandSettings.getOsmandSettings(getApplicationContext()).MAP_VECTOR_DATA.set(true);
}
} else if (toIndex.getName().endsWith(IndexConstants.VOICE_INDEX_EXT_ZIP)) {
}
if(dateModified != null){

View file

@ -92,10 +92,10 @@ public class MapActivityLayers {
RoutingHelper routingHelper = ((OsmandApplication) getApplication()).getRoutingHelper();
underlayLayer = new MapTileLayer();
underlayLayer = new MapTileLayer(false);
// mapView.addLayer(underlayLayer, -0.5f);
mapTileLayer = new MapTileLayer();
mapTileLayer = new MapTileLayer(true);
mapView.addLayer(mapTileLayer, 0.0f);
mapView.setMainLayer(mapTileLayer);
@ -103,7 +103,7 @@ public class MapActivityLayers {
mapVectorLayer = new MapVectorLayer(mapTileLayer);
mapView.addLayer(mapVectorLayer, 0.5f);
overlayLayer = new MapTileLayer();
overlayLayer = new MapTileLayer(false);
// mapView.addLayer(overlayLayer, 0.7f);
// 0.9 gpx layer

View file

@ -142,6 +142,17 @@ public class MapRenderRepositories {
}
}
public boolean containsLatLonMapData(double lat, double lon, int zoom) {
int x = MapUtils.get31TileNumberX(lon);
int y = MapUtils.get31TileNumberY(lat);
for (BinaryMapIndexReader reader : files.values()) {
if (reader.containsMapData(x, y, zoom)) {
return true;
}
}
return false;
}
public void clearAllResources(){
clearCache();
for(String f : new ArrayList<String>(files.keySet())){

View file

@ -1,6 +1,7 @@
package net.osmand.plus.render;
import net.osmand.osm.MapUtils;
import net.osmand.plus.R;
import net.osmand.plus.ResourceManager;
import net.osmand.plus.RotatedTileBox;
import net.osmand.plus.views.BaseMapLayer;
@ -12,6 +13,7 @@ import android.graphics.Paint;
import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.RectF;
import android.widget.Toast;
public class MapVectorLayer extends BaseMapLayer {
@ -99,8 +101,17 @@ public class MapVectorLayer extends BaseMapLayer {
pixRect.set(-view.getWidth()/3, -view.getHeight() / 4, 4 * view.getWidth() /3, 5 * view.getHeight() / 4);
updateRotatedTileBox();
resourceManager.updateRendererMap(rotatedTileBox);
// does it slow down Map refreshing ?
// Arguments : 1. Map request to read data slows whole process // 2. It works in operating memory
if(!warningToSwitchMapShown){
if(!resourceManager.getRenderer().containsLatLonMapData(view.getLatitude(), view.getLongitude(), view.getZoom())){
Toast.makeText(view.getContext(), R.string.switch_to_raster_map_to_see, Toast.LENGTH_LONG).show();
warningToSwitchMapShown = true;
}
}
}
}
MapRenderRepositories renderer = resourceManager.getRenderer();
Bitmap bmp = renderer.getBitmap();

View file

@ -3,6 +3,7 @@ package net.osmand.plus.views;
public abstract class BaseMapLayer implements OsmandMapLayer {
private int alpha = 255;
protected boolean warningToSwitchMapShown = false;
public int getMaximumShownMapZoom(){
return 21;

View file

@ -2,6 +2,7 @@ package net.osmand.plus.views;
import net.osmand.map.ITileSource;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.ResourceManager;
import android.graphics.Bitmap;
import android.graphics.Canvas;
@ -10,16 +11,17 @@ import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.RectF;
import android.util.FloatMath;
import android.widget.Toast;
public class MapTileLayer extends BaseMapLayer {
protected final int emptyTileDivisor = 16;
public static final int OVERZOOM_IN = 2;
private final boolean mainMap;
protected ITileSource map = null;
Paint paintBitmap;
protected RectF tilesRect = new RectF();
protected RectF latlonRect = new RectF();
protected RectF bitmapToDraw = new RectF();
@ -31,6 +33,11 @@ public class MapTileLayer extends BaseMapLayer {
private OsmandSettings settings;
private boolean visible = true;
public MapTileLayer(boolean mainMap){
this.mainMap = mainMap;
}
@Override
public boolean drawInScreenPixels() {
return false;
@ -93,19 +100,10 @@ public class MapTileLayer extends BaseMapLayer {
&& settings.isInternetConnectionAvailable() && map.couldBeDownloadedFromInternet();
int maxLevel = Math.min(view.getSettings().MAX_LEVEL_TO_DOWNLOAD_TILE.get(), map.getMaximumZoomSupported());
int tileSize = map.getTileSize();
boolean oneTileShown = false;
for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) {
// int leftPlusI = (int) FloatMath.floor((float) MapUtils
// .getTileNumberX(nzoom, MapUtils.getLongitudeFromTile(nzoom, left + i)));
// float topTileY;
// if(map.isEllipticYTile()){
// topTileY = (float) MapUtils.getTileEllipsoidNumberY(nzoom, MapUtils.getLatitudeFromEllipsoidTileY(nzoom, top + j));
// } else {
// topTileY = (float) MapUtils.getTileNumberY(nzoom, MapUtils.getLatitudeFromTile(nzoom, top + j));
// }
// int topPlusJ = (int) FloatMath.floor(topTileY);
int leftPlusI = left + i;
int topPlusJ = top + j;
float x1 = (left + i - tileX) * ftileSize + w;
@ -149,14 +147,23 @@ public class MapTileLayer extends BaseMapLayer {
bitmapToZoom.set(xZoom, yZoom, xZoom + tileSize / div, yZoom + tileSize / div);
bitmapToDraw.set(x1, y1, x1 + ftileSize, y1 + ftileSize);
canvas.drawBitmap(bmp, bitmapToZoom, bitmapToDraw, paintBitmap);
oneTileShown = true;
}
} else {
bitmapToZoom.set(0, 0, tileSize, tileSize);
bitmapToDraw.set(x1, y1, x1 + ftileSize, y1 + ftileSize);
canvas.drawBitmap(bmp, bitmapToZoom, bitmapToDraw, paintBitmap);
oneTileShown = true;
}
}
}
if(mainMap && !oneTileShown && !useInternet && !warningToSwitchMapShown){
if(resourceManager.getRenderer().containsLatLonMapData(view.getLatitude(), view.getLongitude(), nzoom)){
Toast.makeText(view.getContext(), R.string.switch_to_vector_map_to_see, Toast.LENGTH_LONG).show();
warningToSwitchMapShown = true;
}
}
}
public int getSourceTileSize() {

View file

@ -29,6 +29,10 @@ public class YandexTrafficLayer extends MapTileLayer {
private String mTimestamp = null;
private boolean updateThreadRan = false;
public YandexTrafficLayer() {
super(false);
}
public void setVisible(boolean visible) {
if(isVisible() != visible){
if(visible){