From cd220216dda409398dfcb174c71aa367336f7479 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Tue, 4 Jul 2023 20:27:41 +0200 Subject: [PATCH] Do not affect the map object scaling when resizing the tiles --- src/map/mapsforge/mapdata.h | 3 +-- src/map/mapsforgemap.cpp | 16 ++++++++-------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/map/mapsforge/mapdata.h b/src/map/mapsforge/mapdata.h index aab80a53..7ebf37ad 100644 --- a/src/map/mapsforge/mapdata.h +++ b/src/map/mapsforge/mapdata.h @@ -59,8 +59,7 @@ public: RectC bounds() const; Range zooms() const {return Range(_subFiles.first().min, _subFiles.last().max);} - int tileSize() const - {return _tileSize < 384 ? _tileSize << 1 : _tileSize;} + int tileSize() const {return _tileSize;} void points(const RectC &rect, int zoom, QList *list); void paths(const RectC &searchRect, const RectC &boundsRect, int zoom, diff --git a/src/map/mapsforgemap.cpp b/src/map/mapsforgemap.cpp index 3f3053b7..766f2c34 100644 --- a/src/map/mapsforgemap.cpp +++ b/src/map/mapsforgemap.cpp @@ -167,18 +167,19 @@ void MapsforgeMap::cancelJobs(bool wait) void MapsforgeMap::draw(QPainter *painter, const QRectF &rect, Flags flags) { - QPointF tl(floor(rect.left() / _data.tileSize()) * _data.tileSize(), - floor(rect.top() / _data.tileSize()) * _data.tileSize()); + int tileSize = (_data.tileSize() < 384) + ? _data.tileSize() << 1 : _data.tileSize(); + QPointF tl(floor(rect.left() / tileSize) * tileSize, + floor(rect.top() / tileSize) * tileSize); QSizeF s(rect.right() - tl.x(), rect.bottom() - tl.y()); - int width = ceil(s.width() / _data.tileSize()); - int height = ceil(s.height() / _data.tileSize()); + int width = ceil(s.width() / tileSize); + int height = ceil(s.height() / tileSize); QList tiles; for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { - QPoint ttl(tl.x() + i * _data.tileSize(), tl.y() + j - * _data.tileSize()); + QPoint ttl(tl.x() + i * tileSize, tl.y() + j * tileSize); if (isRunning(_zoom, ttl)) continue; @@ -187,8 +188,7 @@ void MapsforgeMap::draw(QPainter *painter, const QRectF &rect, Flags flags) painter->drawPixmap(ttl, pm); else { tiles.append(RasterTile(_projection, _transform, &_style, &_data, - _zoom, QRect(ttl, QSize(_data.tileSize(), _data.tileSize())), - _tileRatio)); + _zoom, QRect(ttl, QSize(tileSize, tileSize)), _tileRatio)); } } }