git-svn-id: https://osmand.googlecode.com/svn/trunk@545 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
This commit is contained in:
Victor Shcherb 2010-10-08 16:38:58 +00:00
parent 27ed10f078
commit e9a8a899e3

View file

@ -214,14 +214,24 @@ public class MapUtils {
return x / getPowZoom(zoom) * 360.0 - 180.0; return x / getPowZoom(zoom) * 360.0 - 180.0;
} }
private static double getPowZoom(float zoom){ public static double getPowZoom(float zoom){
if(zoom - Math.ceil(zoom) < 0.05f){ if(zoom >= 0 && zoom - Math.floor(zoom) < 0.05f){
return 1 << ((int)zoom); return 1 << ((int)zoom);
} else { } else {
return Math.pow(2, zoom); return Math.pow(2, zoom);
} }
} }
public static float calcDiffPixelX(float rotateSin, float rotateCos, float dTileX, float dTileY, float tileSize){
return (rotateCos * dTileX - rotateSin * dTileY) * tileSize ;
}
public static float calcDiffPixelY(float rotateSin, float rotateCos, float dTileX, float dTileY, float tileSize){
return (rotateSin * dTileX + rotateCos * dTileY) * tileSize ;
}
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; return Math.atan(Math.sinh(Math.PI * (1 - 2 * y / getPowZoom(zoom)))) * 180d / Math.PI;
} }