Reintegrating v0.5.1 branch to trunk
git-svn-id: https://osmand.googlecode.com/svn/trunk@895 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
This commit is contained in:
parent
e94e415f43
commit
7b13667d57
8 changed files with 43 additions and 21 deletions
|
@ -76,3 +76,5 @@ poi_filter_namefinder = Online NameFinder
|
||||||
reading_cached_tiles = Reading cached tiles...
|
reading_cached_tiles = Reading cached tiles...
|
||||||
|
|
||||||
version_index_is_not_supported = The version of index ''{0}'' is not supported
|
version_index_is_not_supported = The version of index ''{0}'' is not supported
|
||||||
|
|
||||||
|
version_index_is_big_for_memory = The index ''{0}'' did not fit into memory
|
||||||
|
|
|
@ -176,7 +176,12 @@ public class MapUtils {
|
||||||
public static double getTileNumberY(float zoom, double latitude){
|
public static double getTileNumberY(float zoom, double latitude){
|
||||||
latitude = checkLatitude(latitude);
|
latitude = checkLatitude(latitude);
|
||||||
double eval = Math.log( Math.tan(Math.toRadians(latitude)) + 1/Math.cos(Math.toRadians(latitude)) );
|
double eval = Math.log( Math.tan(Math.toRadians(latitude)) + 1/Math.cos(Math.toRadians(latitude)) );
|
||||||
return (1 - eval / Math.PI) / 2 * getPowZoom(zoom);
|
if (Double.isInfinite(eval) || Double.isNaN(eval)) {
|
||||||
|
latitude = latitude < 0 ? - 89.9 : 89.9;
|
||||||
|
eval = Math.log( Math.tan(Math.toRadians(latitude)) + 1/Math.cos(Math.toRadians(latitude)) );
|
||||||
|
}
|
||||||
|
double result = (1 - eval / Math.PI) / 2 * getPowZoom(zoom);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double getTileEllipsoidNumberY(float zoom, double latitude){
|
public static double getTileEllipsoidNumberY(float zoom, double latitude){
|
||||||
|
@ -241,7 +246,9 @@ public class MapUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double getLatitudeFromTile(float zoom, double y){
|
public static double getLatitudeFromTile(float zoom, double y){
|
||||||
return Math.atan(Math.sinh(Math.PI * (1 - 2 * y / getPowZoom(zoom)))) * 180d / Math.PI;
|
int sign = y < 0 ? -1 : 1;
|
||||||
|
double result = Math.atan(sign*Math.sinh(Math.PI * (1 - 2 * y / getPowZoom(zoom)))) * 180d / Math.PI;
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getLengthXFromMeters(float zoom, double latitude, double longitude, double meters, float tileSize, int widthOfDisplay) {
|
public static int getLengthXFromMeters(float zoom, double latitude, double longitude, double meters, float tileSize, int widthOfDisplay) {
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity android:name=".activities.MapActivity" android:label="@string/app_name" android:screenOrientation="portrait"></activity>
|
<activity android:name=".activities.MapActivity" android:label="@string/app_name" android:screenOrientation="portrait"></activity>
|
||||||
<activity android:name=".activities.SettingsActivity" android:label="@string/settings_activity"></activity>
|
<activity android:name=".activities.SettingsActivity" android:label="@string/settings_activity" android:configChanges="keyboardHidden|orientation"></activity>
|
||||||
<activity android:name=".activities.search.SearchActivity" android:label="@string/search_activity" ></activity>
|
<activity android:name=".activities.search.SearchActivity" android:label="@string/search_activity" ></activity>
|
||||||
<activity android:name=".activities.NavigatePointActivity"></activity>
|
<activity android:name=".activities.NavigatePointActivity"></activity>
|
||||||
<activity android:name=".activities.DownloadIndexActivity" android:configChanges="keyboardHidden|orientation"></activity>
|
<activity android:name=".activities.DownloadIndexActivity" android:configChanges="keyboardHidden|orientation"></activity>
|
||||||
|
|
|
@ -422,6 +422,9 @@ public class ResourceManager {
|
||||||
} catch (SQLiteException e) {
|
} catch (SQLiteException e) {
|
||||||
log.error("Exception reading " + f.getAbsolutePath(), e); //$NON-NLS-1$
|
log.error("Exception reading " + f.getAbsolutePath(), e); //$NON-NLS-1$
|
||||||
warnings.add(MessageFormat.format(Messages.getMessage("version_index_is_not_supported"), f.getName())); //$NON-NLS-1$
|
warnings.add(MessageFormat.format(Messages.getMessage("version_index_is_not_supported"), f.getName())); //$NON-NLS-1$
|
||||||
|
} catch (OutOfMemoryError oome) {
|
||||||
|
log.error("Exception reading " + f.getAbsolutePath(), oome); //$NON-NLS-1$
|
||||||
|
warnings.add(MessageFormat.format(Messages.getMessage("version_index_is_big_for_memory"), f.getName()));
|
||||||
}
|
}
|
||||||
} else if(f.getName().endsWith(".map.odb")){ //$NON-NLS-1$
|
} else if(f.getName().endsWith(".map.odb")){ //$NON-NLS-1$
|
||||||
warnings.add(MessageFormat.format(Messages.getMessage("old_map_index_is_not_supported"), f.getName())); //$NON-NLS-1$
|
warnings.add(MessageFormat.format(Messages.getMessage("old_map_index_is_not_supported"), f.getName())); //$NON-NLS-1$
|
||||||
|
|
|
@ -719,7 +719,7 @@ public class DownloadIndexActivity extends ListActivity {
|
||||||
} else if (toIndex.getName().endsWith(IndexConstants.TRANSPORT_INDEX_EXT)) {
|
} else if (toIndex.getName().endsWith(IndexConstants.TRANSPORT_INDEX_EXT)) {
|
||||||
manager.indexingTransport(progress, warnings, toIndex);
|
manager.indexingTransport(progress, warnings, toIndex);
|
||||||
} else if (toIndex.getName().endsWith(IndexConstants.BINARY_MAP_INDEX_EXT)) {
|
} else if (toIndex.getName().endsWith(IndexConstants.BINARY_MAP_INDEX_EXT)) {
|
||||||
manager.indexingMaps(progress);
|
warnings.addAll(manager.indexingMaps(progress));
|
||||||
} else if (toIndex.getName().endsWith(IndexConstants.VOICE_INDEX_EXT_ZIP)) {
|
} else if (toIndex.getName().endsWith(IndexConstants.VOICE_INDEX_EXT_ZIP)) {
|
||||||
}
|
}
|
||||||
if(dateModified != null){
|
if(dateModified != null){
|
||||||
|
|
|
@ -198,7 +198,7 @@ public class RouteProvider {
|
||||||
l.setLatitude(end.getLatitude());
|
l.setLatitude(end.getLatitude());
|
||||||
l.setLongitude(end.getLongitude());
|
l.setLongitude(end.getLongitude());
|
||||||
minDist = Integer.MAX_VALUE;
|
minDist = Integer.MAX_VALUE;
|
||||||
for (int i = 0; i < gpxRoute.size(); i++) {
|
for (int i = startI; i < gpxRoute.size(); i++) {
|
||||||
float d = gpxRoute.get(i).distanceTo(l);
|
float d = gpxRoute.get(i).distanceTo(l);
|
||||||
if (d < minDist) {
|
if (d < minDist) {
|
||||||
endI = i + 1;
|
endI = i + 1;
|
||||||
|
|
|
@ -110,6 +110,14 @@ public class MapRenderRepositories {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
} catch (OutOfMemoryError oome) {
|
||||||
|
if(raf != null){
|
||||||
|
try {
|
||||||
|
raf.close();
|
||||||
|
} catch (IOException e1) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw oome;
|
||||||
}
|
}
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Initializing db " + file.getAbsolutePath() + " " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
log.debug("Initializing db " + file.getAbsolutePath() + " " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||||
|
|
|
@ -28,23 +28,23 @@ import android.graphics.Bitmap;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
|
import android.graphics.Paint.Style;
|
||||||
import android.graphics.PointF;
|
import android.graphics.PointF;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.graphics.RectF;
|
import android.graphics.RectF;
|
||||||
import android.graphics.Paint.Style;
|
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.util.FloatMath;
|
import android.util.FloatMath;
|
||||||
import android.view.GestureDetector;
|
import android.view.GestureDetector;
|
||||||
import android.view.MotionEvent;
|
|
||||||
import android.view.SurfaceHolder;
|
|
||||||
import android.view.SurfaceView;
|
|
||||||
import android.view.WindowManager;
|
|
||||||
import android.view.GestureDetector.OnDoubleTapListener;
|
import android.view.GestureDetector.OnDoubleTapListener;
|
||||||
import android.view.GestureDetector.OnGestureListener;
|
import android.view.GestureDetector.OnGestureListener;
|
||||||
|
import android.view.MotionEvent;
|
||||||
|
import android.view.SurfaceHolder;
|
||||||
import android.view.SurfaceHolder.Callback;
|
import android.view.SurfaceHolder.Callback;
|
||||||
|
import android.view.SurfaceView;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
|
||||||
public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCallback, Callback, AnimateDraggingCallback, OnGestureListener,
|
public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCallback, Callback, AnimateDraggingCallback, OnGestureListener,
|
||||||
OnDoubleTapListener, MultiTouchZoomListener {
|
OnDoubleTapListener, MultiTouchZoomListener {
|
||||||
|
@ -517,21 +517,23 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
||||||
|
|
||||||
for (int i = 0; i < width; i++) {
|
for (int i = 0; i < width; i++) {
|
||||||
for (int j = 0; j < height; j++) {
|
for (int j = 0; j < height; j++) {
|
||||||
float x1 = (i + left - tileX) * ftileSize + w;
|
int leftPlusI = (int) FloatMath.floor((float)MapUtils.getTileNumberX(nzoom, MapUtils.getLongitudeFromTile(nzoom, left+i)));
|
||||||
float y1 = (j + top - tileY) * ftileSize + h;
|
int topPlusJ = (int) FloatMath.floor((float)MapUtils.getTileNumberY(nzoom, MapUtils.getLatitudeFromTile(nzoom, top + j)));
|
||||||
String ordImgTile = mgr.calculateTileId(map, left + i, top + j, nzoom);
|
float x1 = (left + i - tileX) * ftileSize + w;
|
||||||
|
float y1 = (top + j - tileY) * ftileSize + h;
|
||||||
|
String ordImgTile = mgr.calculateTileId(map, leftPlusI, topPlusJ, nzoom);
|
||||||
// asking tile image async
|
// asking tile image async
|
||||||
boolean imgExist = mgr.tileExistOnFileSystem(ordImgTile, map, left + i, top + j, nzoom);
|
boolean imgExist = mgr.tileExistOnFileSystem(ordImgTile, map, leftPlusI, topPlusJ, nzoom);
|
||||||
Bitmap bmp = null;
|
Bitmap bmp = null;
|
||||||
boolean originalBeLoaded = useInternet && nzoom <= maxLevel;
|
boolean originalBeLoaded = useInternet && nzoom <= maxLevel;
|
||||||
if (imgExist || originalBeLoaded) {
|
if (imgExist || originalBeLoaded) {
|
||||||
bmp = mgr.getTileImageForMapAsync(ordImgTile, map, left + i, top + j, nzoom, useInternet);
|
bmp = mgr.getTileImageForMapAsync(ordImgTile, map, leftPlusI, topPlusJ, nzoom, useInternet);
|
||||||
}
|
}
|
||||||
if (bmp == null) {
|
if (bmp == null) {
|
||||||
int div = 2;
|
int div = 2;
|
||||||
// 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, nzoom - 1);
|
String imgTile2 = mgr.calculateTileId(map, leftPlusI / 2, topPlusJ / 2, nzoom - 1);
|
||||||
String imgTile4 = mgr.calculateTileId(map, (left + i) / 4, (top + j) / 4, nzoom - 2);
|
String imgTile4 = mgr.calculateTileId(map, leftPlusI / 4, topPlusJ / 4, nzoom - 2);
|
||||||
if (originalBeLoaded || imgExist) {
|
if (originalBeLoaded || imgExist) {
|
||||||
bmp = mgr.getTileImageFromCache(imgTile2);
|
bmp = mgr.getTileImageFromCache(imgTile2);
|
||||||
div = 2;
|
div = 2;
|
||||||
|
@ -541,14 +543,14 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!originalBeLoaded && !imgExist) {
|
if (!originalBeLoaded && !imgExist) {
|
||||||
if (mgr.tileExistOnFileSystem(imgTile2, map, (left + i) / 2, (top + j) / 2, nzoom - 1)
|
if (mgr.tileExistOnFileSystem(imgTile2, map, leftPlusI / 2, topPlusJ / 2, nzoom - 1)
|
||||||
|| (useInternet && nzoom - 1 <= maxLevel)) {
|
|| (useInternet && nzoom - 1 <= maxLevel)) {
|
||||||
bmp = mgr.getTileImageForMapAsync(imgTile2, map, (left + i) / 2, (top + j) / 2, nzoom - 1,
|
bmp = mgr.getTileImageForMapAsync(imgTile2, map, leftPlusI / 2, topPlusJ / 2, nzoom - 1,
|
||||||
useInternet);
|
useInternet);
|
||||||
div = 2;
|
div = 2;
|
||||||
} else if (mgr.tileExistOnFileSystem(imgTile4, map, (left + i) / 4, (top + j) / 4, nzoom - 2)
|
} else if (mgr.tileExistOnFileSystem(imgTile4, map, leftPlusI / 4, topPlusJ / 4, nzoom - 2)
|
||||||
|| (useInternet && nzoom - 2 <= maxLevel)) {
|
|| (useInternet && nzoom - 2 <= maxLevel)) {
|
||||||
bmp = mgr.getTileImageForMapAsync(imgTile4, map, (left + i) / 4, (top + j) / 4, nzoom - 2,
|
bmp = mgr.getTileImageForMapAsync(imgTile4, map, leftPlusI / 4, topPlusJ / 4, nzoom - 2,
|
||||||
useInternet);
|
useInternet);
|
||||||
div = 4;
|
div = 4;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue