1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-30 22:51:16 +01:00

Fixed broken bounds handling

This commit is contained in:
Martin Tůma 2018-10-09 22:46:28 +02:00
parent 5c6f405795
commit 58b44d33a7

View File

@ -86,17 +86,15 @@ qreal OnlineMap::tileSize() const
void OnlineMap::draw(QPainter *painter, const QRectF &rect, Flags flags) void OnlineMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
{ {
qreal scale = OSM::zoom2scale(_zoom, TILE_SIZE); qreal scale = OSM::zoom2scale(_zoom, TILE_SIZE);
QRectF b(bounds());
QPoint tile = OSM::mercator2tile(QPointF(rect.topLeft().x() * scale, QPoint tile = OSM::mercator2tile(QPointF(rect.topLeft().x() * scale,
-rect.topLeft().y() * scale) * coordinatesRatio(), _zoom); -rect.topLeft().y() * scale) * coordinatesRatio(), _zoom);
QPointF tl(floor(rect.left() / tileSize()) QPointF tl(floor(rect.left() / tileSize())
* tileSize(), floor(rect.top() / tileSize()) * tileSize()); * tileSize(), floor(rect.top() / tileSize()) * tileSize());
QSizeF s(qMin(rect.right() - tl.x(), b.width()), QSizeF s(rect.right() - tl.x(), rect.bottom() - tl.y());
qMin(rect.bottom() - tl.y(), b.height())); int width = _zoom ? qCeil(s.width() / tileSize()) : 1;
int width = qCeil(s.width() / tileSize()); int height = _zoom ? qCeil(s.height() / tileSize()) : 1;
int height = qCeil(s.height() / tileSize());
QVector<Tile> tiles; QVector<Tile> tiles;
tiles.reserve(width * height); tiles.reserve(width * height);