mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-04-21 12:49:10 +02:00
Compare commits
No commits in common. "9380f3102288a49db0d1775d15e8541944cef902" and "d4b731aeaf16c6f3f7d0d30118122d753780e2cc" have entirely different histories.
9380f31022
...
d4b731aeaf
@ -382,19 +382,12 @@ void MBTilesMap::cancelJobs(bool wait)
|
||||
_jobs.at(i)->cancel(wait);
|
||||
}
|
||||
|
||||
QPointF MBTilesMap::tilePos(const QPointF &tl, const QPoint &tc,
|
||||
const QPoint &tile, unsigned overzoom) const
|
||||
{
|
||||
return QPointF(tl.x() + ((tc.x() - tile.x()) << overzoom) * tileSize(),
|
||||
tl.y() + ((tc.y() - tile.y()) << overzoom) * tileSize());
|
||||
}
|
||||
|
||||
void MBTilesMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
||||
{
|
||||
const Zoom &zoom = _zooms.at(_zi);
|
||||
unsigned overzoom = zoom.z - zoom.base;
|
||||
unsigned f = 1U<<overzoom;
|
||||
qreal scale = OSM::zoom2scale(zoom.base, _tileSize << overzoom);
|
||||
qreal scale = OSM::zoom2scale(zoom.base, _tileSize * f);
|
||||
QPoint tile = OSM::mercator2tile(QPointF(rect.topLeft().x() * scale,
|
||||
-rect.topLeft().y() * scale) * coordinatesRatio(), zoom.base);
|
||||
Coordinates ctl(OSM::tile2ll(tile, zoom.base));
|
||||
@ -416,7 +409,8 @@ void MBTilesMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
||||
continue;
|
||||
|
||||
if (QPixmapCache::find(key, &pm)) {
|
||||
QPointF tp(tilePos(tl, t, tile, overzoom));
|
||||
QPointF tp(tl.x() + (t.x() - tile.x()) * tileSize() * f,
|
||||
tl.y() + (t.y() - tile.y()) * tileSize() * f);
|
||||
drawTile(painter, pm, tp);
|
||||
} else
|
||||
tiles.append(MBTile(zoom.z, overzoom, _scaledSize, t,
|
||||
@ -437,7 +431,8 @@ void MBTilesMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
||||
|
||||
QPixmapCache::insert(mt.key(), pm);
|
||||
|
||||
QPointF tp(tilePos(tl, mt.xy(), tile, overzoom));
|
||||
QPointF tp(tl.x() + (mt.xy().x() - tile.x()) * tileSize() * f,
|
||||
tl.y() + (mt.xy().y() - tile.y()) * tileSize() * f);
|
||||
drawTile(painter, pm, tp);
|
||||
}
|
||||
} else
|
||||
|
@ -139,8 +139,6 @@ private:
|
||||
void runJob(MBTilesMapJob *job);
|
||||
void removeJob(MBTilesMapJob *job);
|
||||
void cancelJobs(bool wait);
|
||||
QPointF tilePos(const QPointF &tl, const QPoint &tc, const QPoint &tile,
|
||||
unsigned overzoom) const;
|
||||
|
||||
friend QDebug operator<<(QDebug dbg, const Zoom &zoom);
|
||||
|
||||
|
@ -118,18 +118,11 @@ qreal OnlineMap::tileSize() const
|
||||
return (_tileSize / coordinatesRatio());
|
||||
}
|
||||
|
||||
QPoint OnlineMap::tileCoordinates(int x, int y, int zoom) const
|
||||
QPoint OnlineMap::tileCoordinates(int x, int y, int zoom)
|
||||
{
|
||||
return QPoint(x, _invertY ? (1<<zoom) - y - 1 : y);
|
||||
}
|
||||
|
||||
QPointF OnlineMap::tilePos(const QPointF &tl, const QPoint &tc,
|
||||
const QPoint &tile, unsigned overzoom) const
|
||||
{
|
||||
return QPointF(tl.x() + ((tc.x() - tile.x()) << overzoom) * tileSize(),
|
||||
tl.y() + ((tc.y() - tile.y()) << overzoom) * tileSize());
|
||||
}
|
||||
|
||||
bool OnlineMap::isRunning(const QString &key) const
|
||||
{
|
||||
for (int i = 0; i < _jobs.size(); i++) {
|
||||
@ -181,14 +174,14 @@ void OnlineMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
||||
{
|
||||
int baseZoom = qMin(_baseZoom, _zoom);
|
||||
unsigned overzoom = _zoom - baseZoom;
|
||||
unsigned f = 1U<<overzoom;
|
||||
|
||||
qreal scale = OSM::zoom2scale(baseZoom, _tileSize << overzoom);
|
||||
qreal scale = OSM::zoom2scale(baseZoom, _tileSize * f);
|
||||
QPoint tile = OSM::mercator2tile(QPointF(rect.topLeft().x() * scale,
|
||||
-rect.topLeft().y() * scale) * coordinatesRatio(), baseZoom);
|
||||
Coordinates ctl(OSM::tile2ll(tile, baseZoom));
|
||||
QPointF tl(ll2xy(Coordinates(ctl.lon(), -ctl.lat())));
|
||||
QSizeF s(rect.right() - tl.x(), rect.bottom() - tl.y());
|
||||
unsigned f = 1U<<overzoom;
|
||||
int width = ceil(s.width() / (tileSize() * f));
|
||||
int height = ceil(s.height() / (tileSize() * f));
|
||||
|
||||
@ -220,7 +213,8 @@ void OnlineMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
||||
QPixmap pm;
|
||||
if (QPixmapCache::find(key, &pm)) {
|
||||
QPoint tc(tileCoordinates(t.xy().x(), t.xy().y(), baseZoom));
|
||||
QPointF tp(tilePos(tl, tc, tile, overzoom));
|
||||
QPointF tp(tl.x() + (tc.x() - tile.x()) * tileSize() * f,
|
||||
tl.y() + (tc.y() - tile.y()) * tileSize() * f);
|
||||
drawTile(painter, pm, tp);
|
||||
} else
|
||||
renderTiles.append(OnlineMapTile(t.xy(), t.file(), _zoom, overzoom,
|
||||
@ -242,7 +236,8 @@ void OnlineMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
||||
QPixmapCache::insert(mt.key(), pm);
|
||||
|
||||
QPoint tc(tileCoordinates(mt.xy().x(), mt.xy().y(), baseZoom));
|
||||
QPointF tp(tilePos(tl, tc, tile, overzoom));
|
||||
QPointF tp(tl.x() + (tc.x() - tile.x()) * tileSize() * f,
|
||||
tl.y() + (tc.y() - tile.y()) * tileSize() * f);
|
||||
drawTile(painter, pm, tp);
|
||||
}
|
||||
} else
|
||||
|
@ -115,9 +115,7 @@ private:
|
||||
qreal tileSize() const;
|
||||
qreal coordinatesRatio() const;
|
||||
qreal imageRatio() const;
|
||||
QPoint tileCoordinates(int x, int y, int zoom) const;
|
||||
QPointF tilePos(const QPointF &tl, const QPoint &tc, const QPoint &tile,
|
||||
unsigned overzoom) const;
|
||||
QPoint tileCoordinates(int x, int y, int zoom);
|
||||
void drawTile(QPainter *painter, QPixmap &pixmap, QPointF &tp);
|
||||
bool isRunning(const QString &key) const;
|
||||
void runJob(OnlineMapJob *job);
|
||||
|
Loading…
x
Reference in New Issue
Block a user