Issue 519. Not rotate on low zoom levels

This commit is contained in:
Victor Shcherb 2011-09-18 13:31:25 +02:00
parent b5852e72db
commit fb37149847
2 changed files with 41 additions and 15 deletions

View file

@ -60,7 +60,7 @@ public class AnimateDraggingMapThread {
tileView.rotateToAnimate(rotationDiff / 5 + tileView.getRotate());
}
}
} while (conditionToCountinue);
} while (conditionToCountinue && tileView.isMapRotateEnabled());
}

View file

@ -43,6 +43,7 @@ import android.view.SurfaceHolder.Callback;
public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCallback, Callback {
protected final static int LOWEST_ZOOM_TO_ROTATE = 10;
protected final int emptyTileDivisor = 16;
@ -263,11 +264,16 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
}
public boolean isMapRotateEnabled(){
return zoom > LOWEST_ZOOM_TO_ROTATE;
}
public void setRotate(float rotate) {
float diff = MapUtils.unifyRotationDiff(rotate, this.rotate);
if (Math.abs(diff) > 5) { // check smallest rotation
animatedDraggingThread.startRotate(rotate);
if (isMapRotateEnabled()) {
float diff = MapUtils.unifyRotationDiff(rotate, getRotate());
if (Math.abs(diff) > 5) { // check smallest rotation
animatedDraggingThread.startRotate(rotate);
}
}
}
@ -280,7 +286,7 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
}
public float getRotate() {
return rotate;
return isMapRotateEnabled() ? rotate : 0;
}
@ -488,7 +494,7 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
canvas.save();
// rotate if needed
if (!layer.drawInScreenPixels()) {
canvas.rotate(rotate, w, h);
canvas.rotate(getRotate(), w, h);
}
layer.onDraw(canvas, latlonRect, tilesRect, nightMode);
canvas.restore();
@ -537,19 +543,37 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
// ///////////////////////////////// DRAGGING PART ///////////////////////////////////////
public float calcDiffTileY(float dx, float dy) {
return (-rotateSin * dx + rotateCos * dy) / getTileSize();
if(isMapRotateEnabled()){
return (-rotateSin * dx + rotateCos * dy) / getTileSize();
} else {
return dy / getTileSize();
}
}
public float calcDiffTileX(float dx, float dy) {
return (rotateCos * dx + rotateSin * dy) / getTileSize();
if(isMapRotateEnabled()){
return (rotateCos * dx + rotateSin * dy) / getTileSize();
} else {
return dx / getTileSize();
}
}
public float calcDiffPixelY(float dTileX, float dTileY) {
return (rotateSin * dTileX + rotateCos * dTileY) * getTileSize();
if(isMapRotateEnabled()){
return (rotateSin * dTileX + rotateCos * dTileY) * getTileSize();
} else {
return dTileY * getTileSize();
}
}
public float calcDiffPixelX(float dTileX, float dTileY) {
return (rotateCos * dTileX - rotateSin * dTileY) * getTileSize();
if(isMapRotateEnabled()){
return (rotateCos * dTileX - rotateSin * dTileY) * getTileSize();
} else {
return dTileX * getTileSize();
}
}
/**
@ -602,11 +626,13 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
}
protected void rotateToAnimate(float rotate) {
this.rotate = MapUtils.unifyRotationTo360(rotate);
float rotateRad = (float) Math.toRadians(rotate);
this.rotateCos = FloatMath.cos(rotateRad);
this.rotateSin = FloatMath.sin(rotateRad);
refreshMap();
if (isMapRotateEnabled()) {
this.rotate = MapUtils.unifyRotationTo360(rotate);
float rotateRad = (float) Math.toRadians(rotate);
this.rotateCos = FloatMath.cos(rotateRad);
this.rotateSin = FloatMath.sin(rotateRad);
refreshMap();
}
}
protected void setLatLonAnimate(double latitude, double longitude, boolean notify) {