Fix 1-3 zoom visibility
This commit is contained in:
parent
1098c84bd4
commit
a8b029e91e
4 changed files with 69 additions and 25 deletions
|
@ -189,13 +189,23 @@ public class RotatedTileBox {
|
||||||
double t = Math.min(Math.min(y1, y2), Math.min(y3, y4)) ;
|
double t = Math.min(Math.min(y1, y2), Math.min(y3, y4)) ;
|
||||||
double b = Math.max(Math.max(y1, y2), Math.max(y3, y4)) ;
|
double b = Math.max(Math.max(y1, y2), Math.max(y3, y4)) ;
|
||||||
tileBounds = new QuadRect((float)l, (float)t,(float) r, (float)b);
|
tileBounds = new QuadRect((float)l, (float)t,(float) r, (float)b);
|
||||||
float top = (float) MapUtils.getLatitudeFromTile(zoom, tileBounds.top);
|
float top = (float) MapUtils.getLatitudeFromTile(zoom, alignTile(tileBounds.top));
|
||||||
float left = (float) MapUtils.getLongitudeFromTile(zoom, tileBounds.left);
|
float left = (float) MapUtils.getLongitudeFromTile(zoom, alignTile(tileBounds.left));
|
||||||
float bottom = (float) MapUtils.getLatitudeFromTile(zoom, tileBounds.bottom);
|
float bottom = (float) MapUtils.getLatitudeFromTile(zoom, alignTile(tileBounds.bottom));
|
||||||
float right = (float) MapUtils.getLongitudeFromTile(zoom, tileBounds.right);
|
float right = (float) MapUtils.getLongitudeFromTile(zoom, alignTile(tileBounds.right));
|
||||||
latLonBounds = new QuadRect(left, top, right, bottom);
|
latLonBounds = new QuadRect(left, top, right, bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private double alignTile(double tile) {
|
||||||
|
if(tile < 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if(tile >= MapUtils.getPowZoom(zoom)) {
|
||||||
|
return MapUtils.getPowZoom(zoom) - .000001;
|
||||||
|
}
|
||||||
|
return tile;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public int getPixWidth() {
|
public int getPixWidth() {
|
||||||
return pixWidth;
|
return pixWidth;
|
||||||
|
@ -212,6 +222,13 @@ public class RotatedTileBox {
|
||||||
return getPixXFromTile(xTile, yTile);
|
return getPixXFromTile(xTile, yTile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getPixXFromTile(double tileX, double tileY, float zoom) {
|
||||||
|
double pw = MapUtils.getPowZoom(zoom - this.zoom);
|
||||||
|
float xTile = (float) (tileX / pw);
|
||||||
|
float yTile = (float) (tileY / pw);
|
||||||
|
return getPixXFromTile(xTile, yTile);
|
||||||
|
}
|
||||||
|
|
||||||
protected int getPixXFromTile(double xTile, double yTile) {
|
protected int getPixXFromTile(double xTile, double yTile) {
|
||||||
double rotX;
|
double rotX;
|
||||||
final double dTileX = xTile - oxTile;
|
final double dTileX = xTile - oxTile;
|
||||||
|
@ -232,6 +249,13 @@ public class RotatedTileBox {
|
||||||
return getPixYFromTile(xTile, yTile);
|
return getPixYFromTile(xTile, yTile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getPixYFromTile(double tileX, double tileY, float zoom) {
|
||||||
|
double pw = MapUtils.getPowZoom(zoom - this.zoom);
|
||||||
|
float xTile = (float) (tileX / pw);
|
||||||
|
float yTile = (float) (tileY / pw);
|
||||||
|
return getPixYFromTile(xTile, yTile);
|
||||||
|
}
|
||||||
|
|
||||||
protected int getPixYFromTile(float xTile, float yTile) {
|
protected int getPixYFromTile(float xTile, float yTile) {
|
||||||
final double dTileX = xTile - oxTile;
|
final double dTileX = xTile - oxTile;
|
||||||
final double dTileY = yTile - oyTile;
|
final double dTileY = yTile - oyTile;
|
||||||
|
@ -346,21 +370,34 @@ public class RotatedTileBox {
|
||||||
|
|
||||||
public LatLon getLeftTopLatLon() {
|
public LatLon getLeftTopLatLon() {
|
||||||
checkTileRectangleCalculated();
|
checkTileRectangleCalculated();
|
||||||
return new LatLon(MapUtils.getLatitudeFromTile(zoom, tileLT.y),
|
return new LatLon(MapUtils.getLatitudeFromTile(zoom, alignTile(tileLT.y)),
|
||||||
MapUtils.getLongitudeFromTile(zoom, tileLT.x));
|
MapUtils.getLongitudeFromTile(zoom, alignTile(tileLT.x)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public QuadPoint getLeftTopTile(float zoom) {
|
||||||
|
checkTileRectangleCalculated();
|
||||||
|
return new QuadPoint((float) (tileLT.x * MapUtils.getPowZoom(zoom - this.zoom)),
|
||||||
|
(float) (tileLT.y * MapUtils.getPowZoom(zoom - this.zoom)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public QuadPoint getRightBottomTile(float zoom) {
|
||||||
|
checkTileRectangleCalculated();
|
||||||
|
return new QuadPoint((float) (tileRB.x * MapUtils.getPowZoom(zoom - this.zoom)),
|
||||||
|
(float) (tileRB.y * MapUtils.getPowZoom(zoom - this.zoom)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void checkTileRectangleCalculated() {
|
private void checkTileRectangleCalculated() {
|
||||||
if(tileBounds == null){
|
if(tileBounds == null){
|
||||||
calculateTileRectangle();;
|
calculateTileRectangle();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public LatLon getRightBottomLatLon() {
|
public LatLon getRightBottomLatLon() {
|
||||||
checkTileRectangleCalculated();
|
checkTileRectangleCalculated();
|
||||||
return new LatLon(MapUtils.getLatitudeFromTile(zoom, tileRB.y),
|
return new LatLon(MapUtils.getLatitudeFromTile(zoom, alignTile(tileRB.y)),
|
||||||
MapUtils.getLongitudeFromTile(zoom, tileRB.x));
|
MapUtils.getLongitudeFromTile(zoom, alignTile(tileRB.x)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setZoom(int zoom, float zoomScale) {
|
public void setZoom(int zoom, float zoomScale) {
|
||||||
|
|
|
@ -30,6 +30,7 @@ import net.osmand.binary.BinaryMapIndexReader.MapIndex;
|
||||||
import net.osmand.binary.BinaryMapIndexReader.SearchRequest;
|
import net.osmand.binary.BinaryMapIndexReader.SearchRequest;
|
||||||
import net.osmand.binary.BinaryMapIndexReader.TagValuePair;
|
import net.osmand.binary.BinaryMapIndexReader.TagValuePair;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
|
import net.osmand.data.QuadPoint;
|
||||||
import net.osmand.data.QuadRect;
|
import net.osmand.data.QuadRect;
|
||||||
import net.osmand.data.RotatedTileBox;
|
import net.osmand.data.RotatedTileBox;
|
||||||
import net.osmand.map.MapTileDownloader.IMapDownloaderCallback;
|
import net.osmand.map.MapTileDownloader.IMapDownloaderCallback;
|
||||||
|
@ -554,13 +555,15 @@ public class MapRenderRepositories {
|
||||||
currentRenderingContext.shadowRenderingMode = renderingReq.getIntPropertyValue(renderingReq.ALL.R_ATTR_INT_VALUE);
|
currentRenderingContext.shadowRenderingMode = renderingReq.getIntPropertyValue(renderingReq.ALL.R_ATTR_INT_VALUE);
|
||||||
currentRenderingContext.shadowRenderingColor = renderingReq.getIntPropertyValue(renderingReq.ALL.R_SHADOW_COLOR);
|
currentRenderingContext.shadowRenderingColor = renderingReq.getIntPropertyValue(renderingReq.ALL.R_SHADOW_COLOR);
|
||||||
}
|
}
|
||||||
// final QuadPoint lt = requestedBox.getLeftTopTilePoint();
|
final QuadPoint lt = requestedBox.getLeftTopTile(requestedBox.getZoom() +
|
||||||
LatLon lt = requestedBox.getLeftTopLatLon();
|
requestedBox.getZoomScale());
|
||||||
|
//LatLon lt = 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 float tileDivisor = (float) MapUtils.getPowZoom(31 - requestedBox.getZoom() -
|
||||||
requestedBox.getZoomScale());
|
requestedBox.getZoomScale());
|
||||||
currentRenderingContext.leftX = MapUtils.get31TileNumberX(lt.getLongitude()) / tileDivisor;
|
currentRenderingContext.leftX = lt.x;
|
||||||
currentRenderingContext.topY = MapUtils.get31TileNumberY(lt.getLatitude()) / tileDivisor;
|
//MapUtils.get31TileNumberX(lt.getLongitude()) / tileDivisor;
|
||||||
|
currentRenderingContext.topY = lt.y;//MapUtils.get31TileNumberY(lt.getLatitude()) / tileDivisor;
|
||||||
currentRenderingContext.zoom = requestedBox.getZoom();
|
currentRenderingContext.zoom = requestedBox.getZoom();
|
||||||
currentRenderingContext.rotate = requestedBox.getRotate();
|
currentRenderingContext.rotate = requestedBox.getRotate();
|
||||||
currentRenderingContext.width = requestedBox.getPixWidth();
|
currentRenderingContext.width = requestedBox.getPixWidth();
|
||||||
|
|
|
@ -2,6 +2,7 @@ package net.osmand.plus.render;
|
||||||
|
|
||||||
import android.graphics.*;
|
import android.graphics.*;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
|
import net.osmand.data.QuadPoint;
|
||||||
import net.osmand.data.RotatedTileBox;
|
import net.osmand.data.RotatedTileBox;
|
||||||
import net.osmand.plus.resources.ResourceManager;
|
import net.osmand.plus.resources.ResourceManager;
|
||||||
import net.osmand.plus.views.BaseMapLayer;
|
import net.osmand.plus.views.BaseMapLayer;
|
||||||
|
@ -103,15 +104,16 @@ public class MapVectorLayer extends BaseMapLayer {
|
||||||
boolean shown = false;
|
boolean shown = false;
|
||||||
if (bmp != null && bmpLoc != null) {
|
if (bmp != null && bmpLoc != null) {
|
||||||
float rot = - bmpLoc.getRotate();
|
float rot = - bmpLoc.getRotate();
|
||||||
final LatLon lt = bmpLoc.getLeftTopLatLon();
|
int cz = currentViewport.getZoom();
|
||||||
final LatLon rb = bmpLoc.getRightBottomLatLon();
|
|
||||||
canvas.rotate(rot, currentViewport.getCenterPixelX(), currentViewport.getCenterPixelY());
|
canvas.rotate(rot, currentViewport.getCenterPixelX(), currentViewport.getCenterPixelY());
|
||||||
final RotatedTileBox calc = currentViewport.copy();
|
final RotatedTileBox calc = currentViewport.copy();
|
||||||
calc.setRotate(bmpLoc.getRotate());
|
calc.setRotate(bmpLoc.getRotate());
|
||||||
final int x1 = calc.getPixXFromLatLon(lt.getLatitude(), lt.getLongitude());
|
QuadPoint lt = bmpLoc.getLeftTopTile(cz);
|
||||||
final int x2 = calc.getPixXFromLatLon(rb.getLatitude(), rb.getLongitude());
|
QuadPoint rb = bmpLoc.getRightBottomTile(cz);
|
||||||
final int y1 = calc.getPixYFromLatLon(lt.getLatitude(), lt.getLongitude());
|
final int x1 = calc.getPixXFromTile(lt.x, lt.y, cz);
|
||||||
final int y2 = calc.getPixYFromLatLon(rb.getLatitude(), rb.getLongitude());
|
final int x2 = calc.getPixXFromTile(rb.x, rb.y, cz);
|
||||||
|
final int y1 = calc.getPixYFromTile(lt.x, lt.y, cz);
|
||||||
|
final int y2 = calc.getPixYFromTile(rb.x, rb.y, cz);
|
||||||
destImage.set(x1, y1, x2, y2);
|
destImage.set(x1, y1, x2, y2);
|
||||||
if(!bmp.isRecycled()){
|
if(!bmp.isRecycled()){
|
||||||
canvas.drawBitmap(bmp, null, destImage, paintImg);
|
canvas.drawBitmap(bmp, null, destImage, paintImg);
|
||||||
|
|
|
@ -389,15 +389,17 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
||||||
private void drawBasemap(Canvas canvas) {
|
private void drawBasemap(Canvas canvas) {
|
||||||
if(bufferImgLoc != null) {
|
if(bufferImgLoc != null) {
|
||||||
float rot = - bufferImgLoc.getRotate();
|
float rot = - bufferImgLoc.getRotate();
|
||||||
final LatLon lt = bufferImgLoc.getLeftTopLatLon();
|
|
||||||
final LatLon rb = bufferImgLoc.getRightBottomLatLon();
|
|
||||||
canvas.rotate(rot, currentViewport.getCenterPixelX(), currentViewport.getCenterPixelY());
|
canvas.rotate(rot, currentViewport.getCenterPixelX(), currentViewport.getCenterPixelY());
|
||||||
final RotatedTileBox calc = currentViewport.copy();
|
final RotatedTileBox calc = currentViewport.copy();
|
||||||
calc.setRotate(bufferImgLoc.getRotate());
|
calc.setRotate(bufferImgLoc.getRotate());
|
||||||
final int x1 = calc.getPixXFromLatLon(lt.getLatitude(), lt.getLongitude());
|
|
||||||
final int x2 = calc.getPixXFromLatLon(rb.getLatitude(), rb.getLongitude());
|
int cz = getZoom();
|
||||||
final int y1 = calc.getPixYFromLatLon(lt.getLatitude(), lt.getLongitude());
|
QuadPoint lt = bufferImgLoc.getLeftTopTile(cz);
|
||||||
final int y2 = calc.getPixYFromLatLon(rb.getLatitude(), rb.getLongitude());
|
QuadPoint rb = bufferImgLoc.getRightBottomTile(cz);
|
||||||
|
final int x1 = calc.getPixXFromTile(lt.x, lt.y, cz);
|
||||||
|
final int x2 = calc.getPixXFromTile(rb.x, rb.y, cz);
|
||||||
|
final int y1 = calc.getPixYFromTile(lt.x, lt.y, cz);
|
||||||
|
final int y2 = calc.getPixYFromTile(rb.x, rb.y, cz);
|
||||||
if(!bufferBitmap.isRecycled()){
|
if(!bufferBitmap.isRecycled()){
|
||||||
canvas.drawBitmap(bufferBitmap, null, new RectF(x1, y1, x2, y2), paintImg);
|
canvas.drawBitmap(bufferBitmap, null, new RectF(x1, y1, x2, y2), paintImg);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue