MapView scale less detailed levels on current level feature

This commit is contained in:
2023-01-20 23:28:08 +03:00
parent c166c040b0
commit 4b8a7a4779
5 changed files with 47 additions and 8 deletions

View File

@@ -32,7 +32,32 @@ void OSMTileCache::tileDownloaded(OSM::TileIndex index, const QPixmap & pixmap)
}
OSM::TilePixmap OSMTileCache::getTile(OSM::TileIndex index) {
OSM::TilePixmap OSMTileCache::getTile(OSM::TileIndex index, QRectF & rect_src) {
OSM::TilePixmap ret = getTileFromCache(index);
if (ret.isEmpty()) {
parent->downloader->queueTile(index);
QVector<QPointF> offsets;
while (index.z >= 0) {
index.z--;
offsets << QPointF(index.x % 2, index.y % 2);
index.x /= 2;
index.y /= 2;
ret = getTileFromCache(index);
if (!ret.isEmpty()) {
for (int i = offsets.size() - 1; i >= 0; --i) {
rect_src.setSize(rect_src.size() / 2.);
rect_src.translate(offsets[i].x() * rect_src.width(), offsets[i].y() * rect_src.height());
}
return ret;
}
}
} else
rect_src = ret.pixmap.rect();
return ret;
}
OSM::TilePixmap OSMTileCache::getTileFromCache(OSM::TileIndex index) {
OSM::TilePixmap ret;
ret.index = index;
auto * tile = tile_cache[index.hash()];
@@ -51,7 +76,6 @@ OSM::TilePixmap OSMTileCache::getTile(OSM::TileIndex index) {
return ret;
}
}
parent->downloader->queueTile(index);
}
return ret;
}