mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-02-21 18:20:47 +01:00
Fixed bounds limiting
This commit is contained in:
parent
bbc03ae59f
commit
04f9457085
@ -1,4 +1,3 @@
|
|||||||
#include <QtCore>
|
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include "common/rectc.h"
|
#include "common/rectc.h"
|
||||||
@ -101,15 +100,11 @@ 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, _tileSize);
|
qreal scale = OSM::zoom2scale(_zoom, _tileSize);
|
||||||
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())
|
Coordinates ctl(OSM::tile2ll(tile, _zoom));
|
||||||
* tileSize(), floor(rect.top() / tileSize()) * tileSize());
|
QPointF tl(ll2xy(Coordinates(ctl.lon(), -ctl.lat())));
|
||||||
|
QSizeF s(rect.right() - tl.x(), rect.bottom() - tl.y());
|
||||||
QSizeF s(qMin(rect.right() - tl.x(), b.width()),
|
|
||||||
qMin(rect.bottom() - tl.y(), b.height()));
|
|
||||||
int width = ceil(s.width() / tileSize());
|
int width = ceil(s.width() / tileSize());
|
||||||
int height = ceil(s.height() / tileSize());
|
int height = ceil(s.height() / tileSize());
|
||||||
|
|
||||||
@ -127,9 +122,10 @@ void OnlineMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
|||||||
|
|
||||||
for (int i = 0; i < tiles.count(); i++) {
|
for (int i = 0; i < tiles.count(); i++) {
|
||||||
FetchTile &t = tiles[i];
|
FetchTile &t = tiles[i];
|
||||||
QPointF tp(qMax(tl.x(), b.left()) + (t.xy().x() - tile.x()) * tileSize(),
|
QPointF tp(tl.x() + (t.xy().x() - tile.x()) * tileSize(),
|
||||||
qMax(tl.y(), b.top()) + ((_invertY ? (1<<_zoom) - t.xy().y() - 1 :
|
tl.y() + ((_invertY
|
||||||
t.xy().y()) - tile.y()) * tileSize());
|
? (1<<_zoom) - t.xy().y() - 1
|
||||||
|
: t.xy().y()) - tile.y()) * tileSize());
|
||||||
|
|
||||||
if (!t.pixmap().isNull()) {
|
if (!t.pixmap().isNull()) {
|
||||||
t.pixmap().setDevicePixelRatio(imageRatio());
|
t.pixmap().setDevicePixelRatio(imageRatio());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user