Mapsforge fix map clipping on small zooms (#526)

This commit is contained in:
Gustl22 2018-04-13 18:56:31 +02:00 committed by Emux
parent d1f9a4e8f6
commit 11de89536d
No known key found for this signature in database
GPG Key ID: 89C6921D7AF2BDD0

View File

@ -407,14 +407,12 @@ public class MapDatabase implements ITileDataSource {
} }
} }
// private long mCurrentRow; private void setTileClipping(QueryParameters queryParameters, SubFileParameter subFileParameter,
// private long mCurrentCol; long currentRow, long currentCol) {
private void setTileClipping(QueryParameters queryParameters, long mCurrentRow, long mCurrentCol) {
long numRows = queryParameters.toBlockY - queryParameters.fromBlockY; long numRows = queryParameters.toBlockY - queryParameters.fromBlockY;
long numCols = queryParameters.toBlockX - queryParameters.fromBlockX; long numCols = queryParameters.toBlockX - queryParameters.fromBlockX;
//log.debug(numCols + "/" + numRows + " " + mCurrentCol + " " + mCurrentRow); //log.debug(numCols + "/" + numRows + " " + currentCol + " " + currentRow);
// At large query zoom levels use enlarged buffer // At large query zoom levels use enlarged buffer
int buffer; int buffer;
@ -434,20 +432,30 @@ public class MapDatabase implements ITileDataSource {
int ySmax = Tile.SIZE; int ySmax = Tile.SIZE;
if (numRows > 0) { if (numRows > 0) {
int w = (int) (Tile.SIZE / (numCols + 1)); /* If blocks are at a border, sometimes too less blocks are requested,
int h = (int) (Tile.SIZE / (numRows + 1)); * so the divisor for tile dimensions is increased to base tile subdivision.
*/
boolean isTopBorder = queryParameters.fromBaseTileY < subFileParameter.boundaryTileTop;
boolean isLeftBorder = queryParameters.fromBaseTileX < subFileParameter.boundaryTileLeft;
long numSubX = queryParameters.toBaseTileX - queryParameters.fromBaseTileX;
long numSubY = queryParameters.toBaseTileY - queryParameters.fromBaseTileY;
long numDifX = numSubX - numCols; // 0 except at map borders
long numDifY = numSubY - numRows; // 0 except at map borders
if (mCurrentCol > 0) int w = (int) (Tile.SIZE / (numSubX + 1));
xSmin = xmin = (int) (mCurrentCol * w); int h = (int) (Tile.SIZE / (numSubY + 1));
if (mCurrentCol < numCols) if (currentCol > 0)
xSmax = xmax = (int) (mCurrentCol * w + w); xSmin = xmin = (int) ((currentCol + (isLeftBorder ? numDifX : 0)) * w);
if (mCurrentRow > 0) if (currentCol < numCols)
ySmin = ymin = (int) (mCurrentRow * h); xSmax = xmax = (int) ((currentCol + (isLeftBorder ? numDifX : 0)) * w + w);
if (mCurrentRow < numRows) if (currentRow > 0)
ySmax = ymax = (int) (mCurrentRow * h + h); ySmin = ymin = (int) ((currentRow + (isTopBorder ? numDifY : 0)) * h);
if (currentRow < numRows)
ySmax = ymax = (int) ((currentRow + (isTopBorder ? numDifY : 0)) * h + h);
} }
mTileClipper.setRect(xmin, ymin, xmax, ymax); mTileClipper.setRect(xmin, ymin, xmax, ymax);
mTileSeparator.setRect(xSmin, ySmin, xSmax, ySmax); mTileSeparator.setRect(xSmin, ySmin, xSmax, ySmax);
@ -479,10 +487,7 @@ public class MapDatabase implements ITileDataSource {
/* read and process all blocks from top to bottom and from left to right */ /* read and process all blocks from top to bottom and from left to right */
for (long row = queryParams.fromBlockY; row <= queryParams.toBlockY; row++) { for (long row = queryParams.fromBlockY; row <= queryParams.toBlockY; row++) {
for (long column = queryParams.fromBlockX; column <= queryParams.toBlockX; column++) { for (long column = queryParams.fromBlockX; column <= queryParams.toBlockX; column++) {
//mCurrentCol = column - queryParameters.fromBlockX; setTileClipping(queryParams, subFileParameter,
//mCurrentRow = row - queryParameters.fromBlockY;
setTileClipping(queryParams,
row - queryParams.fromBlockY, row - queryParams.fromBlockY,
column - queryParams.fromBlockX); column - queryParams.fromBlockX);