From e1607267f498449f30ea6f760788789b347bfb3f Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Tue, 20 Jul 2010 12:28:33 +0000 Subject: [PATCH] Implement some fixes git-svn-id: https://osmand.googlecode.com/svn/trunk@375 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8 --- DataExtractionOSM/src/com/osmand/ToDoConstants.java | 3 ++- OsmAnd/AndroidManifest.xml | 2 +- OsmAnd/src/com/osmand/ResourceManager.java | 2 +- OsmAnd/src/com/osmand/SQLiteTileSource.java | 8 ++++++++ OsmAnd/src/com/osmand/activities/MapActivity.java | 1 + .../com/osmand/views/AnimateDraggingMapThread.java | 8 ++++++++ OsmAnd/src/com/osmand/views/OsmandMapTileView.java | 11 +++++++++++ 7 files changed, 32 insertions(+), 3 deletions(-) diff --git a/DataExtractionOSM/src/com/osmand/ToDoConstants.java b/DataExtractionOSM/src/com/osmand/ToDoConstants.java index 6d4db65870..fceade3e31 100644 --- a/DataExtractionOSM/src/com/osmand/ToDoConstants.java +++ b/DataExtractionOSM/src/com/osmand/ToDoConstants.java @@ -16,7 +16,8 @@ public class ToDoConstants { // Improvement : show favorites on the map? // Improvement : progress while loading tiles - // Improvement : download with wget + // Improvement : download with wget or multi downloader + // Improvement : use NameFinder for search POI/address near location // Imrpovement : show vehicle for calculating route // Improvement : show detailed route on the map with turns and show route information directly (like in gmaps) diff --git a/OsmAnd/AndroidManifest.xml b/OsmAnd/AndroidManifest.xml index 3cfee4e219..773f869f7d 100644 --- a/OsmAnd/AndroidManifest.xml +++ b/OsmAnd/AndroidManifest.xml @@ -2,7 +2,7 @@ + android:debuggable="true" android:name=".activities.OsmandApplication" android:description="@string/app_description"> diff --git a/OsmAnd/src/com/osmand/ResourceManager.java b/OsmAnd/src/com/osmand/ResourceManager.java index 03166713b7..dc78c00b9f 100644 --- a/OsmAnd/src/com/osmand/ResourceManager.java +++ b/OsmAnd/src/com/osmand/ResourceManager.java @@ -127,7 +127,7 @@ public class ResourceManager { return getTileImageForMap(file, map, x, y, zoom, loadFromInternetIfNeeded, true, true); } - public synchronized void tileDownloaded(DownloadRequest request){ + public void tileDownloaded(DownloadRequest request){ if(request instanceof TileLoadDownloadRequest){ TileLoadDownloadRequest req = ((TileLoadDownloadRequest) request); imagesOnFS.put(req.tileId, Boolean.TRUE); diff --git a/OsmAnd/src/com/osmand/SQLiteTileSource.java b/OsmAnd/src/com/osmand/SQLiteTileSource.java index db828f735d..15c2ef5937 100644 --- a/OsmAnd/src/com/osmand/SQLiteTileSource.java +++ b/OsmAnd/src/com/osmand/SQLiteTileSource.java @@ -5,6 +5,8 @@ import java.io.FileInputStream; import java.io.IOException; import java.nio.ByteBuffer; +import org.apache.commons.logging.Log; + import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteStatement; @@ -18,6 +20,8 @@ public class SQLiteTileSource implements ITileSource { public static final String EXT = ".sqlitedb"; //$NON-NLS-1$ + private static final Log log = LogUtil.getLog(SQLiteTileSource.class); + private ITileSource base; private String name; private SQLiteDatabase db; @@ -122,9 +126,13 @@ public class SQLiteTileSource implements ITileSource { if(db == null){ return false; } + long time = System.currentTimeMillis(); Cursor cursor = db.rawQuery("SELECT 1 FROM tiles WHERE x = ? AND y = ? AND z = ?", new String[] {x+"", y+"",(17 - zoom)+""}); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$ boolean e = cursor.moveToFirst(); cursor.close(); + if (log.isDebugEnabled()) { + log.debug("Checking tile existance x = " + x + " y = " + y + " z = " + zoom + " for " + (System.currentTimeMillis() - time)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + } return e; } diff --git a/OsmAnd/src/com/osmand/activities/MapActivity.java b/OsmAnd/src/com/osmand/activities/MapActivity.java index d215f5cd75..a318524994 100644 --- a/OsmAnd/src/com/osmand/activities/MapActivity.java +++ b/OsmAnd/src/com/osmand/activities/MapActivity.java @@ -1017,6 +1017,7 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso Intent intent = new Intent(MapActivity.this, SearchPoiFilterActivity.class); intent.putExtra(SearchPoiFilterActivity.SEARCH_LAT, latitude); intent.putExtra(SearchPoiFilterActivity.SEARCH_LON, longitude); + intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); } else if(which == 2){ showRoute(latitude, longitude); diff --git a/OsmAnd/src/com/osmand/views/AnimateDraggingMapThread.java b/OsmAnd/src/com/osmand/views/AnimateDraggingMapThread.java index 5c09098bce..743378055d 100644 --- a/OsmAnd/src/com/osmand/views/AnimateDraggingMapThread.java +++ b/OsmAnd/src/com/osmand/views/AnimateDraggingMapThread.java @@ -13,6 +13,8 @@ public class AnimateDraggingMapThread implements Runnable { public void dragTo(float curX, float curY, float newX, float newY, boolean notify); + public void setLatLon(double latitude, double longitude, boolean notify); + public void zoomTo(float zoom, boolean notify); @@ -44,6 +46,8 @@ public class AnimateDraggingMapThread implements Runnable { private int timeMove; private float moveX; private float moveY; + private double moveLat; + private double moveLon; private volatile Thread currentThread = null; private AnimateDraggingCallback callback = null; @@ -126,6 +130,7 @@ public class AnimateDraggingMapThread implements Runnable { curY = newY; if(curX == moveX && curY == moveY){ phaseOfMoving ++; + callback.setLatLon(moveLat, moveLon, notifyListener); } } } @@ -185,6 +190,7 @@ public class AnimateDraggingMapThread implements Runnable { public void startMoving(double curLat, double curLon, double finalLat, double finalLon, int curZoom, int endZoom, int tileSize, float rotate, boolean notifyListener){ stopAnimatingSync(); + this.notifyListener = notifyListener; curZ = curZoom; intZ = curZoom; @@ -199,6 +205,8 @@ public class AnimateDraggingMapThread implements Runnable { float rad = (float) Math.toRadians(rotate); moveX = FloatMath.cos(rad) * mX - FloatMath.sin(rad) * mY; moveY = FloatMath.sin(rad) * mX + FloatMath.cos(rad) * mY; + moveLat = finalLat; + moveLon = finalLon; if(curZoom < intZ){ dirIntZ = 1; } else { diff --git a/OsmAnd/src/com/osmand/views/OsmandMapTileView.java b/OsmAnd/src/com/osmand/views/OsmandMapTileView.java index 158df9c88f..7efc23cef1 100644 --- a/OsmAnd/src/com/osmand/views/OsmandMapTileView.java +++ b/OsmAnd/src/com/osmand/views/OsmandMapTileView.java @@ -639,6 +639,17 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall } } + @Override + public void setLatLon(double latitude, double longitude, boolean notify) { + this.latitude = latitude; + this.longitude = longitude; + refreshMap(); + if(locationListener != null && notify){ + locationListener.locationChanged(latitude, longitude, this); + } + + } + public void moveTo(float dx, float dy) { float fy = calcDiffTileY(dx, dy); float fx = calcDiffTileX(dx, dy);