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

Optimization

This commit is contained in:
Martin Tůma 2017-01-07 22:20:04 +01:00
parent 3e340ab941
commit 1586a5e912
2 changed files with 5 additions and 5 deletions

View File

@ -23,8 +23,8 @@ static QPoint mercator2tile(const QPointF &m, int z)
{
QPoint tile;
tile.setX((int)(floor((m.x() + 180.0) / 360.0 * pow(2.0, z))));
tile.setY((int)(floor((1.0 - (m.y() / 180.0)) / 2.0 * pow(2.0, z))));
tile.setX((int)(floor((m.x() + 180.0) / 360.0 * (1<<z))));
tile.setY((int)(floor((1.0 - (m.y() / 180.0)) / 2.0 * (1<<z))));
return tile;
}
@ -33,8 +33,8 @@ static QPointF tile2mercator(const QPoint &tile, int z)
{
Coordinates m;
m.setLon(tile.x() / pow(2.0, z) * 360.0 - 180);
qreal n = M_PI - 2.0 * M_PI * tile.y() / pow(2.0, z);
m.setLon(tile.x() / (qreal)(1<<z) * 360.0 - 180.0);
qreal n = M_PI - 2.0 * M_PI * tile.y() / (qreal)(1<<z);
m.setLat(rad2deg(atan(0.5 * (exp(n) - exp(-n)))));
return m.toMercator();

View File

@ -16,7 +16,7 @@
static qreal zoom2resolution(int zoom, qreal y)
{
return (WGS84_RADIUS * 2 * M_PI / Tile::size()
* cos(2 * atan(exp(deg2rad(y))) - M_PI/2)) / pow(2.0, zoom);
* cos(2 * atan(exp(deg2rad(y))) - M_PI/2)) / (qreal)(1<<zoom);
}
ScaleItem::ScaleItem(QGraphicsItem *parent) : QGraphicsItem(parent)