1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-01-18 19:52:09 +01:00

Properly handle Mapsforge world maps

This commit is contained in:
Martin Tůma 2021-05-27 22:07:09 +02:00
parent 441ccc59d0
commit d39bd296f6
2 changed files with 3 additions and 2 deletions

View File

@ -377,6 +377,7 @@ bool MapData::readHeader()
_bounds = RectC(Coordinates(MD(minLon), MD(maxLat)),
Coordinates(MD(maxLon), MD(minLat)));
_bounds &= OSM::BOUNDS;
return true;
}

View File

@ -22,8 +22,8 @@ Coordinates OSM::m2ll(const QPointF &p)
QPoint OSM::mercator2tile(const QPointF &m, int zoom)
{
return QPoint(qFloor((m.x() + 180.0) / 360.0 * (1<<zoom)),
qFloor((1.0 - (m.y() / 180.0)) / 2.0 * (1<<zoom)));
return QPoint(qMin(qFloor((m.x() + 180.0) / 360.0 * (1<<zoom)), (1<<zoom) - 1),
qMin(qFloor((1.0 - (m.y() / 180.0)) / 2.0 * (1<<zoom)), (1<<zoom) - 1));
}
QPointF OSM::tile2mercator(const QPoint &p, int zoom)