diff --git a/OsmAnd-java/src/net/osmand/data/RotatedTileBox.java b/OsmAnd-java/src/net/osmand/data/RotatedTileBox.java index 5dcdb086dc..42e69f8f9e 100644 --- a/OsmAnd-java/src/net/osmand/data/RotatedTileBox.java +++ b/OsmAnd-java/src/net/osmand/data/RotatedTileBox.java @@ -9,7 +9,7 @@ public class RotatedTileBox { private float rotate; private float density; private int zoom; - private double zoomScale; + private double mapDensity = 1; private double zoomAnimation; private int cx; private int cy; @@ -41,7 +41,7 @@ public class RotatedTileBox { this.lat = r.lat; this.lon = r.lon; this.zoom = r.zoom; - this.zoomScale = r.zoomScale; + this.mapDensity = r.mapDensity; this.zoomAnimation = r.zoomAnimation; this.rotate = r.rotate; this.density = r.density; @@ -67,7 +67,7 @@ public class RotatedTileBox { } public void calculateDerivedFields() { - zoomFactor = Math.pow(2, zoomScale + zoomAnimation ) * 256; + zoomFactor = Math.pow(2, zoomAnimation ) * 256 * mapDensity; double rad = Math.toRadians(this.rotate); rotateCos = Math.cos(rad); rotateSin = Math.sin(rad); @@ -392,28 +392,26 @@ public class RotatedTileBox { MapUtils.getLongitudeFromTile(zoom, alignTile(tileRB.x))); } - public void setZoom(int zoom, double zoomScale) { - this.zoom = zoom; - this.zoomScale = zoomScale; + public void setMapDensity(double mapDensity) { + this.mapDensity = mapDensity; calculateDerivedFields(); } + + public double getMapDensity() { + return mapDensity; + } public void setZoom(int zoom) { this.zoom = zoom; calculateDerivedFields(); } - public void setZoom(int zoom, double zoomScale, double zoomToAnimate) { + public void setZoomWithAnimate(int zoom,double zoomToAnimate) { this.zoom = zoom; - this.zoomScale = zoomScale; this.zoomAnimation = zoomToAnimate; calculateDerivedFields(); } - public double getZoomScale() { - return zoomScale; - } - public float getRotate() { return rotate; } @@ -499,13 +497,17 @@ public class RotatedTileBox { return this; } - public RotatedTileBoxBuilder setZoomAndScale(int zoom, double scale) { - tb.zoom = zoom; - tb.zoomScale = scale; - zoomSet = true; + public RotatedTileBoxBuilder setMapDensity(double mapDensity) { + tb.mapDensity = mapDensity; return this; } + public RotatedTileBoxBuilder setZoom(int zoom) { + tb.zoom = zoom; + zoomSet = true; + return this; + } + public RotatedTileBoxBuilder setLocation(double lat, double lon) { tb.lat = lat; tb.lon = lon; diff --git a/OsmAnd/src/net/osmand/core/android/MapRendererContext.java b/OsmAnd/src/net/osmand/core/android/MapRendererContext.java index 287dd66e28..ad4db5850b 100644 --- a/OsmAnd/src/net/osmand/core/android/MapRendererContext.java +++ b/OsmAnd/src/net/osmand/core/android/MapRendererContext.java @@ -101,7 +101,7 @@ public class MapRendererContext { } protected float getDisplayDensityFactor() { - return (float) Math.pow(2, Math.sqrt((app.getSettings().getSettingsZoomScale() + density))); + return (float) (app.getSettings().MAP_DENSITY.get()) * Math.max(1, density); } protected int getRasterTileSize() { @@ -199,7 +199,8 @@ public class MapRendererContext { mapRendererView.removeSymbolsProvider(obfMapSymbolsProvider); } // Create new OBF map symbols provider - obfMapSymbolsProvider = new MapObjectsSymbolsProvider(mapPrimitivesProvider, getReferenceTileSize()); + obfMapSymbolsProvider = new MapObjectsSymbolsProvider(mapPrimitivesProvider, getReferenceTileSize(), + app.getSettings().TEXT_SCALE.get() / Math.max(1, density) ); // If there's bound view, add new provider if (mapRendererView != null) { mapRendererView.addSymbolsProvider(obfMapSymbolsProvider); diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java index 87848dcecf..da16bee9e5 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java @@ -716,16 +716,12 @@ public class OsmandSettings { TEXT_SCALE.setModeDefaultValue(ApplicationMode.CAR, 1.25f); } - public final CommonPreference MAP_ZOOM_SCALE_BY_DENSITY = new FloatPreference("map_zoom_scale_wo_density", 0f).makeProfile().cache(); + public final CommonPreference MAP_DENSITY = new FloatPreference("map_density_n", 1f).makeProfile().cache(); { - MAP_ZOOM_SCALE_BY_DENSITY.setModeDefaultValue(ApplicationMode.CAR, 0.5f); + MAP_DENSITY.setModeDefaultValue(ApplicationMode.CAR, 1.5f); } - public float getSettingsZoomScale(){ - return MAP_ZOOM_SCALE_BY_DENSITY.get() ; - } - // this value string is synchronized with settings_pref.xml preference name public final OsmandPreference SHOW_POI_OVER_MAP = new BooleanPreference("show_poi_over_map", false).makeGlobal(); diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index d08d08685c..e529d9ca9a 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -665,7 +665,7 @@ public class MapActivity extends AccessibleActivity { mapLayers.getMapInfoLayer().recreateControls(); } mapLayers.updateLayers(mapView); - mapView.setComplexZoom(mapView.getZoom(), mapView.getSettingsZoomScale()); + mapView.setComplexZoom(mapView.getZoom(), mapView.getSettingsMapDensity()); app.getDaynightHelper().startSensorIfNeeded(new StateChangedListener() { @Override diff --git a/OsmAnd/src/net/osmand/plus/audionotes/AudioNotesLayer.java b/OsmAnd/src/net/osmand/plus/audionotes/AudioNotesLayer.java index 5a6b3fcd69..bddaff7706 100644 --- a/OsmAnd/src/net/osmand/plus/audionotes/AudioNotesLayer.java +++ b/OsmAnd/src/net/osmand/plus/audionotes/AudioNotesLayer.java @@ -69,7 +69,7 @@ public class AudioNotesLayer extends OsmandMapLayer implements IContextMenuProvi public int getRadiusPoi(RotatedTileBox tb){ int r = 0; - if(tb.getZoom() + tb.getZoomScale() < startZoom){ + if(tb.getZoom() < startZoom){ r = 0; } else { r = 15; diff --git a/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java b/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java index 417de58588..c03ed9b260 100644 --- a/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java +++ b/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java @@ -1,7 +1,5 @@ package net.osmand.plus.base; -import java.util.Calendar; -import java.util.Date; import java.util.List; import net.osmand.Location; @@ -203,13 +201,14 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc if (now - lastTimeAutoZooming > 4500 && (now - lastTimeAutoZooming > threshold || !isUserZoomed)) { isUserZoomed = false; lastTimeAutoZooming = now; - double settingsZoomScale = mapView.getSettingsZoomScale(); - double complexZoom = tb.getZoom() + tb.getZoomScale() + zdelta; + double settingsZoomScale = Math.log(mapView.getSettingsMapDensity()) / Math.log(2.0f); + double zoomScale = Math.log(tb.getMapDensity()) / Math.log(2.0f); + double complexZoom = tb.getZoom() + zoomScale + zdelta; // round to 0.33 double newZoom = Math.round((complexZoom - settingsZoomScale) * 3) / 3f; - int nz = (int)Math.round(newZoom); - double nzscale = newZoom - nz + settingsZoomScale; - mapView.setComplexZoom(nz, nzscale); + int newIntegerZoom = (int)Math.round(newZoom); + double nzscale = newZoom - newIntegerZoom + settingsZoomScale; + mapView.setComplexZoom(newIntegerZoom, Math.pow(2, nzscale)); // mapView.getAnimatedDraggingThread().startZooming(mapView.getFloatZoom() + zdelta, false); } } diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashMapFragment.java b/OsmAnd/src/net/osmand/plus/dashboard/DashMapFragment.java index 83c761cb17..95b9c3bff7 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashMapFragment.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashMapFragment.java @@ -98,7 +98,7 @@ public class DashMapFragment extends DashBaseFragment implements IMapDownloader LatLon lm = getMyApplication().getSettings().getLastKnownMapLocation(); int zm = getMyApplication().getSettings().getLastKnownMapZoom(); osmandMapTileView.setLatLon(lm.getLatitude(), lm.getLongitude()); - osmandMapTileView.setComplexZoom(zm, osmandMapTileView.getSettingsZoomScale()); + osmandMapTileView.setComplexZoom(zm, osmandMapTileView.getSettingsMapDensity()); osmandMapTileView.refreshMap(true); } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java index 71a5ef05a6..828dda2f04 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java @@ -147,7 +147,7 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider public int getRadiusBug(RotatedTileBox tb) { int z; - final double zoom = tb.getZoom() + tb.getZoomScale(); + final double zoom = tb.getZoom(); if (zoom < startZoom) { z = 0; } else if (zoom <= 12) { diff --git a/OsmAnd/src/net/osmand/plus/osmo/OsMoPositionLayer.java b/OsmAnd/src/net/osmand/plus/osmo/OsMoPositionLayer.java index da6be7c06c..ca54767631 100644 --- a/OsmAnd/src/net/osmand/plus/osmo/OsMoPositionLayer.java +++ b/OsmAnd/src/net/osmand/plus/osmo/OsMoPositionLayer.java @@ -107,7 +107,7 @@ public class OsMoPositionLayer extends OsmandMapLayer implements ContextMenuLaye public int getRadiusPoi(RotatedTileBox tb){ int r = 0; - final double zoom = tb.getZoom() + tb.getZoomScale(); + final double zoom = tb.getZoom(); if(zoom < startZoom){ r = 0; } else if(zoom <= 11){ diff --git a/OsmAnd/src/net/osmand/plus/render/MapRenderRepositories.java b/OsmAnd/src/net/osmand/plus/render/MapRenderRepositories.java index 71a5f34199..d24d2fe14b 100644 --- a/OsmAnd/src/net/osmand/plus/render/MapRenderRepositories.java +++ b/OsmAnd/src/net/osmand/plus/render/MapRenderRepositories.java @@ -196,7 +196,7 @@ public class MapRenderRepositories { return true; } if (requestedBox.getZoom() != box.getZoom() || - requestedBox.getZoomScale() != box.getZoomScale()) { + requestedBox.getMapDensity() != box.getMapDensity()) { return true; } @@ -667,10 +667,11 @@ public class MapRenderRepositories { if(renderingReq.searchRenderingAttribute("polygonMinSizeToDisplay")) { currentRenderingContext.polygonMinSizeToDisplay = renderingReq.getIntPropertyValue(renderingReq.ALL.R_ATTR_INT_VALUE); } - final QuadPointDouble lt = requestedBox.getLeftTopTile(requestedBox.getZoom() + requestedBox.getZoomScale()); + final QuadPointDouble lt = requestedBox.getLeftTopTile(requestedBox.getZoom()); + lt.x *= requestedBox.getMapDensity(); + lt.y *= requestedBox.getMapDensity(); // LatLon ltn = requestedBox.getLeftTopLatLon(); - final double tileDivisor = MapUtils.getPowZoom(31 - requestedBox.getZoom() - - requestedBox.getZoomScale()); + final double tileDivisor = MapUtils.getPowZoom(31 - requestedBox.getZoom()) / requestedBox.getMapDensity(); currentRenderingContext.leftX = lt.x; currentRenderingContext.topY = lt.y; @@ -680,7 +681,7 @@ public class MapRenderRepositories { currentRenderingContext.height = requestedBox.getPixHeight(); currentRenderingContext.nightMode = nightMode; currentRenderingContext.preferredLocale = prefs.MAP_PREFERRED_LOCALE.get(); - final float mapDensity = (float) Math.pow(2, requestedBox.getZoomScale()); + final float mapDensity = (float) requestedBox.getMapDensity(); currentRenderingContext.setDensityValue(mapDensity); //Text/icon scales according to mapDensity (so text is size of road) // currentRenderingContext.textScale = (requestedBox.getDensity()*app.getSettings().TEXT_SCALE.get()); diff --git a/OsmAnd/src/net/osmand/plus/render/MapVectorLayer.java b/OsmAnd/src/net/osmand/plus/render/MapVectorLayer.java index d01166e374..04b718677d 100644 --- a/OsmAnd/src/net/osmand/plus/render/MapVectorLayer.java +++ b/OsmAnd/src/net/osmand/plus/render/MapVectorLayer.java @@ -1,7 +1,6 @@ package net.osmand.plus.render; import net.osmand.core.android.MapRendererView; -import net.osmand.core.jni.IMapRenderer; import net.osmand.core.jni.PointI; import net.osmand.data.QuadPointDouble; import net.osmand.data.RotatedTileBox; @@ -15,7 +14,6 @@ import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.PointF; import android.graphics.RectF; -import android.view.MotionEvent; public class MapVectorLayer extends BaseMapLayer { diff --git a/OsmAnd/src/net/osmand/plus/sherpafy/SherpafyStageItineraryFragment.java b/OsmAnd/src/net/osmand/plus/sherpafy/SherpafyStageItineraryFragment.java index 7ad53cd513..5679b266cc 100644 --- a/OsmAnd/src/net/osmand/plus/sherpafy/SherpafyStageItineraryFragment.java +++ b/OsmAnd/src/net/osmand/plus/sherpafy/SherpafyStageItineraryFragment.java @@ -5,9 +5,9 @@ import java.util.List; import net.osmand.data.RotatedTileBox; import net.osmand.map.MapTileDownloader.DownloadRequest; import net.osmand.map.MapTileDownloader.IMapDownloaderCallback; +import net.osmand.plus.GPXUtilities; import net.osmand.plus.GPXUtilities.GPXFile; import net.osmand.plus.GPXUtilities.WptPt; -import net.osmand.plus.GPXUtilities; import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.R; import net.osmand.plus.render.MapVectorLayer; @@ -114,7 +114,7 @@ public class SherpafyStageItineraryFragment extends SherpafyStageInfoFragment im tb.setZoom(tb.getZoom() - 1); } osmandMapTileView.setLatLon(tb.getCenterLatLon().getLatitude(), tb.getCenterLatLon().getLongitude()); - osmandMapTileView.setComplexZoom(tb.getZoom(), osmandMapTileView.getSettingsZoomScale()); + osmandMapTileView.setComplexZoom(tb.getZoom(), osmandMapTileView.getSettingsMapDensity()); } diff --git a/OsmAnd/src/net/osmand/plus/views/AnimateDraggingMapThread.java b/OsmAnd/src/net/osmand/plus/views/AnimateDraggingMapThread.java index 89de94d564..edc17517d1 100644 --- a/OsmAnd/src/net/osmand/plus/views/AnimateDraggingMapThread.java +++ b/OsmAnd/src/net/osmand/plus/views/AnimateDraggingMapThread.java @@ -36,7 +36,6 @@ public class AnimateDraggingMapThread { private double targetLatitude = 0; private double targetLongitude = 0; private int targetIntZoom = 0; - private double targetZoomScale = 0; private boolean isAnimatingZoom; @@ -118,18 +117,14 @@ public class AnimateDraggingMapThread { } - public void startMoving(final double finalLat, final double finalLon, final int endZoom, final boolean notifyListener){ - startMoving(finalLat, finalLon, endZoom, tileView.getZoomScale(), notifyListener); - } - public void startMoving(final double finalLat, final double finalLon, final int endZoom, final double endZoomScale, final boolean notifyListener){ + public void startMoving(final double finalLat, final double finalLon, final int endZoom, final boolean notifyListener){ stopAnimatingSync(); double startLat = tileView.getLatitude(); double startLon = tileView.getLongitude(); float rotate = tileView.getRotate(); final int startZoom = tileView.getZoom(); final RotatedTileBox rb = tileView.getCurrentRotatedTileBox().copy(); - final double zoomScale = rb.getZoomScale(); boolean skipAnimation = false; float mStX = rb.getPixXFromLatLon(startLat, startLon) - rb.getPixXFromLatLon(finalLat, finalLon); float mStY = rb.getPixYFromLatLon(startLat, startLon) - rb.getPixYFromLatLon(finalLat, finalLon); @@ -146,7 +141,7 @@ public class AnimateDraggingMapThread { skipAnimation = skipAnimation || (Math.abs(moveZoom - startZoom) >= 3 || Math.abs(endZoom - moveZoom) > 3); if (skipAnimation) { tileView.setLatLonAnimate(finalLat, finalLon, notifyListener); - tileView.setZoomAnimate(endZoom, endZoomScale, notifyListener); + tileView.setZoomAnimate(endZoom, notifyListener); return; } final float mMoveX = rb.getPixXFromLatLon(startLat, startLon) - rb.getPixXFromLatLon(finalLat, finalLon); @@ -158,9 +153,9 @@ public class AnimateDraggingMapThread { @Override public void run() { - setTargetValues(endZoom, endZoomScale, finalLat, finalLon); + setTargetValues(endZoom, finalLat, finalLon); if(moveZoom != startZoom){ - animatingZoomInThread(startZoom + zoomScale, moveZoom, zoomScale, ZOOM_MOVE_ANIMATION_TIME, notifyListener); + animatingZoomInThread(startZoom, moveZoom, ZOOM_MOVE_ANIMATION_TIME, notifyListener); } if(!stopped){ @@ -171,13 +166,9 @@ public class AnimateDraggingMapThread { } if (!stopped && moveZoom != endZoom) { - animatingZoomInThread(moveZoom + zoomScale, endZoom, endZoomScale, ZOOM_MOVE_ANIMATION_TIME, notifyListener); - } - if(!stopped){ - tileView.setZoomAnimate(endZoom, endZoomScale, notifyListener); - } else{ - tileView.setZoomAnimate(endZoom, endZoomScale, notifyListener); + animatingZoomInThread(moveZoom, endZoom, ZOOM_MOVE_ANIMATION_TIME, notifyListener); } + tileView.setZoomAnimate(endZoom, notifyListener); pendingRotateAnimation(); } @@ -212,11 +203,11 @@ public class AnimateDraggingMapThread { } - private void animatingZoomInThread(double zoomStart, int zoom, double zoomScale, float animationTime, boolean notifyListener){ + private void animatingZoomInThread(double zoomStart, int zoom, float animationTime, boolean notifyListener){ try { isAnimatingZoom = true; double curZoom = zoomStart; - double zoomEnd = (zoom + zoomScale); + double zoomEnd = (zoom /*+ zoomScale*/); animationTime *= Math.abs(zoomEnd - zoomStart); // AccelerateInterpolator interpolator = new AccelerateInterpolator(1); LinearInterpolator interpolator = new LinearInterpolator(); @@ -237,7 +228,7 @@ public class AnimateDraggingMapThread { stopped = true; } } - tileView.setZoomAnimate(zoom, zoomScale, notifyListener); + tileView.setZoomAnimate(zoom, notifyListener); } finally { isAnimatingZoom = false; } @@ -248,17 +239,13 @@ public class AnimateDraggingMapThread { } public void startZooming(final int zoomEnd, final boolean notifyListener){ - startZooming(zoomEnd, tileView.getZoomScale(), notifyListener); - } - - public void startZooming(final int zoomEnd, final double zoomScale, final boolean notifyListener){ final float animationTime = ZOOM_ANIMATION_TIME; startThreadAnimating(new Runnable(){ @Override public void run() { - final double zoomStart = tileView.getZoom() + tileView.getZoomScale(); - setTargetValues(zoomEnd, zoomScale, tileView.getLatitude(), tileView.getLongitude()); - animatingZoomInThread(zoomStart, zoomEnd, zoomScale, animationTime, notifyListener); + final double zoomStart = tileView.getZoom() ; + setTargetValues(zoomEnd, tileView.getLatitude(), tileView.getLongitude()); + animatingZoomInThread(zoomStart, zoomEnd, animationTime, notifyListener); pendingRotateAnimation(); } }); //$NON-NLS-1$ @@ -306,7 +293,6 @@ public class AnimateDraggingMapThread { private void clearTargetValues(){ targetIntZoom = 0; - targetZoomScale = 0; } private void suspendUpdate() { @@ -323,9 +309,8 @@ public class AnimateDraggingMapThread { } } - private void setTargetValues(int zoom, double zoomScale, double lat, double lon){ + private void setTargetValues(int zoom, double lat, double lon){ targetIntZoom = zoom; - targetZoomScale = zoomScale; targetLatitude = lat; targetLongitude = lon; } @@ -353,10 +338,6 @@ public class AnimateDraggingMapThread { return targetIntZoom; } - public double getTargetZoomScale() { - return targetZoomScale; - } - public double getTargetLatitude() { return targetLatitude; } diff --git a/OsmAnd/src/net/osmand/plus/views/GPXLayer.java b/OsmAnd/src/net/osmand/plus/views/GPXLayer.java index e2c6d3aaa3..ce546c55ae 100644 --- a/OsmAnd/src/net/osmand/plus/views/GPXLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/GPXLayer.java @@ -128,7 +128,7 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex private int updatePaints(int color, boolean routePoints, DrawSettings nightMode, RotatedTileBox tileBox){ RenderingRulesStorage rrs = view.getApplication().getRendererRegistry().getCurrentSelectedRenderer(); final boolean isNight = nightMode != null && nightMode.isNightMode(); - int hsh = calculateHash(rrs, routePoints, isNight, tileBox.getZoomScale()); + int hsh = calculateHash(rrs, routePoints, isNight, tileBox.getMapDensity()); if (hsh != cachedHash) { cachedHash = hsh; cachedColor = view.getResources().getColor(R.color.gpx_track); @@ -140,7 +140,7 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex } if (req.searchRenderingAttribute("gpx")) { RenderingContext rc = new OsmandRenderer.RenderingContext(view.getContext()); - rc.setDensityValue((float) Math.pow(2, tileBox.getZoomScale())); + rc.setDensityValue((float) tileBox.getMapDensity()); cachedColor = req.getIntPropertyValue(rrs.PROPS.R_COLOR); osmandRenderer.updatePaint(req, paint, 0, false, rc); isPaint2 = osmandRenderer.updatePaint(req, paint2, 1, false, rc); diff --git a/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java b/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java index 65f157a763..f04e296d05 100644 --- a/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java +++ b/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java @@ -222,8 +222,9 @@ public class OsmandMapTileView implements IMapDownloaderCallback { dm = new DisplayMetrics(); mgr.getDefaultDisplay().getMetrics(dm); currentViewport = new RotatedTileBox.RotatedTileBoxBuilder(). - setLocation(0, 0).setZoomAndScale(3, 0).setPixelDimensions(view.getWidth(), view.getHeight()).build(); + setLocation(0, 0).setZoom(3).setPixelDimensions(view.getWidth(), view.getHeight()).build(); currentViewport.setDensity(dm.density); + currentViewport.setMapDensity(getSettingsMapDensity()); } @@ -295,10 +296,11 @@ public class OsmandMapTileView implements IMapDownloaderCallback { } } - public void setComplexZoom(int zoom, double scale) { + public void setComplexZoom(int zoom, double mapDensity) { if (mainLayer != null && zoom <= mainLayer.getMaximumShownMapZoom() && zoom >= mainLayer.getMinimumShownMapZoom()) { animatedDraggingThread.stopAnimating(); - currentViewport.setZoom(zoom, scale, 0); + currentViewport.setZoomWithAnimate(zoom, 0); + currentViewport.setMapDensity(mapDensity); currentViewport.setRotate(zoom > LOWEST_ZOOM_TO_ROTATE ? rotate : 0); refreshMap(); } @@ -349,13 +351,10 @@ public class OsmandMapTileView implements IMapDownloaderCallback { return currentViewport.getZoom(); } - public double getSettingsZoomScale() { - return getSettings().getSettingsZoomScale() + Math.sqrt(Math.max(0, getDensity() - 1)); + public double getSettingsMapDensity() { + return (getSettings().MAP_DENSITY.get()) * Math.max(1, getDensity()); } - public double getZoomScale() { - return currentViewport.getZoomScale(); - } public boolean isZooming() { return currentViewport.isZoomAnimated(); @@ -679,8 +678,8 @@ public class OsmandMapTileView implements IMapDownloaderCallback { } } - protected void setZoomAnimate(int zoom, double zoomScale, boolean notify) { - currentViewport.setZoom(zoom, zoomScale, 0); + protected void setZoomAnimate(int zoom, boolean notify) { + currentViewport.setZoomWithAnimate(zoom, 0); refreshMap(); if (locationListener != null && notify) { locationListener.locationChanged(getLatitude(), getLongitude(), this); @@ -690,7 +689,7 @@ public class OsmandMapTileView implements IMapDownloaderCallback { // for internal usage protected void zoomToAnimate(double tzoom, boolean notify) { int zoom = getZoom(); - double zoomToAnimate = tzoom - zoom - getZoomScale(); + double zoomToAnimate = tzoom - zoom; if (zoomToAnimate >= 1) { zoom += (int) zoomToAnimate; zoomToAnimate -= (int) zoomToAnimate; @@ -867,7 +866,7 @@ public class OsmandMapTileView implements IMapDownloaderCallback { final RotatedTileBox calc = initialViewport.copy(); calc.setLatLonCenter(initialCenterLatLon.getLatitude(), initialCenterLatLon.getLongitude()); - double calcZoom = initialViewport.getZoom() + dz + initialViewport.getZoomScale(); + double calcZoom = initialViewport.getZoom() + dz ; float calcRotate = calc.getRotate() + angle; calc.setRotate(calcRotate); calc.setZoomAnimation(dz); diff --git a/OsmAnd/src/net/osmand/plus/views/POIMapLayer.java b/OsmAnd/src/net/osmand/plus/views/POIMapLayer.java index 8f3cae6b81..844d4f4cce 100644 --- a/OsmAnd/src/net/osmand/plus/views/POIMapLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/POIMapLayer.java @@ -184,7 +184,7 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon public int getRadiusPoi(RotatedTileBox tb) { int r = 0; - final double zoom = tb.getZoom() + tb.getZoomScale(); + final double zoom = tb.getZoom(); if (zoom < startZoom) { r = 0; } else if (zoom <= 15) { diff --git a/OsmAnd/src/net/osmand/plus/views/PointNavigationLayer.java b/OsmAnd/src/net/osmand/plus/views/PointNavigationLayer.java index c59afcf3b4..dbde27c92d 100644 --- a/OsmAnd/src/net/osmand/plus/views/PointNavigationLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/PointNavigationLayer.java @@ -177,7 +177,7 @@ public class PointNavigationLayer extends OsmandMapLayer implements IContextMenu public int getRadiusPoi(RotatedTileBox tb){ int r = 0; - final double zoom = tb.getZoom() + tb.getZoomScale(); + final double zoom = tb.getZoom(); if(zoom <= 15){ r = 10; } else if(zoom <= 16){ diff --git a/OsmAnd/src/net/osmand/plus/views/RouteLayer.java b/OsmAnd/src/net/osmand/plus/views/RouteLayer.java index 42ebca8737..924386a9f5 100644 --- a/OsmAnd/src/net/osmand/plus/views/RouteLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/RouteLayer.java @@ -86,7 +86,7 @@ public class RouteLayer extends OsmandMapLayer { private void updatePaints(DrawSettings nightMode, RotatedTileBox tileBox){ RenderingRulesStorage rrs = view.getApplication().getRendererRegistry().getCurrentSelectedRenderer(); final boolean isNight = nightMode != null && nightMode.isNightMode(); - int hsh = calculateHash(rrs, isNight, tileBox.getZoomScale()); + int hsh = calculateHash(rrs, isNight, tileBox.getMapDensity()); if (hsh != cachedHash) { cachedHash = hsh; // cachedColor = view.getResources().getColor(R.color.nav_track); @@ -95,7 +95,7 @@ public class RouteLayer extends OsmandMapLayer { req.setBooleanFilter(rrs.PROPS.R_NIGHT_MODE, isNight); if (req.searchRenderingAttribute("route")) { RenderingContext rc = new OsmandRenderer.RenderingContext(view.getContext()); - rc.setDensityValue((float) Math.pow(2, tileBox.getZoomScale())); + rc.setDensityValue((float) tileBox.getMapDensity()); // cachedColor = req.getIntPropertyValue(rrs.PROPS.R_COLOR); osmandRenderer.updatePaint(req, paint, 0, false, rc); isPaint2 = osmandRenderer.updatePaint(req, paint2, 1, false, rc); diff --git a/OsmAnd/src/net/osmand/plus/views/TransportInfoLayer.java b/OsmAnd/src/net/osmand/plus/views/TransportInfoLayer.java index 3f3c82414d..ff305613fd 100644 --- a/OsmAnd/src/net/osmand/plus/views/TransportInfoLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/TransportInfoLayer.java @@ -47,7 +47,7 @@ public class TransportInfoLayer extends OsmandMapLayer { } public int getRadius(RotatedTileBox tb){ - final double zoom = tb.getZoom() + tb.getZoomScale(); + final double zoom = tb.getZoom(); if(zoom <= 16) { return (int) (tb.getDensity() * 8); } diff --git a/OsmAnd/src/net/osmand/plus/views/TransportStopsLayer.java b/OsmAnd/src/net/osmand/plus/views/TransportStopsLayer.java index e9c0fac953..7e50a524b0 100644 --- a/OsmAnd/src/net/osmand/plus/views/TransportStopsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/TransportStopsLayer.java @@ -122,7 +122,7 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa } public int getRadiusPoi(RotatedTileBox tb){ - final double zoom = tb.getZoom() + tb.getZoomScale(); + final double zoom = tb.getZoom(); int r; if(zoom < startZoom){ r = 0; diff --git a/OsmAnd/src/net/osmand/plus/views/controls/MapZoomControls.java b/OsmAnd/src/net/osmand/plus/views/controls/MapZoomControls.java index bdd7cc729f..e0c03cb738 100644 --- a/OsmAnd/src/net/osmand/plus/views/controls/MapZoomControls.java +++ b/OsmAnd/src/net/osmand/plus/views/controls/MapZoomControls.java @@ -1,6 +1,5 @@ package net.osmand.plus.views.controls; -import android.view.Gravity; import gnu.trove.list.array.TIntArrayList; import java.util.ArrayList; @@ -127,11 +126,10 @@ public class MapZoomControls extends MapControls { zoomShadow.draw(canvas); if (drawZoomLevel) { String zoomText = tb.getZoom() + ""; - double frac = tb.getZoomScale(); + double frac = tb.getMapDensity(); if (frac != 0) { int ifrac = (int) (frac * 10); - boolean pos = ifrac > 0; - zoomText += (pos ? "+" : "-"); + zoomText += " "; zoomText += Math.abs(ifrac) / 10; if (ifrac % 10 != 0) { zoomText += "." + Math.abs(ifrac) % 10; @@ -237,11 +235,10 @@ public class MapZoomControls extends MapControls { @Override public boolean onLongClick(View notUseCouldBeNull) { - final OsmandSettings.OsmandPreference zoomScale = view.getSettings().MAP_ZOOM_SCALE_BY_DENSITY; + final OsmandSettings.OsmandPreference mapDensity = view.getSettings().MAP_DENSITY; final AlertDialog.Builder bld = new AlertDialog.Builder(view.getContext()); - float scale = zoomScale.get();// view.getZoomScale(); - int p = (int) ((scale > 0 ? 1 : -1) * Math.round(scale * scale * 100)) + 100; - final TIntArrayList tlist = new TIntArrayList(new int[] {50, 75, 100, 150, 200, 300, 400, 500 }); + int p = (int) (mapDensity.get() * 100); + final TIntArrayList tlist = new TIntArrayList(new int[] {33, 50, 75, 100, 150, 200, 300, 400 }); final List values = new ArrayList(); int i = -1; for (int k = 0; k <= tlist.size(); k++) { @@ -269,15 +266,8 @@ public class MapZoomControls extends MapControls { @Override public void onClick(DialogInterface dialog, int which) { int p = tlist.get(which); - float newScale; - if (p >= 100) { - newScale = (float) Math.sqrt((tlist.get(which) - 100f) / 100f); - } else { - newScale = -(float) Math.sqrt((100f - tlist.get(which)) / 100f); - } - zoomScale.set(newScale); - view.getAnimatedDraggingThread().startZooming(view.getZoom(), - view.getSettingsZoomScale(), false); + mapDensity.set(p / 100.0f); + view.setComplexZoom(view.getZoom(), view.getSettingsMapDensity()); dialog.dismiss(); } }); diff --git a/OsmAnd/src/net/osmand/plus/views/controls/RulerControl.java b/OsmAnd/src/net/osmand/plus/views/controls/RulerControl.java index bed5b590f9..43803c4db6 100644 --- a/OsmAnd/src/net/osmand/plus/views/controls/RulerControl.java +++ b/OsmAnd/src/net/osmand/plus/views/controls/RulerControl.java @@ -58,9 +58,9 @@ public class RulerControl extends MapControls { // update cache if (view.isZooming()) { cacheRulerText = null; - } else if((tb.getZoom() + tb.getZoomScale()) != cacheRulerZoom || + } else if((tb.getZoom()) != cacheRulerZoom || Math.abs(tb.getCenterTileX() - cacheRulerTileX) + Math.abs(tb.getCenterTileY() - cacheRulerTileY) > 1){ - cacheRulerZoom = (tb.getZoom() + tb.getZoomScale()); + cacheRulerZoom = (tb.getZoom()); cacheRulerTileX = tb.getCenterTileX(); cacheRulerTileY = tb.getCenterTileY(); final double dist = tb.getDistance(0, tb.getPixHeight() / 2, tb.getPixWidth(), tb.getPixHeight() / 2);