PIQt now provide PICout << operators for Qt types

MapView::setTileObsoleteTime() method. You can set maximum lifetime for tile, after that it will be redownloaded
This commit is contained in:
2024-09-28 09:15:25 +03:00
parent 2eacbfbfc1
commit dd4695780d
7 changed files with 128 additions and 6 deletions

View File

@@ -31,8 +31,10 @@ void OSMTileCache::tileDownloaded(OSM::TileIndex index, const QPixmap & pixmap)
OSM::TilePixmap OSMTileCache::getTile(OSM::TileIndex index, QRectF & rect_src) {
OSM::TilePixmap ret = getTileFromCache(index);
if (ret.isEmpty()) {
if (ret.isEmpty() || ret.obsolete) {
parent->downloader->queueTile(index);
}
if (ret.isEmpty()) {
QVector<QPointF> offsets;
while (index.z >= 0) {
index.z--;
@@ -81,10 +83,15 @@ OSM::TilePixmap OSMTileCache::getTileFromCache(OSM::TileIndex index) {
if (cache_dir.exists(hashdir)) {
QString hashname = hashdir + "/" + index.hashName();
if (cache_dir.exists(hashname)) {
ret.pixmap.load(cache_dir.absoluteFilePath(hashname), "png");
QString fname = cache_dir.absoluteFilePath(hashname);
ret.pixmap.load(fname, "png");
tile = new OSM::TilePixmap();
tile->index = index;
tile->pixmap = ret.pixmap;
if (secs_obsolete > 0) {
int secs_old = QFileInfo(fname).lastModified().secsTo(QDateTime::currentDateTime());
ret.obsolete = secs_old >= secs_obsolete;
}
tile_cache.insert(tile->index.hash(), tile, tile->pixmapBytes());
return ret;
}