Refactor zoom representation

This commit is contained in:
Victor Shcherb 2014-12-06 14:55:36 +01:00
parent 14d0f7ff4a
commit 170aaabfa6
22 changed files with 83 additions and 116 deletions

View file

@ -9,7 +9,7 @@ public class RotatedTileBox {
private float rotate; private float rotate;
private float density; private float density;
private int zoom; private int zoom;
private double zoomScale; private double mapDensity = 1;
private double zoomAnimation; private double zoomAnimation;
private int cx; private int cx;
private int cy; private int cy;
@ -41,7 +41,7 @@ public class RotatedTileBox {
this.lat = r.lat; this.lat = r.lat;
this.lon = r.lon; this.lon = r.lon;
this.zoom = r.zoom; this.zoom = r.zoom;
this.zoomScale = r.zoomScale; this.mapDensity = r.mapDensity;
this.zoomAnimation = r.zoomAnimation; this.zoomAnimation = r.zoomAnimation;
this.rotate = r.rotate; this.rotate = r.rotate;
this.density = r.density; this.density = r.density;
@ -67,7 +67,7 @@ public class RotatedTileBox {
} }
public void calculateDerivedFields() { public void calculateDerivedFields() {
zoomFactor = Math.pow(2, zoomScale + zoomAnimation ) * 256; zoomFactor = Math.pow(2, zoomAnimation ) * 256 * mapDensity;
double rad = Math.toRadians(this.rotate); double rad = Math.toRadians(this.rotate);
rotateCos = Math.cos(rad); rotateCos = Math.cos(rad);
rotateSin = Math.sin(rad); rotateSin = Math.sin(rad);
@ -392,28 +392,26 @@ public class RotatedTileBox {
MapUtils.getLongitudeFromTile(zoom, alignTile(tileRB.x))); MapUtils.getLongitudeFromTile(zoom, alignTile(tileRB.x)));
} }
public void setZoom(int zoom, double zoomScale) { public void setMapDensity(double mapDensity) {
this.zoom = zoom; this.mapDensity = mapDensity;
this.zoomScale = zoomScale;
calculateDerivedFields(); calculateDerivedFields();
} }
public double getMapDensity() {
return mapDensity;
}
public void setZoom(int zoom) { public void setZoom(int zoom) {
this.zoom = zoom; this.zoom = zoom;
calculateDerivedFields(); calculateDerivedFields();
} }
public void setZoom(int zoom, double zoomScale, double zoomToAnimate) { public void setZoomWithAnimate(int zoom,double zoomToAnimate) {
this.zoom = zoom; this.zoom = zoom;
this.zoomScale = zoomScale;
this.zoomAnimation = zoomToAnimate; this.zoomAnimation = zoomToAnimate;
calculateDerivedFields(); calculateDerivedFields();
} }
public double getZoomScale() {
return zoomScale;
}
public float getRotate() { public float getRotate() {
return rotate; return rotate;
} }
@ -499,9 +497,13 @@ public class RotatedTileBox {
return this; return this;
} }
public RotatedTileBoxBuilder setZoomAndScale(int zoom, double scale) { public RotatedTileBoxBuilder setMapDensity(double mapDensity) {
tb.mapDensity = mapDensity;
return this;
}
public RotatedTileBoxBuilder setZoom(int zoom) {
tb.zoom = zoom; tb.zoom = zoom;
tb.zoomScale = scale;
zoomSet = true; zoomSet = true;
return this; return this;
} }

View file

