From 5223c2e96d2fd35649edef1b6758a00f63d95253 Mon Sep 17 00:00:00 2001 From: vshcherb Date: Sun, 6 Oct 2013 22:41:28 +0300 Subject: [PATCH] Add route view distance to settings --- .../plus/base/MapViewTrackingUtilities.java | 17 ++++++----------- .../net/osmand/plus/views/MapControlsLayer.java | 10 ++++++++-- .../osmand/plus/views/OsmandMapTileView.java | 5 ----- 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java b/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java index 7befd3aeee..0bbfa6da29 100644 --- a/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java +++ b/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java @@ -164,10 +164,6 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc double distToSee = speed * time; float zoomDelta = (float) (Math.log(visibleDist / distToSee) / Math.log(2.0f)); // check if 17, 18 is correct? - final float zoomScale = tb.getZoom() + tb.getZoomScale(); - if (zoomDelta + zoomScale >= 18 ) { - return 18 - zoomScale ; - } return zoomDelta; } @@ -176,21 +172,20 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc long now = System.currentTimeMillis(); final RotatedTileBox tb = mapView.getCurrentRotatedTileBox(); float zdelta = defineZoomFromSpeed(tb, location.getSpeed()); - if (Math.abs(zdelta) >= OsmandMapTileView.ZOOM_DELTA_1) { + if (Math.abs(zdelta) >= 0.5/*?Math.sqrt(0.5)*/) { // prevent ui hysteresis (check time interval for autozoom) if (zdelta >= 2) { // decrease a bit - zdelta -= 3 * OsmandMapTileView.ZOOM_DELTA_1; + zdelta -= 1; } else if (zdelta <= -2) { // decrease a bit - zdelta += 3 * OsmandMapTileView.ZOOM_DELTA_1; + zdelta += 1; } if (now - lastTimeAutoZooming > 4500) { lastTimeAutoZooming = now; - float complexZoom = tb.getZoom() + tb.getZoomScale(); - float newZoom = Math.round((complexZoom + zdelta) * OsmandMapTileView.ZOOM_DELTA) - * OsmandMapTileView.ZOOM_DELTA_1; - // TODO test round final int tz = Math.round(newZoom); + float complexZoom = tb.getZoom() + tb.getZoomScale() + zdelta; + // round to 0.5 + float newZoom = Math.round(complexZoom * 2) * 0.5f; final int tz = (int)newZoom; mapView.setComplexZoom(tz, newZoom - tz); // mapView.getAnimatedDraggingThread().startZooming(mapView.getFloatZoom() + zdelta, false); diff --git a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java index 91e0044012..8f51fb787f 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java @@ -206,9 +206,15 @@ public class MapControlsLayer extends OsmandMapLayer { private void drawZoomLevel(Canvas canvas, RotatedTileBox tb) { String zoomText = tb.getZoom() + ""; float frac = tb.getZoomScale(); - while(frac > OsmandMapTileView.ZOOM_DELTA_1) { - frac -= OsmandMapTileView.ZOOM_DELTA_1; + if (frac != 0) { zoomText += "'"; + if(frac >= 1){ + int ifrac = ((int) frac); + zoomText += ifrac; + if(frac != ifrac) { + zoomText += "." + ((int) ((frac - ifrac) * 10f)); + } + } } float length = zoomTextPaint.measureText(zoomText); if (zoomShadow.getBounds().width() == 0) { diff --git a/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java b/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java index f1aa3bbbd9..44cf4f6ee6 100644 --- a/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java +++ b/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java @@ -59,11 +59,6 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall protected static final int emptyTileDivisor = 16; - public static final float ZOOM_DELTA = 3; - public static final float ZOOM_DELTA_1 = 1/3f; - - - public interface OnTrackBallListener { public boolean onTrackBallEvent(MotionEvent e);