1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-28 05:34:47 +01:00

Use a more accurate and faster top left xy coordinate computation

This commit is contained in:
Martin Tůma 2024-02-04 17:42:36 +01:00
parent e726a45dcf
commit a3bac33bf4
6 changed files with 13 additions and 13 deletions

View File

@ -348,8 +348,8 @@ void AQMMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
qreal scale = OSM::zoom2scale(z.zoom, z.tileSize); qreal scale = OSM::zoom2scale(z.zoom, z.tileSize);
QPoint tile = OSM::mercator2tile(QPointF(rect.topLeft().x() * scale, QPoint tile = OSM::mercator2tile(QPointF(rect.topLeft().x() * scale,
-rect.topLeft().y() * scale) * _mapRatio, z.zoom); -rect.topLeft().y() * scale) * _mapRatio, z.zoom);
Coordinates ctl(OSM::tile2ll(tile, z.zoom)); QPointF tlm(OSM::tile2mercator(tile, z.zoom));
QPointF tl(ll2xy(Coordinates(ctl.lon(), -ctl.lat()))); QPointF tl(QPointF(tlm.x() / scale, tlm.y() / scale) / _mapRatio);
QSizeF s(rect.right() - tl.x(), rect.bottom() - tl.y()); QSizeF s(rect.right() - tl.x(), rect.bottom() - tl.y());
int width = ceil(s.width() / tileSize()); int width = ceil(s.width() / tileSize());
int height = ceil(s.height() / tileSize()); int height = ceil(s.height() / tileSize());

View File

@ -245,8 +245,8 @@ void GEMFMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
qreal scale = OSM::zoom2scale(z.level, _tileSize); qreal scale = OSM::zoom2scale(z.level, _tileSize);
QPoint tile = OSM::mercator2tile(QPointF(rect.topLeft().x() * scale, QPoint tile = OSM::mercator2tile(QPointF(rect.topLeft().x() * scale,
-rect.topLeft().y() * scale) * _mapRatio, z.level); -rect.topLeft().y() * scale) * _mapRatio, z.level);
Coordinates ctl(OSM::tile2ll(tile, z.level)); QPointF tlm(OSM::tile2mercator(tile, z.level));
QPointF tl(ll2xy(Coordinates(ctl.lon(), -ctl.lat()))); QPointF tl(QPointF(tlm.x() / scale, tlm.y() / scale) / _mapRatio);
QSizeF s(rect.right() - tl.x(), rect.bottom() - tl.y()); QSizeF s(rect.right() - tl.x(), rect.bottom() - tl.y());
int width = ceil(s.width() / tileSize()); int width = ceil(s.width() / tileSize());
int height = ceil(s.height() / tileSize()); int height = ceil(s.height() / tileSize());

View File

