1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-24 11:45:53 +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 <QPainter>
#include <QtMath>
#include "common/rectc.h" #include "common/rectc.h"
#include "downloader.h" #include "downloader.h"
#include "osm.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()), QSizeF s(qMin(rect.right() - tl.x(), b.width()),
qMin(rect.bottom() - tl.y(), b.height())); qMin(rect.bottom() - tl.y(), b.height()));
int width = ceil(s.width() / tileSize()); int width = qCeil(s.width() / tileSize());
int height = ceil(s.height() / tileSize()); int height = qCeil(s.height() / tileSize());
QVector<Tile> tiles; QVector<Tile> tiles;
tiles.reserve(width * height); tiles.reserve(width * height);

View File

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

View File

@ -1,4 +1,5 @@
#include <QPainter> #include <QPainter>
#include <QtMath>
#include "common/rectc.h" #include "common/rectc.h"
#include "common/wgs84.h" #include "common/wgs84.h"
#include "config.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); const WMTS::Zoom &z = _zooms.at(_zoom);
QSizeF ts(tileSize(z)); QSizeF ts(tileSize(z));
QPoint tl = QPoint((int)floor(rect.left() / ts.width()), QPoint tl = QPoint(qFloor(rect.left() / ts.width()),
(int)floor(rect.top() / ts.height())); qFloor(rect.top() / ts.height()));
QPoint br = QPoint((int)ceil(rect.right() / ts.width()), QPoint br = QPoint(qCeil(rect.right() / ts.width()),
(int)ceil(rect.bottom() / ts.height())); qCeil(rect.bottom() / ts.height()));
QVector<Tile> tiles; QVector<Tile> tiles;
tiles.reserve((br.x() - tl.x()) * (br.y() - tl.y())); tiles.reserve((br.x() - tl.x()) * (br.y() - tl.y()));