Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2013-11-26 17:13:55 +01:00
commit 1d0a97e08e
8 changed files with 49 additions and 46 deletions

View file

@ -28,13 +28,13 @@ public class RenderingContext {
}
public float leftX;
public float topY;
public double leftX;
public double topY;
public int width;
public int height;
public int zoom;
public float tileDivisor;
public double tileDivisor;
public float rotate;
// debug purpose

View file

@ -1,12 +1,12 @@
package net.osmand.data;
public class QuadRect {
public float left;
public float right;
public float top;
public float bottom;
public double left;
public double right;
public double top;
public double bottom;
public QuadRect(float left, float top, float right, float bottom) {
public QuadRect(double left, double top, double right, double bottom) {
this.left = left;
this.right = right;
this.top = top;
@ -20,15 +20,15 @@ public class QuadRect {
public QuadRect() {
}
public float width() {
public double width() {
return right - left;
}
public float height() {
public double height() {
return bottom - top;
}
public boolean contains(float left, float top, float right, float bottom) {
public boolean contains(double left, double top, double right, double bottom) {
return this.left < this.right && this.top < this.bottom && this.left <= left && this.top <= top && this.right >= right
&& this.bottom >= bottom;
}
@ -41,15 +41,15 @@ public class QuadRect {
return a.left < b.right && b.left < a.right && a.top < b.bottom && b.top < a.bottom;
}
public float centerX() {
public double centerX() {
return (left + right) / 2;
}
public float centerY() {
public double centerY() {
return (top + bottom) / 2;
}
public void offset(float dx, float dy) {
public void offset(double dx, double dy) {
left += dx;
top += dy;
right += dx;
@ -57,7 +57,7 @@ public class QuadRect {
}
public void inset(float dx, float dy) {
public void inset(double dx, double dy) {
left += dx;
top += dy;
right -= dx;

View file

@ -86,13 +86,13 @@ public class QuadTree<T> {
void splitBox(QuadRect node_extent, QuadRect[] n) {
// coord2d c=node_extent.center();
float width = node_extent.width();
float height = node_extent.height();
double width = node_extent.width();
double height = node_extent.height();
float lox = node_extent.left;
float loy = node_extent.top;
float hix = node_extent.right;
float hiy = node_extent.bottom;
double lox = node_extent.left;
double loy = node_extent.top;
double hix = node_extent.right;
double hiy = node_extent.bottom;
n[0] = new QuadRect(lox, loy, lox + width * ratio, loy + height * ratio);
n[1] = new QuadRect(hix - width * ratio, loy, hix, loy + height * ratio);

View file

@ -483,10 +483,10 @@ public class MapActivityActions implements DialogProvider {
}
final RotatedTileBox tb = mapView.getCurrentRotatedTileBox();
final QuadRect tilesRect = tb.getTileBounds();
int left = (int) FloatMath.floor(tilesRect.left);
int top = (int) FloatMath.floor(tilesRect.top);
int width = (int) (FloatMath.ceil(tilesRect.right) - left);
int height = (int) (FloatMath.ceil(tilesRect.bottom) - top);
int left = (int) Math.floor(tilesRect.left);
int top = (int) Math.floor(tilesRect.top);
int width = (int) (Math.ceil(tilesRect.right) - left);
int height = (int) (Math.ceil(tilesRect.bottom) - top);
for (int i = 0; i <width; i++) {
for (int j = 0; j< height; j++) {
((OsmandApplication)mapActivity.getApplication()).getResourceManager().

View file

@ -586,11 +586,11 @@ public class MapRenderRepositories {
final QuadPointDouble lt = requestedBox.getLeftTopTile(requestedBox.getZoom());
// LatLon ltn = requestedBox.getLeftTopLatLon();
final float mapDensity = (float) Math.pow(2, requestedBox.getZoomScale());
final float tileDivisor = (float) MapUtils.getPowZoom(31 - requestedBox.getZoom() -
final double tileDivisor = MapUtils.getPowZoom(31 - requestedBox.getZoom() -
requestedBox.getZoomScale());
currentRenderingContext.leftX = (float) (lt.x * MapUtils.getPowZoom(requestedBox.getZoomScale()));
currentRenderingContext.leftX = lt.x * MapUtils.getPowZoom(requestedBox.getZoomScale());
// MapUtils.get31TileNumberX(ltn.getLongitude()) / tileDivisor;
currentRenderingContext.topY = (float) (lt.y * MapUtils.getPowZoom(requestedBox.getZoomScale()));
currentRenderingContext.topY = lt.y * MapUtils.getPowZoom(requestedBox.getZoomScale());
//MapUtils.get31TileNumberY(ltn.getLatitude()) / tileDivisor;
currentRenderingContext.zoom = requestedBox.getZoom();
currentRenderingContext.rotate = requestedBox.getRotate();

View file

@ -415,10 +415,10 @@ public class OsmandRenderer {
private PointF calcPoint(int xt, int yt, RenderingContext rc){
rc.pointCount ++;
float tx = xt / rc.tileDivisor;
float ty = yt / rc.tileDivisor;
float dTileX = tx - rc.leftX;
float dTileY = ty - rc.topY;
double tx = xt / rc.tileDivisor;
double ty = yt / rc.tileDivisor;
float dTileX = (float) (tx - rc.leftX);
float dTileY = (float) (ty - rc.topY);
float x = rc.cosRotateTileSize * dTileX - rc.sinRotateTileSize * dTileY;
float y = rc.sinRotateTileSize * dTileX + rc.cosRotateTileSize * dTileY;
rc.tempPoint.set(x, y);

View file

@ -98,7 +98,11 @@ public class TextRenderer {
return paintText;
}
private float sqr(float a) {
private double sqr(double a) {
return a * a;
}
private float fsqr(float a) {
return a * a;
}
@ -106,7 +110,7 @@ public class TextRenderer {
if (Math.abs(tRot) < Math.PI / 15 && Math.abs(sRot) < Math.PI / 15) {
return QuadRect.intersects(tRect, sRect);
}
float dist = FloatMath.sqrt(sqr(tRect.centerX() - sRect.centerX()) + sqr(tRect.centerY() - sRect.centerY()));
double dist = Math.sqrt(sqr(tRect.centerX() - sRect.centerX()) + sqr(tRect.centerY() - sRect.centerY()));
if (dist < 3) {
return true;
}
@ -115,8 +119,8 @@ public class TextRenderer {
if (Math.abs(Math.cos(tRot - sRot)) < 0.3) {
// rotate one rectangle to 90 degrees
tRot += Math.PI / 2;
float l = tRect.centerX() - tRect.height() / 2;
float t = tRect.centerY() - tRect.width() / 2;
double l = tRect.centerX() - tRect.height() / 2;
double t = tRect.centerY() - tRect.width() / 2;
tRect = new QuadRect(l, t, l + tRect.height(), t + tRect.width());
}
@ -126,8 +130,8 @@ public class TextRenderer {
// (calculate offset for t center suppose we rotate around s center)
float diff = (float) (-Math.atan2(tRect.centerX() - sRect.centerX(), tRect.centerY() - sRect.centerY()) + Math.PI / 2);
diff -= sRot;
float left = sRect.centerX() + dist * FloatMath.cos(diff) - tRect.width() / 2;
float top = sRect.centerY() - dist * FloatMath.sin(diff) - tRect.height() / 2;
double left = sRect.centerX() + dist * FloatMath.cos(diff) - tRect.width() / 2;
double top = sRect.centerY() - dist * FloatMath.sin(diff) - tRect.height() / 2;
QuadRect nRect = new QuadRect(left, top, left + tRect.width(), top + tRect.height());
return QuadRect.intersects(nRect, sRect);
}
@ -405,7 +409,7 @@ public class TextRenderer {
float roadLength = 0;
boolean prevInside = false;
float visibleRoadLength = 0;
float textw = p.bounds.width();
float textw = (float) p.bounds.width();
int last = 0;
int startVisible = 0;
float[] distances = new float[points.length - 1];
@ -415,8 +419,8 @@ public class TextRenderer {
boolean inside = points[i].x >= 0 && points[i].x <= rc.width &&
points[i].x >= 0 && points[i].y <= rc.height;
if (i > 0) {
float d = FloatMath.sqrt(sqr(points[i].x - points[i - 1].x) +
sqr(points[i].y - points[i - 1].y));
float d = FloatMath.sqrt(fsqr(points[i].x - points[i - 1].x) +
fsqr(points[i].y - points[i - 1].y));
distances[i-1]= d;
roadLength += d;
if(inside) {

View file

@ -16,7 +16,6 @@ import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;
import android.util.FloatMath;
import android.widget.Toast;
public class MapTileLayer extends BaseMapLayer {
@ -142,10 +141,10 @@ public class MapTileLayer extends BaseMapLayer {
}
int left = (int) FloatMath.floor(tilesRect.left);
int top = (int) FloatMath.floor(tilesRect.top + ellipticTileCorrection);
int width = (int) FloatMath.ceil(tilesRect.right - left);
int height = (int) FloatMath.ceil(tilesRect.bottom + ellipticTileCorrection - top);
int left = (int) Math.floor(tilesRect.left);
int top = (int) Math.floor(tilesRect.top + ellipticTileCorrection);
int width = (int) Math.ceil(tilesRect.right - left);
int height = (int) Math.ceil(tilesRect.bottom + ellipticTileCorrection - top);
boolean useInternet = settings.USE_INTERNET_TO_DOWNLOAD_TILES.get()
&& settings.isInternetConnectionAvailable() && map.couldBeDownloadedFromInternet();