@ -393,13 +393,13 @@ void MBTilesMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
{ {
const Zoom &zoom = _zooms.at(_zi); const Zoom &zoom = _zooms.at(_zi);
unsigned overzoom = zoom.z - zoom.base; 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 << overzoom);
QPoint tile = OSM::mercator2tile(QPointF(rect.topLeft().x() * scale, QPoint tile = OSM::mercator2tile(QPointF(rect.topLeft().x() * scale,
-rect.topLeft().y() * scale) * coordinatesRatio(), zoom.base); -rect.topLeft().y() * scale) * coordinatesRatio(), zoom.base);
Coordinates ctl(OSM::tile2ll(tile, zoom.base)); QPointF tlm(OSM::tile2mercator(tile, zoom.base));
QPointF tl(ll2xy(Coordinates(ctl.lon(), -ctl.lat()))); QPointF tl(QPointF(tlm.x() / scale, tlm.y() / scale) / coordinatesRatio());
QSizeF s(rect.right() - tl.x(), rect.bottom() - tl.y()); QSizeF s(rect.right() - tl.x(), rect.bottom() - tl.y());
unsigned f = 1U<<overzoom;
int width = ceil(s.width() / (tileSize() * f)); int width = ceil(s.width() / (tileSize() * f));
int height = ceil(s.height() / (tileSize() * f)); int height = ceil(s.height() / (tileSize() * f));

View File

@ -185,8 +185,8 @@ void OnlineMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
qreal scale = OSM::zoom2scale(baseZoom, _tileSize << overzoom); qreal scale = OSM::zoom2scale(baseZoom, _tileSize << overzoom);
QPoint tile = OSM::mercator2tile(QPointF(rect.topLeft().x() * scale, QPoint tile = OSM::mercator2tile(QPointF(rect.topLeft().x() * scale,
-rect.topLeft().y() * scale) * coordinatesRatio(), baseZoom); -rect.topLeft().y() * scale) * coordinatesRatio(), baseZoom);
Coordinates ctl(OSM::tile2ll(tile, baseZoom)); QPointF tlm(OSM::tile2mercator(tile, baseZoom));
QPointF tl(ll2xy(Coordinates(ctl.lon(), -ctl.lat()))); QPointF tl(QPointF(tlm.x() / scale, tlm.y() / scale) / coordinatesRatio());
QSizeF s(rect.right() - tl.x(), rect.bottom() - tl.y()); QSizeF s(rect.right() - tl.x(), rect.bottom() - tl.y());
unsigned f = 1U<<overzoom; unsigned f = 1U<<overzoom;
int width = ceil(s.width() / (tileSize() * f)); int width = ceil(s.width() / (tileSize() * f));

View File

@ -240,8 +240,8 @@ void OsmdroidMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
qreal scale = OSM::zoom2scale(_zoom, _tileSize); qreal scale = OSM::zoom2scale(_zoom, _tileSize);
QPoint tile = OSM::mercator2tile(QPointF(rect.topLeft().x() * scale, QPoint tile = OSM::mercator2tile(QPointF(rect.topLeft().x() * scale,
-rect.topLeft().y() * scale) * _mapRatio, _zoom); -rect.topLeft().y() * scale) * _mapRatio, _zoom);
Coordinates ctl(OSM::tile2ll(tile, _zoom)); QPointF tlm(OSM::tile2mercator(tile, _zoom));
QPointF tl(ll2xy(Coordinates(ctl.lon(), -ctl.lat()))); QPointF tl(QPointF(tlm.x() / scale, tlm.y() / scale) / _mapRatio);
QSizeF s(rect.right() - tl.x(), rect.bottom() - tl.y()); QSizeF s(rect.right() - tl.x(), rect.bottom() - tl.y());
int width = ceil(s.width() / tileSize()); int width = ceil(s.width() / tileSize());
int height = ceil(s.height() / tileSize()); int height = ceil(s.height() / tileSize());

View File

@ -187,8 +187,8 @@ void SqliteMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
qreal scale = OSM::zoom2scale(_zoom, _tileSize); qreal scale = OSM::zoom2scale(_zoom, _tileSize);
QPoint tile = OSM::mercator2tile(QPointF(rect.topLeft().x() * scale, QPoint tile = OSM::mercator2tile(QPointF(rect.topLeft().x() * scale,
-rect.topLeft().y() * scale) * _mapRatio, _zoom); -rect.topLeft().y() * scale) * _mapRatio, _zoom);
Coordinates ctl(OSM::tile2ll(tile, _zoom)); QPointF tlm(OSM::tile2mercator(tile, _zoom));
QPointF tl(ll2xy(Coordinates(ctl.lon(), -ctl.lat()))); QPointF tl(QPointF(tlm.x() / scale, tlm.y() / scale) / _mapRatio);
QSizeF s(rect.right() - tl.x(), rect.bottom() - tl.y()); QSizeF s(rect.right() - tl.x(), rect.bottom() - tl.y());
int width = ceil(s.width() / tileSize()); int width = ceil(s.width() / tileSize());
int height = ceil(s.height() / tileSize()); int height = ceil(s.height() / tileSize());