mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-24 11:45:53 +01:00
Code cleanup
This commit is contained in:
parent
90c1e52fb5
commit
97fdcfdd74
@ -5,31 +5,12 @@
|
|||||||
#include <QBuffer>
|
#include <QBuffer>
|
||||||
#include <QtConcurrent>
|
#include <QtConcurrent>
|
||||||
#include "osm.h"
|
#include "osm.h"
|
||||||
|
#include "tile.h"
|
||||||
#include "aqmmap.h"
|
#include "aqmmap.h"
|
||||||
|
|
||||||
|
|
||||||
#define MAGIC "FLATPACK1"
|
#define MAGIC "FLATPACK1"
|
||||||
|
|
||||||
class AQTile
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
AQTile(const QPoint &xy, const QByteArray &data, const QString &key)
|
|
||||||
: _xy(xy), _data(data), _key(key) {}
|
|
||||||
|
|
||||||
const QPoint &xy() const {return _xy;}
|
|
||||||
const QString &key() const {return _key;}
|
|
||||||
const QPixmap &pixmap() const {return _pixmap;}
|
|
||||||
|
|
||||||
void load() {_pixmap.loadFromData(_data);}
|
|
||||||
|
|
||||||
private:
|
|
||||||
QPoint _xy;
|
|
||||||
QByteArray _data;
|
|
||||||
QString _key;
|
|
||||||
QPixmap _pixmap;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static bool parseHeader(const QByteArray &data, QString &name)
|
static bool parseHeader(const QByteArray &data, QString &name)
|
||||||
{
|
{
|
||||||
QList<QByteArray> lines = data.split('\n');
|
QList<QByteArray> lines = data.split('\n');
|
||||||
@ -380,7 +361,7 @@ void AQMMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
|||||||
int height = ceil(s.height() / tileSize());
|
int height = ceil(s.height() / tileSize());
|
||||||
|
|
||||||
|
|
||||||
QList<AQTile> tiles;
|
QList<RenderTile> tiles;
|
||||||
|
|
||||||
for (int i = 0; i < width; i++) {
|
for (int i = 0; i < width; i++) {
|
||||||
for (int j = 0; j < height; j++) {
|
for (int j = 0; j < height; j++) {
|
||||||
@ -395,16 +376,16 @@ void AQMMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
|||||||
* tileSize());
|
* tileSize());
|
||||||
drawTile(painter, pm, tp);
|
drawTile(painter, pm, tp);
|
||||||
} else {
|
} else {
|
||||||
tiles.append(AQTile(t, tileData(t), key));
|
tiles.append(RenderTile(t, tileData(t), key));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QFuture<void> future = QtConcurrent::map(tiles, &AQTile::load);
|
QFuture<void> future = QtConcurrent::map(tiles, &RenderTile::load);
|
||||||
future.waitForFinished();
|
future.waitForFinished();
|
||||||
|
|
||||||
for (int i = 0; i < tiles.size(); i++) {
|
for (int i = 0; i < tiles.size(); i++) {
|
||||||
const AQTile &mt = tiles.at(i);
|
const RenderTile &mt = tiles.at(i);
|
||||||
QPixmap pm(mt.pixmap());
|
QPixmap pm(mt.pixmap());
|
||||||
if (pm.isNull())
|
if (pm.isNull())
|
||||||
continue;
|
continue;
|
||||||
|
@ -108,11 +108,11 @@ void OnlineMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
|||||||
int width = _zoom ? qCeil(s.width() / tileSize()) : 1;
|
int width = _zoom ? qCeil(s.width() / tileSize()) : 1;
|
||||||
int height = _zoom ? qCeil(s.height() / tileSize()) : 1;
|
int height = _zoom ? qCeil(s.height() / tileSize()) : 1;
|
||||||
|
|
||||||
QVector<Tile> tiles;
|
QVector<FetchTile> tiles;
|
||||||
tiles.reserve(width * height);
|
tiles.reserve(width * height);
|
||||||
for (int i = 0; i < width; i++)
|
for (int i = 0; i < width; i++)
|
||||||
for (int j = 0; j < height; j++)
|
for (int j = 0; j < height; j++)
|
||||||
tiles.append(Tile(QPoint(tile.x() + i, _invertY ? (1<<_zoom)
|
tiles.append(FetchTile(QPoint(tile.x() + i, _invertY ? (1<<_zoom)
|
||||||
- (tile.y() + j) - 1 : tile.y() + j), _zoom));
|
- (tile.y() + j) - 1 : tile.y() + j), _zoom));
|
||||||
|
|
||||||
if (flags & Map::Block)
|
if (flags & Map::Block)
|
||||||
@ -121,7 +121,7 @@ void OnlineMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
|||||||
_tileLoader->loadTilesAsync(tiles);
|
_tileLoader->loadTilesAsync(tiles);
|
||||||
|
|
||||||
for (int i = 0; i < tiles.count(); i++) {
|
for (int i = 0; i < tiles.count(); i++) {
|
||||||
Tile &t = tiles[i];
|
FetchTile &t = tiles[i];
|
||||||
QPointF tp = _zoom ? QPointF(tl.x() + (t.xy().x() - tile.x())
|
QPointF tp = _zoom ? QPointF(tl.x() + (t.xy().x() - tile.x())
|
||||||
* tileSize(), tl.y() + ((_invertY ? (1<<_zoom) - t.xy().y() - 1 :
|
* tileSize(), tl.y() + ((_invertY ? (1<<_zoom) - t.xy().y() - 1 :
|
||||||
t.xy().y()) - tile.y()) * tileSize())
|
t.xy().y()) - tile.y()) * tileSize())
|
||||||
|
@ -7,31 +7,12 @@
|
|||||||
#include <QBuffer>
|
#include <QBuffer>
|
||||||
#include <QtConcurrent>
|
#include <QtConcurrent>
|
||||||
#include "osm.h"
|
#include "osm.h"
|
||||||
|
#include "tile.h"
|
||||||
#include "osmdroidmap.h"
|
#include "osmdroidmap.h"
|
||||||
|
|
||||||
|
|
||||||
#define META_TYPE(type) static_cast<QMetaType::Type>(type)
|
#define META_TYPE(type) static_cast<QMetaType::Type>(type)
|
||||||
|
|
||||||
class OsmdroidTile
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
OsmdroidTile(const QPoint &xy, const QByteArray &data, const QString &key)
|
|
||||||
: _xy(xy), _data(data), _key(key) {}
|
|
||||||
|
|
||||||
const QPoint &xy() const {return _xy;}
|
|
||||||
const QString &key() const {return _key;}
|
|
||||||
const QPixmap &pixmap() const {return _pixmap;}
|
|
||||||
|
|
||||||
void load() {_pixmap.loadFromData(_data);}
|
|
||||||
|
|
||||||
private:
|
|
||||||
QPoint _xy;
|
|
||||||
QByteArray _data;
|
|
||||||
QString _key;
|
|
||||||
QPixmap _pixmap;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
OsmdroidMap::OsmdroidMap(const QString &fileName, QObject *parent)
|
OsmdroidMap::OsmdroidMap(const QString &fileName, QObject *parent)
|
||||||
: Map(fileName, parent), _mapRatio(1.0), _valid(false)
|
: Map(fileName, parent), _mapRatio(1.0), _valid(false)
|
||||||
{
|
{
|
||||||
@ -268,7 +249,7 @@ void OsmdroidMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
|||||||
int height = ceil(s.height() / tileSize());
|
int height = ceil(s.height() / tileSize());
|
||||||
|
|
||||||
|
|
||||||
QList<OsmdroidTile> tiles;
|
QList<RenderTile> tiles;
|
||||||
|
|
||||||
for (int i = 0; i < width; i++) {
|
for (int i = 0; i < width; i++) {
|
||||||
for (int j = 0; j < height; j++) {
|
for (int j = 0; j < height; j++) {
|
||||||
@ -283,16 +264,16 @@ void OsmdroidMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
|||||||
* tileSize());
|
* tileSize());
|
||||||
drawTile(painter, pm, tp);
|
drawTile(painter, pm, tp);
|
||||||
} else {
|
} else {
|
||||||
tiles.append(OsmdroidTile(t, tileData(_zoom, t), key));
|
tiles.append(RenderTile(t, tileData(_zoom, t), key));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QFuture<void> future = QtConcurrent::map(tiles, &OsmdroidTile::load);
|
QFuture<void> future = QtConcurrent::map(tiles, &RenderTile::load);
|
||||||
future.waitForFinished();
|
future.waitForFinished();
|
||||||
|
|
||||||
for (int i = 0; i < tiles.size(); i++) {
|
for (int i = 0; i < tiles.size(); i++) {
|
||||||
const OsmdroidTile &mt = tiles.at(i);
|
const RenderTile &mt = tiles.at(i);
|
||||||
QPixmap pm(mt.pixmap());
|
QPixmap pm(mt.pixmap());
|
||||||
if (pm.isNull())
|
if (pm.isNull())
|
||||||
continue;
|
continue;
|
||||||
|
@ -7,31 +7,12 @@
|
|||||||
#include <QBuffer>
|
#include <QBuffer>
|
||||||
#include <QtConcurrent>
|
#include <QtConcurrent>
|
||||||
#include "osm.h"
|
#include "osm.h"
|
||||||
|
#include "tile.h"
|
||||||
#include "sqlitemap.h"
|
#include "sqlitemap.h"
|
||||||
|
|
||||||
|
|
||||||
#define META_TYPE(type) static_cast<QMetaType::Type>(type)
|
#define META_TYPE(type) static_cast<QMetaType::Type>(type)
|
||||||
|
|
||||||
class SqliteTile
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
SqliteTile(const QPoint &xy, const QByteArray &data, const QString &key)
|
|
||||||
: _xy(xy), _data(data), _key(key) {}
|
|
||||||
|
|
||||||
const QPoint &xy() const {return _xy;}
|
|
||||||
const QString &key() const {return _key;}
|
|
||||||
const QPixmap &pixmap() const {return _pixmap;}
|
|
||||||
|
|
||||||
void load() {_pixmap.loadFromData(_data);}
|
|
||||||
|
|
||||||
private:
|
|
||||||
QPoint _xy;
|
|
||||||
QByteArray _data;
|
|
||||||
QString _key;
|
|
||||||
QPixmap _pixmap;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
SqliteMap::SqliteMap(const QString &fileName, QObject *parent)
|
SqliteMap::SqliteMap(const QString &fileName, QObject *parent)
|
||||||
: Map(fileName, parent), _mapRatio(1.0), _valid(false)
|
: Map(fileName, parent), _mapRatio(1.0), _valid(false)
|
||||||
{
|
{
|
||||||
@ -215,7 +196,7 @@ void SqliteMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
|||||||
int height = ceil(s.height() / tileSize());
|
int height = ceil(s.height() / tileSize());
|
||||||
|
|
||||||
|
|
||||||
QList<SqliteTile> tiles;
|
QList<RenderTile> tiles;
|
||||||
|
|
||||||
for (int i = 0; i < width; i++) {
|
for (int i = 0; i < width; i++) {
|
||||||
for (int j = 0; j < height; j++) {
|
for (int j = 0; j < height; j++) {
|
||||||
@ -230,16 +211,16 @@ void SqliteMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
|||||||
* tileSize());
|
* tileSize());
|
||||||
drawTile(painter, pm, tp);
|
drawTile(painter, pm, tp);
|
||||||
} else {
|
} else {
|
||||||
tiles.append(SqliteTile(t, tileData(_zoom, t), key));
|
tiles.append(RenderTile(t, tileData(_zoom, t), key));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QFuture<void> future = QtConcurrent::map(tiles, &SqliteTile::load);
|
QFuture<void> future = QtConcurrent::map(tiles, &RenderTile::load);
|
||||||
future.waitForFinished();
|
future.waitForFinished();
|
||||||
|
|
||||||
for (int i = 0; i < tiles.size(); i++) {
|
for (int i = 0; i < tiles.size(); i++) {
|
||||||
const SqliteTile &mt = tiles.at(i);
|
const RenderTile &mt = tiles.at(i);
|
||||||
QPixmap pm(mt.pixmap());
|
QPixmap pm(mt.pixmap());
|
||||||
if (pm.isNull())
|
if (pm.isNull())
|
||||||
continue;
|
continue;
|
||||||
|
@ -7,11 +7,11 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include "rectd.h"
|
#include "rectd.h"
|
||||||
|
|
||||||
class Tile
|
class FetchTile
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Tile() {}
|
FetchTile() {}
|
||||||
Tile(const QPoint &xy, const QVariant &zoom, const RectD &bbox = RectD())
|
FetchTile(const QPoint &xy, const QVariant &zoom, const RectD &bbox = RectD())
|
||||||
: _xy(xy), _zoom(zoom), _bbox(bbox) {}
|
: _xy(xy), _zoom(zoom), _bbox(bbox) {}
|
||||||
|
|
||||||
const QVariant &zoom() const {return _zoom;}
|
const QVariant &zoom() const {return _zoom;}
|
||||||
@ -26,8 +26,27 @@ private:
|
|||||||
QPixmap _pixmap;
|
QPixmap _pixmap;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class RenderTile
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
RenderTile(const QPoint &xy, const QByteArray &data, const QString &key)
|
||||||
|
: _xy(xy), _data(data), _key(key) {}
|
||||||
|
|
||||||
|
const QPoint &xy() const {return _xy;}
|
||||||
|
const QString &key() const {return _key;}
|
||||||
|
const QPixmap &pixmap() const {return _pixmap;}
|
||||||
|
|
||||||
|
void load() {_pixmap.loadFromData(_data);}
|
||||||
|
|
||||||
|
private:
|
||||||
|
QPoint _xy;
|
||||||
|
QByteArray _data;
|
||||||
|
QString _key;
|
||||||
|
QPixmap _pixmap;
|
||||||
|
};
|
||||||
|
|
||||||
#ifndef QT_NO_DEBUG
|
#ifndef QT_NO_DEBUG
|
||||||
inline QDebug operator<<(QDebug dbg, const Tile &tile)
|
inline QDebug operator<<(QDebug dbg, const FetchTile &tile)
|
||||||
{
|
{
|
||||||
dbg.nospace() << "Tile(" << tile.zoom() << ", " << tile.xy() << ", "
|
dbg.nospace() << "Tile(" << tile.zoom() << ", " << tile.xy() << ", "
|
||||||
<< tile.bbox() << ")";
|
<< tile.bbox() << ")";
|
||||||
|
@ -11,30 +11,27 @@ class TileImage
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TileImage() : _tile(0), _scaledSize(0) {}
|
TileImage() : _tile(0), _scaledSize(0) {}
|
||||||
TileImage(const QString &file, Tile *tile, int scaledSize)
|
TileImage(const QString &file, FetchTile *tile, int scaledSize)
|
||||||
: _file(file), _tile(tile), _scaledSize(scaledSize) {}
|
: _file(file), _tile(tile), _scaledSize(scaledSize) {}
|
||||||
|
|
||||||
void createPixmap()
|
|
||||||
{
|
|
||||||
_tile->pixmap().convertFromImage(_image);
|
|
||||||
}
|
|
||||||
void load()
|
void load()
|
||||||
{
|
{
|
||||||
|
QImage img;
|
||||||
QByteArray z(_tile->zoom().toString().toLatin1());
|
QByteArray z(_tile->zoom().toString().toLatin1());
|
||||||
QImageReader reader(_file, z);
|
QImageReader reader(_file, z);
|
||||||
if (_scaledSize)
|
if (_scaledSize)
|
||||||
reader.setScaledSize(QSize(_scaledSize, _scaledSize));
|
reader.setScaledSize(QSize(_scaledSize, _scaledSize));
|
||||||
reader.read(&_image);
|
reader.read(&img);
|
||||||
|
_tile->pixmap().convertFromImage(img);
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &file() const {return _file;}
|
const QString &file() const {return _file;}
|
||||||
Tile *tile() {return _tile;}
|
FetchTile *tile() {return _tile;}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString _file;
|
QString _file;
|
||||||
Tile *_tile;
|
FetchTile *_tile;
|
||||||
int _scaledSize;
|
int _scaledSize;
|
||||||
QImage _image;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static QString quadKey(const QPoint &xy, int zoom)
|
static QString quadKey(const QPoint &xy, int zoom)
|
||||||
@ -64,13 +61,13 @@ TileLoader::TileLoader(const QString &dir, QObject *parent)
|
|||||||
connect(_downloader, &Downloader::finished, this, &TileLoader::finished);
|
connect(_downloader, &Downloader::finished, this, &TileLoader::finished);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TileLoader::loadTilesAsync(QVector<Tile> &list)
|
void TileLoader::loadTilesAsync(QVector<FetchTile> &list)
|
||||||
{
|
{
|
||||||
QList<Download> dl;
|
QList<Download> dl;
|
||||||
QList<TileImage> imgs;
|
QList<TileImage> imgs;
|
||||||
|
|
||||||
for (int i = 0; i < list.size(); i++) {
|
for (int i = 0; i < list.size(); i++) {
|
||||||
Tile &t = list[i];
|
FetchTile &t = list[i];
|
||||||
QString file(tileFile(t));
|
QString file(tileFile(t));
|
||||||
|
|
||||||
if (QPixmapCache::find(file, &t.pixmap()))
|
if (QPixmapCache::find(file, &t.pixmap()))
|
||||||
@ -97,19 +94,18 @@ void TileLoader::loadTilesAsync(QVector<Tile> &list)
|
|||||||
|
|
||||||
for (int i = 0; i < imgs.size(); i++) {
|
for (int i = 0; i < imgs.size(); i++) {
|
||||||
TileImage &ti = imgs[i];
|
TileImage &ti = imgs[i];
|
||||||
ti.createPixmap();
|
|
||||||
QPixmapCache::insert(ti.file(), ti.tile()->pixmap());
|
QPixmapCache::insert(ti.file(), ti.tile()->pixmap());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TileLoader::loadTilesSync(QVector<Tile> &list)
|
void TileLoader::loadTilesSync(QVector<FetchTile> &list)
|
||||||
{
|
{
|
||||||
QList<Download> dl;
|
QList<Download> dl;
|
||||||
QList<Tile *> tl;
|
QList<FetchTile *> tl;
|
||||||
QList<TileImage> imgs;
|
QList<TileImage> imgs;
|
||||||
|
|
||||||
for (int i = 0; i < list.size(); i++) {
|
for (int i = 0; i < list.size(); i++) {
|
||||||
Tile &t = list[i];
|
FetchTile &t = list[i];
|
||||||
QString file(tileFile(t));
|
QString file(tileFile(t));
|
||||||
|
|
||||||
if (QPixmapCache::find(file, &t.pixmap()))
|
if (QPixmapCache::find(file, &t.pixmap()))
|
||||||
@ -137,7 +133,7 @@ void TileLoader::loadTilesSync(QVector<Tile> &list)
|
|||||||
wait.exec();
|
wait.exec();
|
||||||
|
|
||||||
for (int i = 0; i < tl.size(); i++) {
|
for (int i = 0; i < tl.size(); i++) {
|
||||||
Tile *t = tl[i];
|
FetchTile *t = tl[i];
|
||||||
QString file = tileFile(*t);
|
QString file = tileFile(*t);
|
||||||
if (QFileInfo(file).exists())
|
if (QFileInfo(file).exists())
|
||||||
imgs.append(TileImage(file, t, _scaledSize));
|
imgs.append(TileImage(file, t, _scaledSize));
|
||||||
@ -146,9 +142,6 @@ void TileLoader::loadTilesSync(QVector<Tile> &list)
|
|||||||
|
|
||||||
QFuture<void> future = QtConcurrent::map(imgs, &TileImage::load);
|
QFuture<void> future = QtConcurrent::map(imgs, &TileImage::load);
|
||||||
future.waitForFinished();
|
future.waitForFinished();
|
||||||
|
|
||||||
for (int i = 0; i < imgs.size(); i++)
|
|
||||||
imgs[i].createPixmap();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TileLoader::clearCache()
|
void TileLoader::clearCache()
|
||||||
@ -173,7 +166,7 @@ void TileLoader::setScaledSize(int size)
|
|||||||
QPixmapCache::clear();
|
QPixmapCache::clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
QUrl TileLoader::tileUrl(const Tile &tile) const
|
QUrl TileLoader::tileUrl(const FetchTile &tile) const
|
||||||
{
|
{
|
||||||
QString url(_url);
|
QString url(_url);
|
||||||
|
|
||||||
@ -195,7 +188,7 @@ QUrl TileLoader::tileUrl(const Tile &tile) const
|
|||||||
return QUrl(url);
|
return QUrl(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TileLoader::tileFile(const Tile &tile) const
|
QString TileLoader::tileFile(const FetchTile &tile) const
|
||||||
{
|
{
|
||||||
return _dir + QLatin1Char('/') + tile.zoom().toString() + QLatin1Char('-')
|
return _dir + QLatin1Char('/') + tile.zoom().toString() + QLatin1Char('-')
|
||||||
+ QString::number(tile.xy().x()) + QLatin1Char('-')
|
+ QString::number(tile.xy().x()) + QLatin1Char('-')
|
||||||
|
@ -19,16 +19,16 @@ public:
|
|||||||
void setScaledSize(int size);
|
void setScaledSize(int size);
|
||||||
void setQuadTiles(bool quadTiles) {_quadTiles = quadTiles;}
|
void setQuadTiles(bool quadTiles) {_quadTiles = quadTiles;}
|
||||||
|
|
||||||
void loadTilesAsync(QVector<Tile> &list);
|
void loadTilesAsync(QVector<FetchTile> &list);
|
||||||
void loadTilesSync(QVector<Tile> &list);
|
void loadTilesSync(QVector<FetchTile> &list);
|
||||||
void clearCache();
|
void clearCache();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void finished();
|
void finished();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QUrl tileUrl(const Tile &tile) const;
|
QUrl tileUrl(const FetchTile &tile) const;
|
||||||
QString tileFile(const Tile &tile) const;
|
QString tileFile(const FetchTile &tile) const;
|
||||||
|
|
||||||
Downloader *_downloader;
|
Downloader *_downloader;
|
||||||
QString _url;
|
QString _url;
|
||||||
|
@ -174,7 +174,7 @@ void WMSMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
|||||||
QPoint br = QPoint(qCeil(rect.right() / tileSize()),
|
QPoint br = QPoint(qCeil(rect.right() / tileSize()),
|
||||||
qCeil(rect.bottom() / tileSize()));
|
qCeil(rect.bottom() / tileSize()));
|
||||||
|
|
||||||
QVector<Tile> tiles;
|
QVector<FetchTile> tiles;
|
||||||
tiles.reserve((br.x() - tl.x()) * (br.y() - tl.y()));
|
tiles.reserve((br.x() - tl.x()) * (br.y() - tl.y()));
|
||||||
for (int i = tl.x(); i < br.x(); i++) {
|
for (int i = tl.x(); i < br.x(); i++) {
|
||||||
for (int j = tl.y(); j < br.y(); j++) {
|
for (int j = tl.y(); j < br.y(); j++) {
|
||||||
@ -186,7 +186,7 @@ void WMSMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
|||||||
? RectD(PointD(tbr.y(), tbr.x()), PointD(ttl.y(), ttl.x()))
|
? RectD(PointD(tbr.y(), tbr.x()), PointD(ttl.y(), ttl.x()))
|
||||||
: RectD(ttl, tbr);
|
: RectD(ttl, tbr);
|
||||||
|
|
||||||
tiles.append(Tile(QPoint(i, j), _zoom, bbox));
|
tiles.append(FetchTile(QPoint(i, j), _zoom, bbox));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,7 +196,7 @@ void WMSMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
|||||||
_tileLoader->loadTilesAsync(tiles);
|
_tileLoader->loadTilesAsync(tiles);
|
||||||
|
|
||||||
for (int i = 0; i < tiles.count(); i++) {
|
for (int i = 0; i < tiles.count(); i++) {
|
||||||
Tile &t = tiles[i];
|
FetchTile &t = tiles[i];
|
||||||
QPointF tp(t.xy().x() * tileSize(), t.xy().y() * tileSize());
|
QPointF tp(t.xy().x() * tileSize(), t.xy().y() * tileSize());
|
||||||
if (!t.pixmap().isNull()) {
|
if (!t.pixmap().isNull()) {
|
||||||
t.pixmap().setDevicePixelRatio(_mapRatio);
|
t.pixmap().setDevicePixelRatio(_mapRatio);
|
||||||
|
@ -180,11 +180,11 @@ void WMTSMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
|||||||
QPoint br = QPoint(qCeil(rect.right() / ts.width()),
|
QPoint br = QPoint(qCeil(rect.right() / ts.width()),
|
||||||
qCeil(rect.bottom() / ts.height()));
|
qCeil(rect.bottom() / ts.height()));
|
||||||
|
|
||||||
QVector<Tile> tiles;
|
QVector<FetchTile> tiles;
|
||||||
tiles.reserve((br.x() - tl.x()) * (br.y() - tl.y()));
|
tiles.reserve((br.x() - tl.x()) * (br.y() - tl.y()));
|
||||||
for (int i = tl.x(); i < br.x(); i++)
|
for (int i = tl.x(); i < br.x(); i++)
|
||||||
for (int j = tl.y(); j < br.y(); j++)
|
for (int j = tl.y(); j < br.y(); j++)
|
||||||
tiles.append(Tile(QPoint(i, j), z.id()));
|
tiles.append(FetchTile(QPoint(i, j), z.id()));
|
||||||
|
|
||||||
if (flags & Map::Block)
|
if (flags & Map::Block)
|
||||||
_tileLoader->loadTilesSync(tiles);
|
_tileLoader->loadTilesSync(tiles);
|
||||||
@ -192,7 +192,7 @@ void WMTSMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
|||||||
_tileLoader->loadTilesAsync(tiles);
|
_tileLoader->loadTilesAsync(tiles);
|
||||||
|
|
||||||
for (int i = 0; i < tiles.count(); i++) {
|
for (int i = 0; i < tiles.count(); i++) {
|
||||||
Tile &t = tiles[i];
|
FetchTile &t = tiles[i];
|
||||||
QPointF tp(t.xy().x() * ts.width(), t.xy().y() * ts.height());
|
QPointF tp(t.xy().x() * ts.width(), t.xy().y() * ts.height());
|
||||||
if (!t.pixmap().isNull()) {
|
if (!t.pixmap().isNull()) {
|
||||||
t.pixmap().setDevicePixelRatio(imageRatio());
|
t.pixmap().setDevicePixelRatio(imageRatio());
|
||||||
|
Loading…
Reference in New Issue
Block a user