Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
1d0a97e08e
8 changed files with 49 additions and 46 deletions
|
@ -28,13 +28,13 @@ public class RenderingContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public float leftX;
|
public double leftX;
|
||||||
public float topY;
|
public double topY;
|
||||||
public int width;
|
public int width;
|
||||||
public int height;
|
public int height;
|
||||||
|
|
||||||
public int zoom;
|
public int zoom;
|
||||||
public float tileDivisor;
|
public double tileDivisor;
|
||||||
public float rotate;
|
public float rotate;
|
||||||
|
|
||||||
// debug purpose
|
// debug purpose
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
package net.osmand.data;
|
package net.osmand.data;
|
||||||
|
|
||||||
public class QuadRect {
|
public class QuadRect {
|
||||||
public float left;
|
public double left;
|
||||||
public float right;
|
public double right;
|
||||||
public float top;
|
public double top;
|
||||||
public float bottom;
|
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.left = left;
|
||||||
this.right = right;
|
this.right = right;
|
||||||
this.top = top;
|
this.top = top;
|
||||||
|
@ -20,15 +20,15 @@ public class QuadRect {
|
||||||
public QuadRect() {
|
public QuadRect() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public float width() {
|
public double width() {
|
||||||
return right - left;
|
return right - left;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float height() {
|
public double height() {
|
||||||
return bottom - top;
|
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
|
return this.left < this.right && this.top < this.bottom && this.left <= left && this.top <= top && this.right >= right
|
||||||
&& this.bottom >= bottom;
|
&& 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;
|
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;
|
return (left + right) / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float centerY() {
|
public double centerY() {
|
||||||
return (top + bottom) / 2;
|
return (top + bottom) / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void offset(float dx, float dy) {
|
public void offset(double dx, double dy) {
|
||||||
left += dx;
|
left += dx;
|
||||||
top += dy;
|
top += dy;
|
||||||
right += dx;
|
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;
|
left += dx;
|
||||||
top += dy;
|
top += dy;
|
||||||
right -= dx;
|
right -= dx;
|
||||||
|
|
|
@ -86,13 +86,13 @@ public class QuadTree<T> {
|
||||||
void splitBox(QuadRect node_extent, QuadRect[] n) {
|
void splitBox(QuadRect node_extent, QuadRect[] n) {
|
||||||
// coord2d c=node_extent.center();
|
// coord2d c=node_extent.center();
|
||||||
|
|
||||||
float width = node_extent.width();
|
double width = node_extent.width();
|
||||||
float height = node_extent.height();
|
double height = node_extent.height();
|
||||||
|
|
||||||
float lox = node_extent.left;
|
double lox = node_extent.left;
|
||||||
float loy = node_extent.top;
|
double loy = node_extent.top;
|
||||||
float hix = node_extent.right;
|
double hix = node_extent.right;
|
||||||
float hiy = node_extent.bottom;
|
double hiy = node_extent.bottom;
|
||||||
|
|
||||||
n[0] = new QuadRect(lox, loy, lox + width * ratio, loy + height * ratio);
|
n[0] = new QuadRect(lox, loy, lox + width * ratio, loy + height * ratio);
|
||||||
n[1] = new QuadRect(hix - width * ratio, loy, hix, loy + height * ratio);
|
n[1] = new QuadRect(hix - width * ratio, loy, hix, loy + height * ratio);
|
||||||
|
|
|
@ -483,10 +483,10 @@ public class MapActivityActions implements DialogProvider {
|
||||||
}
|
}
|
||||||
final RotatedTileBox tb = mapView.getCurrentRotatedTileBox();
|
final RotatedTileBox tb = mapView.getCurrentRotatedTileBox();
|
||||||
final QuadRect tilesRect = tb.getTileBounds();
|
final QuadRect tilesRect = tb.getTileBounds();
|
||||||
int left = (int) FloatMath.floor(tilesRect.left);
|
int left = (int) Math.floor(tilesRect.left);
|
||||||
int top = (int) FloatMath.floor(tilesRect.top);
|
int top = (int) Math.floor(tilesRect.top);
|
||||||
int width = (int) (FloatMath.ceil(tilesRect.right) - left);
|
int width = (int) (Math.ceil(tilesRect.right) - left);
|
||||||
int height = (int) (FloatMath.ceil(tilesRect.bottom) - top);
|
int height = (int) (Math.ceil(tilesRect.bottom) - top);
|
||||||
for (int i = 0; i <width; i++) {
|
for (int i = 0; i <width; i++) {
|
||||||
for (int j = 0; j< height; j++) {
|
for (int j = 0; j< height; j++) {
|
||||||
((OsmandApplication)mapActivity.getApplication()).getResourceManager().
|
((OsmandApplication)mapActivity.getApplication()).getResourceManager().
|
||||||
|
|
|
@ -586,11 +586,11 @@ public class MapRenderRepositories {
|
||||||
final QuadPointDouble lt = requestedBox.getLeftTopTile(requestedBox.getZoom());
|
final QuadPointDouble lt = requestedBox.getLeftTopTile(requestedBox.getZoom());
|
||||||
// LatLon ltn = requestedBox.getLeftTopLatLon();
|
// LatLon ltn = requestedBox.getLeftTopLatLon();
|
||||||
final float mapDensity = (float) Math.pow(2, requestedBox.getZoomScale());
|
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());
|
requestedBox.getZoomScale());
|
||||||
currentRenderingContext.leftX = (float) (lt.x * MapUtils.getPowZoom(requestedBox.getZoomScale()));
|
currentRenderingContext.leftX = lt.x * MapUtils.getPowZoom(requestedBox.getZoomScale());
|
||||||
// MapUtils.get31TileNumberX(ltn.getLongitude()) / tileDivisor;
|
// 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;
|
//MapUtils.get31TileNumberY(ltn.getLatitude()) / tileDivisor;
|
||||||
currentRenderingContext.zoom = requestedBox.getZoom();
|
currentRenderingContext.zoom = requestedBox.getZoom();
|
||||||
currentRenderingContext.rotate = requestedBox.getRotate();
|
currentRenderingContext.rotate = requestedBox.getRotate();
|
||||||
|
|
|
@ -415,10 +415,10 @@ public class OsmandRenderer {
|
||||||
|
|
||||||
private PointF calcPoint(int xt, int yt, RenderingContext rc){
|
private PointF calcPoint(int xt, int yt, RenderingContext rc){
|
||||||
rc.pointCount ++;
|
rc.pointCount ++;
|
||||||
float tx = xt / rc.tileDivisor;
|
double tx = xt / rc.tileDivisor;
|
||||||
float ty = yt / rc.tileDivisor;
|
double ty = yt / rc.tileDivisor;
|
||||||
float dTileX = tx - rc.leftX;
|
float dTileX = (float) (tx - rc.leftX);
|
||||||
float dTileY = ty - rc.topY;
|
float dTileY = (float) (ty - rc.topY);
|
||||||
float x = rc.cosRotateTileSize * dTileX - rc.sinRotateTileSize * dTileY;
|
float x = rc.cosRotateTileSize * dTileX - rc.sinRotateTileSize * dTileY;
|
||||||
float y = rc.sinRotateTileSize * dTileX + rc.cosRotateTileSize * dTileY;
|
float y = rc.sinRotateTileSize * dTileX + rc.cosRotateTileSize * dTileY;
|
||||||
rc.tempPoint.set(x, y);
|
rc.tempPoint.set(x, y);
|
||||||
|
|
|
@ -98,7 +98,11 @@ public class TextRenderer {
|
||||||
return paintText;
|
return paintText;
|
||||||
}
|
}
|
||||||
|
|
||||||
private float sqr(float a) {
|
private double sqr(double a) {
|
||||||
|
return a * a;
|
||||||
|
}
|
||||||
|
|
||||||
|
private float fsqr(float a) {
|
||||||
return a * a;
|
return a * a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +110,7 @@ public class TextRenderer {
|
||||||
if (Math.abs(tRot) < Math.PI / 15 && Math.abs(sRot) < Math.PI / 15) {
|
if (Math.abs(tRot) < Math.PI / 15 && Math.abs(sRot) < Math.PI / 15) {
|
||||||
return QuadRect.intersects(tRect, sRect);
|
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) {
|
if (dist < 3) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -115,8 +119,8 @@ public class TextRenderer {
|
||||||
if (Math.abs(Math.cos(tRot - sRot)) < 0.3) {
|
if (Math.abs(Math.cos(tRot - sRot)) < 0.3) {
|
||||||
// rotate one rectangle to 90 degrees
|
// rotate one rectangle to 90 degrees
|
||||||
tRot += Math.PI / 2;
|
tRot += Math.PI / 2;
|
||||||
float l = tRect.centerX() - tRect.height() / 2;
|
double l = tRect.centerX() - tRect.height() / 2;
|
||||||
float t = tRect.centerY() - tRect.width() / 2;
|
double t = tRect.centerY() - tRect.width() / 2;
|
||||||
tRect = new QuadRect(l, t, l + tRect.height(), t + tRect.width());
|
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)
|
// (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);
|
float diff = (float) (-Math.atan2(tRect.centerX() - sRect.centerX(), tRect.centerY() - sRect.centerY()) + Math.PI / 2);
|
||||||
diff -= sRot;
|
diff -= sRot;
|
||||||
float left = sRect.centerX() + dist * FloatMath.cos(diff) - tRect.width() / 2;
|
double left = sRect.centerX() + dist * FloatMath.cos(diff) - tRect.width() / 2;
|
||||||
float top = sRect.centerY() - dist * FloatMath.sin(diff) - tRect.height() / 2;
|
double top = sRect.centerY() - dist * FloatMath.sin(diff) - tRect.height() / 2;
|
||||||
QuadRect nRect = new QuadRect(left, top, left + tRect.width(), top + tRect.height());
|
QuadRect nRect = new QuadRect(left, top, left + tRect.width(), top + tRect.height());
|
||||||
return QuadRect.intersects(nRect, sRect);
|
return QuadRect.intersects(nRect, sRect);
|
||||||
}
|
}
|
||||||
|
@ -405,7 +409,7 @@ public class TextRenderer {
|
||||||
float roadLength = 0;
|
float roadLength = 0;
|
||||||
boolean prevInside = false;
|
boolean prevInside = false;
|
||||||
float visibleRoadLength = 0;
|
float visibleRoadLength = 0;
|
||||||
float textw = p.bounds.width();
|
float textw = (float) p.bounds.width();
|
||||||
int last = 0;
|
int last = 0;
|
||||||
int startVisible = 0;
|
int startVisible = 0;
|
||||||
float[] distances = new float[points.length - 1];
|
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 &&
|
boolean inside = points[i].x >= 0 && points[i].x <= rc.width &&
|
||||||
points[i].x >= 0 && points[i].y <= rc.height;
|
points[i].x >= 0 && points[i].y <= rc.height;
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
float d = FloatMath.sqrt(sqr(points[i].x - points[i - 1].x) +
|
float d = FloatMath.sqrt(fsqr(points[i].x - points[i - 1].x) +
|
||||||
sqr(points[i].y - points[i - 1].y));
|
fsqr(points[i].y - points[i - 1].y));
|
||||||
distances[i-1]= d;
|
distances[i-1]= d;
|
||||||
roadLength += d;
|
roadLength += d;
|
||||||
if(inside) {
|
if(inside) {
|
||||||
|
|
|
@ -16,7 +16,6 @@ import android.graphics.Matrix;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.graphics.RectF;
|
import android.graphics.RectF;
|
||||||
import android.util.FloatMath;
|
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
public class MapTileLayer extends BaseMapLayer {
|
public class MapTileLayer extends BaseMapLayer {
|
||||||
|
@ -142,10 +141,10 @@ public class MapTileLayer extends BaseMapLayer {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int left = (int) FloatMath.floor(tilesRect.left);
|
int left = (int) Math.floor(tilesRect.left);
|
||||||
int top = (int) FloatMath.floor(tilesRect.top + ellipticTileCorrection);
|
int top = (int) Math.floor(tilesRect.top + ellipticTileCorrection);
|
||||||
int width = (int) FloatMath.ceil(tilesRect.right - left);
|
int width = (int) Math.ceil(tilesRect.right - left);
|
||||||
int height = (int) FloatMath.ceil(tilesRect.bottom + ellipticTileCorrection - top);
|
int height = (int) Math.ceil(tilesRect.bottom + ellipticTileCorrection - top);
|
||||||
|
|
||||||
boolean useInternet = settings.USE_INTERNET_TO_DOWNLOAD_TILES.get()
|
boolean useInternet = settings.USE_INTERNET_TO_DOWNLOAD_TILES.get()
|
||||||
&& settings.isInternetConnectionAvailable() && map.couldBeDownloadedFromInternet();
|
&& settings.isInternetConnectionAvailable() && map.couldBeDownloadedFromInternet();
|
||||||
|
|
Loading…
Reference in a new issue