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

Code cleanup

This commit is contained in:
Martin Tůma 2018-10-06 21:15:06 +02:00
parent a3625ac89d
commit 6e92557806
3 changed files with 16 additions and 13 deletions

View File

@ -1,4 +1,5 @@
#include <QPainter>
#include <QtMath>
#include "common/rectc.h"
#include "downloader.h"
#include "osm.h"
@ -94,8 +95,8 @@ void OnlineMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
QSizeF s(qMin(rect.right() - tl.x(), b.width()),
qMin(rect.bottom() - tl.y(), b.height()));
int width = ceil(s.width() / tileSize());
int height = ceil(s.height() / tileSize());
int width = qCeil(s.width() / tileSize());
int height = qCeil(s.height() / tileSize());
QVector<Tile> tiles;
tiles.reserve(width * height);

View File

@ -1,5 +1,6 @@
#include <QDir>
#include <QPainter>
#include <QtMath>
#include "common/wgs84.h"
#include "common/rectc.h"
#include "config.h"
@ -50,9 +51,9 @@ void WMSMap::computeZooms(const RangeF &scaleDenominator)
if (scaleDenominator.size() > 0) {
double ld = log2(scaleDenominator.max()) - log2(scaleDenominator.min());
int cld = ceil(ld);
double step = ld / (qreal)cld;
qreal lmax = log2(scaleDenominator.max());
int cld = (int)ceil(ld);
double step = ld / (double)cld;
double lmax = log2(scaleDenominator.max());
for (int i = 0; i <= cld; i++)
_zooms.append(pow(2.0, lmax - i * step));
} else
@ -188,10 +189,10 @@ qreal WMSMap::tileSize() const
void WMSMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
{
QPoint tl = QPoint((int)floor(rect.left() / tileSize()),
(int)floor(rect.top() / tileSize()));
QPoint br = QPoint((int)ceil(rect.right() / tileSize()),
(int)ceil(rect.bottom() / tileSize()));
QPoint tl = QPoint(qFloor(rect.left() / tileSize()),
qFloor(rect.top() / tileSize()));
QPoint br = QPoint(qCeil(rect.right() / tileSize()),
qCeil(rect.bottom() / tileSize()));
QVector<Tile> tiles;
tiles.reserve((br.x() - tl.x()) * (br.y() - tl.y()));

View File

@ -1,4 +1,5 @@
#include <QPainter>
#include <QtMath>
#include "common/rectc.h"
#include "common/wgs84.h"
#include "config.h"
@ -168,10 +169,10 @@ void WMTSMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
const WMTS::Zoom &z = _zooms.at(_zoom);
QSizeF ts(tileSize(z));
QPoint tl = QPoint((int)floor(rect.left() / ts.width()),
(int)floor(rect.top() / ts.height()));
QPoint br = QPoint((int)ceil(rect.right() / ts.width()),
(int)ceil(rect.bottom() / ts.height()));
QPoint tl = QPoint(qFloor(rect.left() / ts.width()),
qFloor(rect.top() / ts.height()));
QPoint br = QPoint(qCeil(rect.right() / ts.width()),
qCeil(rect.bottom() / ts.height()));
QVector<Tile> tiles;
tiles.reserve((br.x() - tl.x()) * (br.y() - tl.y()));