mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-01-19 04:02:09 +01:00
Code cleanup
This commit is contained in:
parent
bd946fb477
commit
a458b82e37
@ -31,13 +31,12 @@ static QPoint mercator2tile(const QPointF &m, int z)
|
|||||||
|
|
||||||
static QPointF tile2mercator(const QPoint &tile, int z)
|
static QPointF tile2mercator(const QPoint &tile, int z)
|
||||||
{
|
{
|
||||||
Coordinates m;
|
QPointF m;
|
||||||
|
|
||||||
m.setLon(tile.x() / (qreal)(1<<z) * 360.0 - 180.0);
|
m.setX(((360.0 * tile.x()) / (qreal)(1<<z)) - 180.0);
|
||||||
qreal n = M_PI - 2.0 * M_PI * tile.y() / (qreal)(1<<z);
|
m.setY((1.0 - (2.0 * tile.y()) / (qreal)(1<<z)) * 180.0);
|
||||||
m.setLat(rad2deg(atan(0.5 * (exp(n) - exp(-n)))));
|
|
||||||
|
|
||||||
return m.toMercator();
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int scale2zoom(qreal scale)
|
static int scale2zoom(qreal scale)
|
||||||
@ -660,15 +659,13 @@ void PathView::drawBackground(QPainter *painter, const QRectF &rect)
|
|||||||
QPoint tile = mercator2tile(QPointF(rr.topLeft().x(), -rr.topLeft().y()),
|
QPoint tile = mercator2tile(QPointF(rr.topLeft().x(), -rr.topLeft().y()),
|
||||||
_zoom);
|
_zoom);
|
||||||
QPointF tm = tile2mercator(tile, _zoom);
|
QPointF tm = tile2mercator(tile, _zoom);
|
||||||
QPoint tl = mapToScene(mapFromScene(QPointF(tm.x() / scale,
|
QPoint tl = QPoint((int)(tm.x() / scale), (int)(-tm.y() / scale));
|
||||||
-tm.y() / scale))).toPoint();
|
|
||||||
|
|
||||||
QList<Tile> tiles;
|
QList<Tile> tiles;
|
||||||
for (int i = 0; i <= rr.size().width() / Tile::size() + 1; i++) {
|
for (int i = 0; i <= rr.size().width() / Tile::size() + 1; i++)
|
||||||
for (int j = 0; j <= rr.size().height() / Tile::size() + 1; j++) {
|
for (int j = 0; j <= rr.size().height() / Tile::size() + 1; j++)
|
||||||
tiles.append(Tile(QPoint(tile.x() + i, tile.y() + j), _zoom));
|
tiles.append(Tile(QPoint(tile.x() + i, tile.y() + j), _zoom));
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_map->loadTiles(tiles, _plot);
|
_map->loadTiles(tiles, _plot);
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
static qreal zoom2resolution(int zoom, qreal y)
|
static qreal zoom2resolution(int zoom, qreal y)
|
||||||
{
|
{
|
||||||
return (WGS84_RADIUS * 2 * M_PI / Tile::size()
|
return (WGS84_RADIUS * 2 * M_PI / Tile::size()
|
||||||
* cos(2 * atan(exp(deg2rad(y))) - M_PI/2)) / (qreal)(1<<zoom);
|
* cos(2.0 * atan(exp(deg2rad(y))) - M_PI/2)) / (qreal)(1<<zoom);
|
||||||
}
|
}
|
||||||
|
|
||||||
ScaleItem::ScaleItem(QGraphicsItem *parent) : QGraphicsItem(parent)
|
ScaleItem::ScaleItem(QGraphicsItem *parent) : QGraphicsItem(parent)
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
#include <QCursor>
|
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include "format.h"
|
#include "format.h"
|
||||||
#include "tooltip.h"
|
#include "tooltip.h"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user