From 6e92557806a972aa411024c7abb9ca694febfcd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Sat, 6 Oct 2018 21:15:06 +0200 Subject: [PATCH] Code cleanup --- src/map/onlinemap.cpp | 5 +++-- src/map/wmsmap.cpp | 15 ++++++++------- src/map/wmtsmap.cpp | 9 +++++---- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/map/onlinemap.cpp b/src/map/onlinemap.cpp index d60cb677..6c8bccc8 100644 --- a/src/map/onlinemap.cpp +++ b/src/map/onlinemap.cpp @@ -1,4 +1,5 @@ #include +#include #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 tiles; tiles.reserve(width * height); diff --git a/src/map/wmsmap.cpp b/src/map/wmsmap.cpp index 3f3f7c03..86f4fb8f 100644 --- a/src/map/wmsmap.cpp +++ b/src/map/wmsmap.cpp @@ -1,5 +1,6 @@ #include #include +#include #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 tiles; tiles.reserve((br.x() - tl.x()) * (br.y() - tl.y())); diff --git a/src/map/wmtsmap.cpp b/src/map/wmtsmap.cpp index 8050d9d4..d529ea6b 100644 --- a/src/map/wmtsmap.cpp +++ b/src/map/wmtsmap.cpp @@ -1,4 +1,5 @@ #include +#include #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 tiles; tiles.reserve((br.x() - tl.x()) * (br.y() - tl.y()));