mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-01-18 19:52:09 +01:00
Code cleanup
This commit is contained in:
parent
86c6fa7b03
commit
c82e97b1ca
@ -100,13 +100,6 @@ static bool parseLevel(const QByteArray &data, int &zoom, int &tileSize,
|
||||
return true;
|
||||
}
|
||||
|
||||
static Coordinates tile2ll(const QPoint &p, int z)
|
||||
{
|
||||
double n = M_PI - 2.0 * M_PI * p.y() / (double)(1 << z);
|
||||
return Coordinates(p.x() / (double)(1 << z) * 360.0 - 180,
|
||||
180.0 / M_PI * atan(0.5 * (exp(n) - exp(-n))));
|
||||
}
|
||||
|
||||
|
||||
bool AQMMap::readSize(size_t &size)
|
||||
{
|
||||
@ -200,8 +193,8 @@ bool AQMMap::readHeader()
|
||||
if (!parseLevel(data, zoom, tileSize, bounds))
|
||||
return false;
|
||||
|
||||
_bounds = RectC(tile2ll(bounds.topLeft(), zoom),
|
||||
tile2ll(bounds.bottomRight(), zoom));
|
||||
_bounds = RectC(OSM::tile2ll(bounds.topLeft(), zoom),
|
||||
OSM::tile2ll(bounds.bottomRight(), zoom));
|
||||
_zooms.append(Zoom(zoom, tileSize));
|
||||
} else if (files.at(i).name == "@LEVEL") {
|
||||
li = i;
|
||||
|
@ -21,6 +21,13 @@ QPoint OSM::mercator2tile(const QPointF &m, int zoom)
|
||||
qFloor((1.0 - (m.y() / 180.0)) / 2.0 * (1<<zoom)));
|
||||
}
|
||||
|
||||
Coordinates OSM::tile2ll(const QPoint &p, int z)
|
||||
{
|
||||
double n = M_PI - 2.0 * M_PI * p.y() / (double)(1 << z);
|
||||
return Coordinates(p.x() / (double)(1 << z) * 360.0 - 180,
|
||||
180.0 / M_PI * atan(0.5 * (exp(n) - exp(-n))));
|
||||
}
|
||||
|
||||
qreal OSM::zoom2scale(int zoom, int tileSize)
|
||||
{
|
||||
return (360.0/(qreal)((1<<zoom) * tileSize));
|
||||
|
@ -15,6 +15,7 @@ namespace OSM
|
||||
QPointF ll2m(const Coordinates &c);
|
||||
Coordinates m2ll(const QPointF &p);
|
||||
QPoint mercator2tile(const QPointF &m, int zoom);
|
||||
Coordinates tile2ll(const QPoint &p, int z);
|
||||
qreal zoom2scale(int zoom, int tileSize);
|
||||
int scale2zoom(qreal scale, int tileSize);
|
||||
qreal resolution(const QPointF &p, int zoom, int tileSize);
|
||||
|
Loading…
x
Reference in New Issue
Block a user