@ -101,7 +101,7 @@ public class MapRendererContext {
} }
protected float getDisplayDensityFactor() { 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() { protected int getRasterTileSize() {
@ -199,7 +199,8 @@ public class MapRendererContext {
mapRendererView.removeSymbolsProvider(obfMapSymbolsProvider); mapRendererView.removeSymbolsProvider(obfMapSymbolsProvider);
} }
// Create new OBF map symbols provider // 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 there's bound view, add new provider
if (mapRendererView != null) { if (mapRendererView != null) {
mapRendererView.addSymbolsProvider(obfMapSymbolsProvider); mapRendererView.addSymbolsProvider(obfMapSymbolsProvider);

View file

@ -716,16 +716,12 @@ public class OsmandSettings {
TEXT_SCALE.setModeDefaultValue(ApplicationMode.CAR, 1.25f); TEXT_SCALE.setModeDefaultValue(ApplicationMode.CAR, 1.25f);
} }
public final CommonPreference<Float> MAP_ZOOM_SCALE_BY_DENSITY = new FloatPreference("map_zoom_scale_wo_density", 0f).makeProfile().cache(); public final CommonPreference<Float> 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 // this value string is synchronized with settings_pref.xml preference name
public final OsmandPreference<Boolean> SHOW_POI_OVER_MAP = new BooleanPreference("show_poi_over_map", false).makeGlobal(); public final OsmandPreference<Boolean> SHOW_POI_OVER_MAP = new BooleanPreference("show_poi_over_map", false).makeGlobal();

View file

@ -665,7 +665,7 @@ public class MapActivity extends AccessibleActivity {
mapLayers.getMapInfoLayer().recreateControls(); mapLayers.getMapInfoLayer().recreateControls();
} }
mapLayers.updateLayers(mapView); mapLayers.updateLayers(mapView);
mapView.setComplexZoom(mapView.getZoom(), mapView.getSettingsZoomScale()); mapView.setComplexZoom(mapView.getZoom(), mapView.getSettingsMapDensity());
app.getDaynightHelper().startSensorIfNeeded(new StateChangedListener<Boolean>() { app.getDaynightHelper().startSensorIfNeeded(new StateChangedListener<Boolean>() {
@Override @Override

View file

@ -69,7 +69,7 @@ public class AudioNotesLayer extends OsmandMapLayer implements IContextMenuProvi
public int getRadiusPoi(RotatedTileBox tb){ public int getRadiusPoi(RotatedTileBox tb){
int r = 0; int r = 0;
if(tb.getZoom() + tb.getZoomScale() < startZoom){ if(tb.getZoom() < startZoom){
r = 0; r = 0;
} else { } else {
r = 15; r = 15;

View file

@ -1,7 +1,5 @@
package net.osmand.plus.base; package net.osmand.plus.base;
import java.util.Calendar;
import java.util.Date;
import java.util.List; import java.util.List;
import net.osmand.Location; import net.osmand.Location;
@ -203,13 +201,14 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
if (now - lastTimeAutoZooming > 4500 && (now - lastTimeAutoZooming > threshold || !isUserZoomed)) { if (now - lastTimeAutoZooming > 4500 && (now - lastTimeAutoZooming > threshold || !isUserZoomed)) {
isUserZoomed = false; isUserZoomed = false;
lastTimeAutoZooming = now; lastTimeAutoZooming = now;
double settingsZoomScale = mapView.getSettingsZoomScale(); double settingsZoomScale = Math.log(mapView.getSettingsMapDensity()) / Math.log(2.0f);
double complexZoom = tb.getZoom() + tb.getZoomScale() + zdelta; double zoomScale = Math.log(tb.getMapDensity()) / Math.log(2.0f);
double complexZoom = tb.getZoom() + zoomScale + zdelta;
// round to 0.33 // round to 0.33
double newZoom = Math.round((complexZoom - settingsZoomScale) * 3) / 3f; double newZoom = Math.round((complexZoom - settingsZoomScale) * 3) / 3f;
int nz = (int)Math.round(newZoom); int newIntegerZoom = (int)Math.round(newZoom);
double nzscale = newZoom - nz + settingsZoomScale; double nzscale = newZoom - newIntegerZoom + settingsZoomScale;
mapView.setComplexZoom(nz, nzscale); mapView.setComplexZoom(newIntegerZoom, Math.pow(2, nzscale));
// mapView.getAnimatedDraggingThread().startZooming(mapView.getFloatZoom() + zdelta, false); // mapView.getAnimatedDraggingThread().startZooming(mapView.getFloatZoom() + zdelta, false);
} }
} }

View file

@ -98,7 +98,7 @@ public class DashMapFragment extends DashBaseFragment implements IMapDownloader
LatLon lm = getMyApplication().getSettings().getLastKnownMapLocation(); LatLon lm = getMyApplication().getSettings().getLastKnownMapLocation();
int zm = getMyApplication().getSettings().getLastKnownMapZoom(); int zm = getMyApplication().getSettings().getLastKnownMapZoom();
osmandMapTileView.setLatLon(lm.getLatitude(), lm.getLongitude()); osmandMapTileView.setLatLon(lm.getLatitude(), lm.getLongitude());
osmandMapTileView.setComplexZoom(zm, osmandMapTileView.getSettingsZoomScale()); osmandMapTileView.setComplexZoom(zm, osmandMapTileView.getSettingsMapDensity());
osmandMapTileView.refreshMap(true); osmandMapTileView.refreshMap(true);
} }

View file

@ -147,7 +147,7 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
public int getRadiusBug(RotatedTileBox tb) { public int getRadiusBug(RotatedTileBox tb) {
int z; int z;
final double zoom = tb.getZoom() + tb.getZoomScale(); final double zoom = tb.getZoom();
if (zoom < startZoom) { if (zoom < startZoom) {
z = 0; z = 0;
} else if (zoom <= 12) { } else if (zoom <= 12) {

View file

@ -107,7 +107,7 @@ public class OsMoPositionLayer extends OsmandMapLayer implements ContextMenuLaye
public int getRadiusPoi(RotatedTileBox tb){ public int getRadiusPoi(RotatedTileBox tb){
int r = 0; int r = 0;
final double zoom = tb.getZoom() + tb.getZoomScale(); final double zoom = tb.getZoom();
if(zoom < startZoom){ if(zoom < startZoom){
r = 0; r = 0;
} else if(zoom <= 11){ } else if(zoom <= 11){

View file

@ -196,7 +196,7 @@ public class MapRenderRepositories {
return true; return true;
} }
if (requestedBox.getZoom() != box.getZoom() || if (requestedBox.getZoom() != box.getZoom() ||
requestedBox.getZoomScale() != box.getZoomScale()) { requestedBox.getMapDensity() != box.getMapDensity()) {
return true; return true;
} }
@ -667,10 +667,11 @@ public class MapRenderRepositories {
if(renderingReq.searchRenderingAttribute("polygonMinSizeToDisplay")) { if(renderingReq.searchRenderingAttribute("polygonMinSizeToDisplay")) {
currentRenderingContext.polygonMinSizeToDisplay = renderingReq.getIntPropertyValue(renderingReq.ALL.R_ATTR_INT_VALUE); 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(); // LatLon ltn = requestedBox.getLeftTopLatLon();
final double tileDivisor = MapUtils.getPowZoom(31 - requestedBox.getZoom() - final double tileDivisor = MapUtils.getPowZoom(31 - requestedBox.getZoom()) / requestedBox.getMapDensity();
requestedBox.getZoomScale());
currentRenderingContext.leftX = lt.x; currentRenderingContext.leftX = lt.x;
currentRenderingContext.topY = lt.y; currentRenderingContext.topY = lt.y;
@ -680,7 +681,7 @@ public class MapRenderRepositories {
currentRenderingContext.height = requestedBox.getPixHeight(); currentRenderingContext.height = requestedBox.getPixHeight();
currentRenderingContext.nightMode = nightMode; currentRenderingContext.nightMode = nightMode;
currentRenderingContext.preferredLocale = prefs.MAP_PREFERRED_LOCALE.get(); 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); currentRenderingContext.setDensityValue(mapDensity);
//Text/icon scales according to mapDensity (so text is size of road) //Text/icon scales according to mapDensity (so text is size of road)
// currentRenderingContext.textScale = (requestedBox.getDensity()*app.getSettings().TEXT_SCALE.get()); // currentRenderingContext.textScale = (requestedBox.getDensity()*app.getSettings().TEXT_SCALE.get());

View file

@ -1,7 +1,6 @@
package net.osmand.plus.render; package net.osmand.plus.render;
import net.osmand.core.android.MapRendererView; import net.osmand.core.android.MapRendererView;
import net.osmand.core.jni.IMapRenderer;
import net.osmand.core.jni.PointI; import net.osmand.core.jni.PointI;
import net.osmand.data.QuadPointDouble; import net.osmand.data.QuadPointDouble;
import net.osmand.data.RotatedTileBox; import net.osmand.data.RotatedTileBox;
@ -15,7 +14,6 @@ import android.graphics.Canvas;
import android.graphics.Paint; import android.graphics.Paint;
import android.graphics.PointF; import android.graphics.PointF;
import android.graphics.RectF; import android.graphics.RectF;
import android.view.MotionEvent;
public class MapVectorLayer extends BaseMapLayer { public class MapVectorLayer extends BaseMapLayer {

View file

@ -5,9 +5,9 @@ import java.util.List;
import net.osmand.data.RotatedTileBox; import net.osmand.data.RotatedTileBox;
import net.osmand.map.MapTileDownloader.DownloadRequest; import net.osmand.map.MapTileDownloader.DownloadRequest;
import net.osmand.map.MapTileDownloader.IMapDownloaderCallback; import net.osmand.map.MapTileDownloader.IMapDownloaderCallback;
import net.osmand.plus.GPXUtilities;
import net.osmand.plus.GPXUtilities.GPXFile; import net.osmand.plus.GPXUtilities.GPXFile;
import net.osmand.plus.GPXUtilities.WptPt; import net.osmand.plus.GPXUtilities.WptPt;
import net.osmand.plus.GPXUtilities;
import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.render.MapVectorLayer; import net.osmand.plus.render.MapVectorLayer;
@ -114,7 +114,7 @@ public class SherpafyStageItineraryFragment extends SherpafyStageInfoFragment im
tb.setZoom(tb.getZoom() - 1); tb.setZoom(tb.getZoom() - 1);
} }
osmandMapTileView.setLatLon(tb.getCenterLatLon().getLatitude(), tb.getCenterLatLon().getLongitude()); osmandMapTileView.setLatLon(tb.getCenterLatLon().getLatitude(), tb.getCenterLatLon().getLongitude());
osmandMapTileView.setComplexZoom(tb.getZoom(), osmandMapTileView.getSettingsZoomScale()); osmandMapTileView.setComplexZoom(tb.getZoom(), osmandMapTileView.getSettingsMapDensity());
} }

View file

@ -36,7 +36,6 @@ public class AnimateDraggingMapThread {
private double targetLatitude = 0; private double targetLatitude = 0;
private double targetLongitude = 0; private double targetLongitude = 0;
private int targetIntZoom = 0; private int targetIntZoom = 0;
private double targetZoomScale = 0;
private boolean isAnimatingZoom; 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(); stopAnimatingSync();
double startLat = tileView.getLatitude(); double startLat = tileView.getLatitude();
double startLon = tileView.getLongitude(); double startLon = tileView.getLongitude();
float rotate = tileView.getRotate(); float rotate = tileView.getRotate();
final int startZoom = tileView.getZoom(); final int startZoom = tileView.getZoom();
final RotatedTileBox rb = tileView.getCurrentRotatedTileBox().copy(); final RotatedTileBox rb = tileView.getCurrentRotatedTileBox().copy();
final double zoomScale = rb.getZoomScale();
boolean skipAnimation = false; boolean skipAnimation = false;
float mStX = rb.getPixXFromLatLon(startLat, startLon) - rb.getPixXFromLatLon(finalLat, finalLon); float mStX = rb.getPixXFromLatLon(startLat, startLon) - rb.getPixXFromLatLon(finalLat, finalLon);
float mStY = rb.getPixYFromLatLon(startLat, startLon) - rb.getPixYFromLatLon(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); skipAnimation = skipAnimation || (Math.abs(moveZoom - startZoom) >= 3 || Math.abs(endZoom - moveZoom) > 3);
if (skipAnimation) { if (skipAnimation) {
tileView.setLatLonAnimate(finalLat, finalLon, notifyListener); tileView.setLatLonAnimate(finalLat, finalLon, notifyListener);
tileView.setZoomAnimate(endZoom, endZoomScale, notifyListener); tileView.setZoomAnimate(endZoom, notifyListener);
return; return;
} }
final float mMoveX = rb.getPixXFromLatLon(startLat, startLon) - rb.getPixXFromLatLon(finalLat, finalLon); final float mMoveX = rb.getPixXFromLatLon(startLat, startLon) - rb.getPixXFromLatLon(finalLat, finalLon);
@ -158,9 +153,9 @@ public class AnimateDraggingMapThread {
@Override @Override
public void run() { public void run() {
setTargetValues(endZoom, endZoomScale, finalLat, finalLon); setTargetValues(endZoom, finalLat, finalLon);
if(moveZoom != startZoom){ if(moveZoom != startZoom){
animatingZoomInThread(startZoom + zoomScale, moveZoom, zoomScale, ZOOM_MOVE_ANIMATION_TIME, notifyListener); animatingZoomInThread(startZoom, moveZoom, ZOOM_MOVE_ANIMATION_TIME, notifyListener);
} }
if(!stopped){ if(!stopped){
@ -171,13 +166,9 @@ public class AnimateDraggingMapThread {
} }
if (!stopped && moveZoom != endZoom) { if (!stopped && moveZoom != endZoom) {
animatingZoomInThread(moveZoom + zoomScale, endZoom, endZoomScale, ZOOM_MOVE_ANIMATION_TIME, notifyListener); animatingZoomInThread(moveZoom, endZoom, ZOOM_MOVE_ANIMATION_TIME, notifyListener);
}
if(!stopped){
tileView.setZoomAnimate(endZoom, endZoomScale, notifyListener);
} else{
tileView.setZoomAnimate(endZoom, endZoomScale, notifyListener);
} }
tileView.setZoomAnimate(endZoom, notifyListener);
pendingRotateAnimation(); 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 { try {
isAnimatingZoom = true; isAnimatingZoom = true;
double curZoom = zoomStart; double curZoom = zoomStart;
double zoomEnd = (zoom + zoomScale); double zoomEnd = (zoom /*+ zoomScale*/);
animationTime *= Math.abs(zoomEnd - zoomStart); animationTime *= Math.abs(zoomEnd - zoomStart);
// AccelerateInterpolator interpolator = new AccelerateInterpolator(1); // AccelerateInterpolator interpolator = new AccelerateInterpolator(1);
LinearInterpolator interpolator = new LinearInterpolator(); LinearInterpolator interpolator = new LinearInterpolator();
@ -237,7 +228,7 @@ public class AnimateDraggingMapThread {
stopped = true; stopped = true;
} }
} }
tileView.setZoomAnimate(zoom, zoomScale, notifyListener); tileView.setZoomAnimate(zoom, notifyListener);
} finally { } finally {
isAnimatingZoom = false; isAnimatingZoom = false;
} }
@ -248,17 +239,13 @@ public class AnimateDraggingMapThread {
} }
public void startZooming(final int zoomEnd, final boolean notifyListener){ 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; final float animationTime = ZOOM_ANIMATION_TIME;
startThreadAnimating(new Runnable(){ startThreadAnimating(new Runnable(){
@Override @Override
public void run() { public void run() {
final double zoomStart = tileView.getZoom() + tileView.getZoomScale(); final double zoomStart = tileView.getZoom() ;
setTargetValues(zoomEnd, zoomScale, tileView.getLatitude(), tileView.getLongitude()); setTargetValues(zoomEnd, tileView.getLatitude(), tileView.getLongitude());
animatingZoomInThread(zoomStart, zoomEnd, zoomScale, animationTime, notifyListener); animatingZoomInThread(zoomStart, zoomEnd, animationTime, notifyListener);
pendingRotateAnimation(); pendingRotateAnimation();
} }
}); //$NON-NLS-1$ }); //$NON-NLS-1$
@ -306,7 +293,6 @@ public class AnimateDraggingMapThread {
private void clearTargetValues(){ private void clearTargetValues(){
targetIntZoom = 0; targetIntZoom = 0;
targetZoomScale = 0;
} }
private void suspendUpdate() { 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; targetIntZoom = zoom;
targetZoomScale = zoomScale;
targetLatitude = lat; targetLatitude = lat;
targetLongitude = lon; targetLongitude = lon;
} }
@ -353,10 +338,6 @@ public class AnimateDraggingMapThread {
return targetIntZoom; return targetIntZoom;
} }
public double getTargetZoomScale() {
return targetZoomScale;
}
public double getTargetLatitude() { public double getTargetLatitude() {
return targetLatitude; return targetLatitude;
} }

View file

@ -128,7 +128,7 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
private int updatePaints(int color, boolean routePoints, DrawSettings nightMode, RotatedTileBox tileBox){ private int updatePaints(int color, boolean routePoints, DrawSettings nightMode, RotatedTileBox tileBox){
RenderingRulesStorage rrs = view.getApplication().getRendererRegistry().getCurrentSelectedRenderer(); RenderingRulesStorage rrs = view.getApplication().getRendererRegistry().getCurrentSelectedRenderer();
final boolean isNight = nightMode != null && nightMode.isNightMode(); 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) { if (hsh != cachedHash) {
cachedHash = hsh; cachedHash = hsh;
cachedColor = view.getResources().getColor(R.color.gpx_track); cachedColor = view.getResources().getColor(R.color.gpx_track);
@ -140,7 +140,7 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
} }
if (req.searchRenderingAttribute("gpx")) { if (req.searchRenderingAttribute("gpx")) {
RenderingContext rc = new OsmandRenderer.RenderingContext(view.getContext()); 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); cachedColor = req.getIntPropertyValue(rrs.PROPS.R_COLOR);
osmandRenderer.updatePaint(req, paint, 0, false, rc); osmandRenderer.updatePaint(req, paint, 0, false, rc);
isPaint2 = osmandRenderer.updatePaint(req, paint2, 1, false, rc); isPaint2 = osmandRenderer.updatePaint(req, paint2, 1, false, rc);

View file

@ -222,8 +222,9 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
dm = new DisplayMetrics(); dm = new DisplayMetrics();
mgr.getDefaultDisplay().getMetrics(dm); mgr.getDefaultDisplay().getMetrics(dm);
currentViewport = new RotatedTileBox.RotatedTileBoxBuilder(). 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.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()) { if (mainLayer != null && zoom <= mainLayer.getMaximumShownMapZoom() && zoom >= mainLayer.getMinimumShownMapZoom()) {
animatedDraggingThread.stopAnimating(); animatedDraggingThread.stopAnimating();
currentViewport.setZoom(zoom, scale, 0); currentViewport.setZoomWithAnimate(zoom, 0);
currentViewport.setMapDensity(mapDensity);
currentViewport.setRotate(zoom > LOWEST_ZOOM_TO_ROTATE ? rotate : 0); currentViewport.setRotate(zoom > LOWEST_ZOOM_TO_ROTATE ? rotate : 0);
refreshMap(); refreshMap();
} }
@ -349,13 +351,10 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
return currentViewport.getZoom(); return currentViewport.getZoom();
} }
public double getSettingsZoomScale() { public double getSettingsMapDensity() {
return getSettings().getSettingsZoomScale() + Math.sqrt(Math.max(0, getDensity() - 1)); return (getSettings().MAP_DENSITY.get()) * Math.max(1, getDensity());
} }
public double getZoomScale() {
return currentViewport.getZoomScale();
}
public boolean isZooming() { public boolean isZooming() {
return currentViewport.isZoomAnimated(); return currentViewport.isZoomAnimated();
@ -679,8 +678,8 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
} }
} }
protected void setZoomAnimate(int zoom, double zoomScale, boolean notify) { protected void setZoomAnimate(int zoom, boolean notify) {
currentViewport.setZoom(zoom, zoomScale, 0); currentViewport.setZoomWithAnimate(zoom, 0);
refreshMap(); refreshMap();
if (locationListener != null && notify) { if (locationListener != null && notify) {
locationListener.locationChanged(getLatitude(), getLongitude(), this); locationListener.locationChanged(getLatitude(), getLongitude(), this);
@ -690,7 +689,7 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
// for internal usage // for internal usage
protected void zoomToAnimate(double tzoom, boolean notify) { protected void zoomToAnimate(double tzoom, boolean notify) {
int zoom = getZoom(); int zoom = getZoom();
double zoomToAnimate = tzoom - zoom - getZoomScale(); double zoomToAnimate = tzoom - zoom;
if (zoomToAnimate >= 1) { if (zoomToAnimate >= 1) {
zoom += (int) zoomToAnimate; zoom += (int) zoomToAnimate;
zoomToAnimate -= (int) zoomToAnimate; zoomToAnimate -= (int) zoomToAnimate;
@ -867,7 +866,7 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
final RotatedTileBox calc = initialViewport.copy(); final RotatedTileBox calc = initialViewport.copy();
calc.setLatLonCenter(initialCenterLatLon.getLatitude(), initialCenterLatLon.getLongitude()); calc.setLatLonCenter(initialCenterLatLon.getLatitude(), initialCenterLatLon.getLongitude());
double calcZoom = initialViewport.getZoom() + dz + initialViewport.getZoomScale(); double calcZoom = initialViewport.getZoom() + dz ;
float calcRotate = calc.getRotate() + angle; float calcRotate = calc.getRotate() + angle;
calc.setRotate(calcRotate); calc.setRotate(calcRotate);
calc.setZoomAnimation(dz); calc.setZoomAnimation(dz);

View file

@ -184,7 +184,7 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
public int getRadiusPoi(RotatedTileBox tb) { public int getRadiusPoi(RotatedTileBox tb) {
int r = 0; int r = 0;
final double zoom = tb.getZoom() + tb.getZoomScale(); final double zoom = tb.getZoom();
if (zoom < startZoom) { if (zoom < startZoom) {
r = 0; r = 0;
} else if (zoom <= 15) { } else if (zoom <= 15) {

View file

@ -177,7 +177,7 @@ public class PointNavigationLayer extends OsmandMapLayer implements IContextMenu
public int getRadiusPoi(RotatedTileBox tb){ public int getRadiusPoi(RotatedTileBox tb){
int r = 0; int r = 0;
final double zoom = tb.getZoom() + tb.getZoomScale(); final double zoom = tb.getZoom();
if(zoom <= 15){ if(zoom <= 15){
r = 10; r = 10;
} else if(zoom <= 16){ } else if(zoom <= 16){

View file

@ -86,7 +86,7 @@ public class RouteLayer extends OsmandMapLayer {
private void updatePaints(DrawSettings nightMode, RotatedTileBox tileBox){ private void updatePaints(DrawSettings nightMode, RotatedTileBox tileBox){
RenderingRulesStorage rrs = view.getApplication().getRendererRegistry().getCurrentSelectedRenderer(); RenderingRulesStorage rrs = view.getApplication().getRendererRegistry().getCurrentSelectedRenderer();
final boolean isNight = nightMode != null && nightMode.isNightMode(); final boolean isNight = nightMode != null && nightMode.isNightMode();
int hsh = calculateHash(rrs, isNight, tileBox.getZoomScale()); int hsh = calculateHash(rrs, isNight, tileBox.getMapDensity());
if (hsh != cachedHash) { if (hsh != cachedHash) {
cachedHash = hsh; cachedHash = hsh;
// cachedColor = view.getResources().getColor(R.color.nav_track); // 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); req.setBooleanFilter(rrs.PROPS.R_NIGHT_MODE, isNight);
if (req.searchRenderingAttribute("route")) { if (req.searchRenderingAttribute("route")) {
RenderingContext rc = new OsmandRenderer.RenderingContext(view.getContext()); 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); // cachedColor = req.getIntPropertyValue(rrs.PROPS.R_COLOR);
osmandRenderer.updatePaint(req, paint, 0, false, rc); osmandRenderer.updatePaint(req, paint, 0, false, rc);
isPaint2 = osmandRenderer.updatePaint(req, paint2, 1, false, rc); isPaint2 = osmandRenderer.updatePaint(req, paint2, 1, false, rc);

View file

@ -47,7 +47,7 @@ public class TransportInfoLayer extends OsmandMapLayer {
} }
public int getRadius(RotatedTileBox tb){ public int getRadius(RotatedTileBox tb){
final double zoom = tb.getZoom() + tb.getZoomScale(); final double zoom = tb.getZoom();
if(zoom <= 16) { if(zoom <= 16) {
return (int) (tb.getDensity() * 8); return (int) (tb.getDensity() * 8);
} }

View file

@ -122,7 +122,7 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa
} }
public int getRadiusPoi(RotatedTileBox tb){ public int getRadiusPoi(RotatedTileBox tb){
final double zoom = tb.getZoom() + tb.getZoomScale(); final double zoom = tb.getZoom();
int r; int r;
if(zoom < startZoom){ if(zoom < startZoom){
r = 0; r = 0;

View file

@ -1,6 +1,5 @@
package net.osmand.plus.views.controls; package net.osmand.plus.views.controls;
import android.view.Gravity;
import gnu.trove.list.array.TIntArrayList; import gnu.trove.list.array.TIntArrayList;
import java.util.ArrayList; import java.util.ArrayList;
@ -127,11 +126,10 @@ public class MapZoomControls extends MapControls {
zoomShadow.draw(canvas); zoomShadow.draw(canvas);
if (drawZoomLevel) { if (drawZoomLevel) {
String zoomText = tb.getZoom() + ""; String zoomText = tb.getZoom() + "";
double frac = tb.getZoomScale(); double frac = tb.getMapDensity();
if (frac != 0) { if (frac != 0) {
int ifrac = (int) (frac * 10); int ifrac = (int) (frac * 10);
boolean pos = ifrac > 0; zoomText += " ";
zoomText += (pos ? "+" : "-");
zoomText += Math.abs(ifrac) / 10; zoomText += Math.abs(ifrac) / 10;
if (ifrac % 10 != 0) { if (ifrac % 10 != 0) {
zoomText += "." + Math.abs(ifrac) % 10; zoomText += "." + Math.abs(ifrac) % 10;
@ -237,11 +235,10 @@ public class MapZoomControls extends MapControls {
@Override @Override
public boolean onLongClick(View notUseCouldBeNull) { public boolean onLongClick(View notUseCouldBeNull) {
final OsmandSettings.OsmandPreference<Float> zoomScale = view.getSettings().MAP_ZOOM_SCALE_BY_DENSITY; final OsmandSettings.OsmandPreference<Float> mapDensity = view.getSettings().MAP_DENSITY;
final AlertDialog.Builder bld = new AlertDialog.Builder(view.getContext()); final AlertDialog.Builder bld = new AlertDialog.Builder(view.getContext());
float scale = zoomScale.get();// view.getZoomScale(); int p = (int) (mapDensity.get() * 100);
int p = (int) ((scale > 0 ? 1 : -1) * Math.round(scale * scale * 100)) + 100; final TIntArrayList tlist = new TIntArrayList(new int[] {33, 50, 75, 100, 150, 200, 300, 400 });
final TIntArrayList tlist = new TIntArrayList(new int[] {50, 75, 100, 150, 200, 300, 400, 500 });
final List<String> values = new ArrayList<String>(); final List<String> values = new ArrayList<String>();
int i = -1; int i = -1;
for (int k = 0; k <= tlist.size(); k++) { for (int k = 0; k <= tlist.size(); k++) {
@ -269,15 +266,8 @@ public class MapZoomControls extends MapControls {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
int p = tlist.get(which); int p = tlist.get(which);
float newScale; mapDensity.set(p / 100.0f);
if (p >= 100) { view.setComplexZoom(view.getZoom(), view.getSettingsMapDensity());
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);
dialog.dismiss(); dialog.dismiss();
} }
}); });

View file

@ -58,9 +58,9 @@ public class RulerControl extends MapControls {
// update cache // update cache
if (view.isZooming()) { if (view.isZooming()) {
cacheRulerText = null; 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){ Math.abs(tb.getCenterTileX() - cacheRulerTileX) + Math.abs(tb.getCenterTileY() - cacheRulerTileY) > 1){
cacheRulerZoom = (tb.getZoom() + tb.getZoomScale()); cacheRulerZoom = (tb.getZoom());
cacheRulerTileX = tb.getCenterTileX(); cacheRulerTileX = tb.getCenterTileX();
cacheRulerTileY = tb.getCenterTileY(); cacheRulerTileY = tb.getCenterTileY();
final double dist = tb.getDistance(0, tb.getPixHeight() / 2, tb.getPixWidth(), tb.getPixHeight() / 2); final double dist = tb.getDistance(0, tb.getPixHeight() / 2, tb.getPixWidth(), tb.getPixHeight() / 2);