1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-06-30 21:09:15 +02:00

Compare commits

..

20 Commits

Author SHA1 Message Date
cf81a90865 Some more micro-optimizations & code cleanup 2023-05-16 23:03:07 +02:00
04c203625f Version++ 2023-05-13 15:05:10 +02:00
d0cea97c90 Added support for custom HTTP headers in map tile requests 2023-05-13 15:01:35 +02:00
ddc7eb7149 Do not outline soundings like in ENC maps 2023-05-12 10:19:52 +02:00
bb22ad95b7 Use the point label as additional source for the id hash
Some (marine) maps have different points with the same type on the same
position.
2023-05-11 22:57:35 +02:00
682fcc09cc Merge branch 'origin/master' into Weblate. 2023-05-11 21:31:32 +02:00
60e83b24f9 Use as much as possible of the 64b hash in Qt6 2023-05-11 21:31:10 +02:00
c30501185c Merge branch 'origin/master' into Weblate. 2023-05-07 21:20:08 +02:00
9b3c11cc68 Version++ 2023-05-07 21:19:55 +02:00
61f77ef19e Merge branch 'origin/master' into Weblate. 2023-05-07 21:16:26 +02:00
c0834491d3 Translated using Weblate (Norwegian Bokmål)
Currently translated at 100.0% (467 of 467 strings)

Translation: GPXSee/Translations
Translate-URL: https://hosted.weblate.org/projects/gpxsee/translations/nb_NO/
2023-05-07 21:16:25 +02:00
e6fdd0f53d Fixed crash on empty routes 2023-05-07 21:15:44 +02:00
fe444e88a3 Merge branch 'origin/master' into Weblate. 2023-05-06 21:53:53 +02:00
d9c0770b51 Code cleanup 2023-05-06 21:53:40 +02:00
3a0e9bb733 Merge branch 'origin/master' into Weblate. 2023-05-06 16:15:14 +02:00
ca6c7247c0 Added missing cache insert 2023-05-06 16:14:49 +02:00
0b25cb9f81 Merge branch 'origin/master' into Weblate. 2023-05-04 21:49:22 +02:00
b19c3a83f3 Merge branch 'origin/master' into Weblate. 2023-05-04 09:52:05 +02:00
728361ad7b Merge branch 'origin/master' into Weblate. 2023-05-04 09:41:07 +02:00
raf
f5e3e5bd21 Translated using Weblate (Catalan)
Currently translated at 100.0% (467 of 467 strings)

Translation: GPXSee/Translations
Translate-URL: https://hosted.weblate.org/projects/gpxsee/translations/ca/
2023-04-29 11:48:37 +02:00
34 changed files with 132 additions and 110 deletions

View File

@ -1,4 +1,4 @@
version: 13.1.{build}
version: 13.3.{build}
configuration:
- Release

View File

@ -3,7 +3,7 @@ unix:!macx:!android {
} else {
TARGET = GPXSee
}
VERSION = 13.1
VERSION = 13.3
QT += core \
gui \

View File

@ -866,7 +866,7 @@
<location filename="../src/GUI/gui.cpp" line="907"/>
<location filename="../src/GUI/gui.cpp" line="925"/>
<source>CRS directory:</source>
<translation type="unfinished"></translation>
<translation>Directori CRS:</translation>
</message>
<message>
<location filename="../src/GUI/gui.cpp" line="909"/>
@ -1020,6 +1020,7 @@
<translation>
<numerusform>%n fitxer</numerusform>
<numerusform>%n fitxers</numerusform>
<numerusform>%n fitxers</numerusform>
</translation>
</message>
</context>

View File

@ -712,7 +712,7 @@
<location filename="../src/GUI/gui.cpp" line="907"/>
<location filename="../src/GUI/gui.cpp" line="925"/>
<source>CRS directory:</source>
<translation type="unfinished"></translation>
<translation>CRS-mappe:</translation>
</message>
<message>
<location filename="../src/GUI/gui.cpp" line="913"/>
@ -1718,12 +1718,12 @@
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="70"/>
<source>Select the proper coordinate reference system (CRS) of maps without a CRS definition (JNX, KMZ and World file maps).</source>
<translation type="unfinished"></translation>
<translation>Velg riktig koordinatreferansesystem (CRS) for kart uten en CRS-definisjon (JNX, KMZ og World-file kart).</translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="73"/>
<source>Select the desired projection of vector maps (IMG, Mapsforge and ENC maps). The projection must be valid for the whole map area.</source>
<translation type="unfinished"></translation>
<translation>Velg ønsket projeksjon for vektorkart (IMG, Mapsforge og ENC-kart). Projeksjonen være gyldig for hele kartområdet.</translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="104"/>

View File

@ -37,7 +37,7 @@ Unicode true
; The name of the installer
Name "GPXSee"
; Program version
!define VERSION "13.1"
!define VERSION "13.3"
; The file to write
OutFile "GPXSee-${VERSION}_x64.exe"

View File

@ -3,6 +3,7 @@
#include <cmath>
#include <QDebug>
#include "hash.h"
#define deg2rad(d) (((d)*M_PI)/180.0)
#define rad2deg(d) (((d)*180.0)/M_PI)
@ -48,6 +49,11 @@ inline bool operator<(const Coordinates &c1, const Coordinates &c2)
return (c1.lat() < c2.lat());
}
inline HASH_T qHash(const Coordinates &c)
{
return qHash(QPair<double, double>(c.lon(), c.lat()));
}
#ifndef QT_NO_DEBUG
QDebug operator<<(QDebug dbg, const Coordinates &c);
#endif // QT_NO_DEBUG

View File

@ -53,7 +53,7 @@ Authorization::Authorization(const QString &username, const QString &password)
{
QString concatenated = username + ":" + password;
QByteArray data = concatenated.toLocal8Bit().toBase64();
_header = "Basic " + data;
_header = HTTPHeader("Authorization", "Basic " + data);
}
NetworkTimeout::NetworkTimeout(int timeout, QNetworkReply *reply)
@ -83,9 +83,10 @@ QNetworkAccessManager *Downloader::_manager = 0;
int Downloader::_timeout = 30;
bool Downloader::_http2 = true;
bool Downloader::doDownload(const Download &dl, const Authorization &auth)
bool Downloader::doDownload(const Download &dl, const QList<HTTPHeader> &headers)
{
const QUrl &url = dl.url();
bool userAgent = false;
if (!url.isValid() || !(url.scheme() == QLatin1String("http")
|| url.scheme() == QLatin1String("https"))) {
@ -103,9 +104,15 @@ bool Downloader::doDownload(const Download &dl, const Authorization &auth)
request.setAttribute(ATTR_REDIRECT_POLICY,
QNetworkRequest::NoLessSafeRedirectPolicy);
request.setAttribute(ATTR_HTTP2_ALLOWED, QVariant(_http2));
request.setRawHeader("User-Agent", USER_AGENT);
if (!auth.isNull())
request.setRawHeader("Authorization", auth.header());
for (int i = 0; i < headers.size(); i++) {
const HTTPHeader &hdr = headers.at(i);
request.setRawHeader(hdr.key(), hdr.value());
if (hdr.key() == "User-Agent")
userAgent = true;
}
if (!userAgent)
request.setRawHeader("User-Agent", USER_AGENT);
QFile *file = new QFile(tmpName(dl.file()));
if (!file->open(QIODevice::WriteOnly)) {
@ -183,12 +190,12 @@ void Downloader::downloadFinished(QNetworkReply *reply)
}
bool Downloader::get(const QList<Download> &list,
const Authorization &authorization)
const QList<HTTPHeader> &headers)
{
bool finishEmitted = false;
for (int i = 0; i < list.count(); i++)
finishEmitted |= doDownload(list.at(i), authorization);
finishEmitted |= doDownload(list.at(i), headers);
return finishEmitted;
}

View File

@ -7,9 +7,12 @@
#include <QUrl>
#include <QList>
#include <QHash>
#include "common/kv.h"
class QFile;
typedef KV<QByteArray, QByteArray> HTTPHeader;
class Download
{
public:
@ -29,11 +32,11 @@ public:
Authorization() {}
Authorization(const QString &username, const QString &password);
bool isNull() const {return _header.isNull();}
const QByteArray &header() const {return _header;}
const HTTPHeader &header() const {return _header;}
bool isNull() const {return _header.key().isNull();}
private:
QByteArray _header;
HTTPHeader _header;
};
class NetworkTimeout : public QObject
@ -60,8 +63,7 @@ class Downloader : public QObject
public:
Downloader(QObject *parent = 0) : QObject(parent) {}
bool get(const QList<Download> &list, const Authorization &authorization
= Authorization());
bool get(const QList<Download> &list, const QList<HTTPHeader> &headers);
void clearErrors() {_errorDownloads.clear();}
static void setNetworkManager(QNetworkAccessManager *manager)
@ -80,7 +82,7 @@ private:
class ReplyTimeout;
void insertError(const QUrl &url, QNetworkReply::NetworkError error);
bool doDownload(const Download &dl, const Authorization &auth);
bool doDownload(const Download &dl, const QList<HTTPHeader> &headers);
void downloadFinished(QNetworkReply *reply);
void readData(QNetworkReply *reply);

View File

@ -6,13 +6,13 @@
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#define HASH_T uint
inline uint qHash(const QPoint &p)
{
return qHash(QPair<int, int>(p.x(), p.y()));
}
#else // QT6
#define HASH_T size_t
#endif // QT6
inline HASH_T qHash(const QPoint &p)
{
return ::qHash(p.x()) ^ ::qHash(p.y());
}
#endif // HASH_H

View File

@ -4,6 +4,7 @@
template <class KEY, class VALUE>
class KV {
public:
KV() {}
KV(const KEY &key, const VALUE &value) : _key(key), _value(value) {}
const KEY &key() const {return _key;}

View File

@ -64,7 +64,7 @@ bool DEMLoader::loadTiles(const RectC &rect)
}
}
return _downloader->get(dl, _authorization);
return _downloader->get(dl, _headers);
}
bool DEMLoader::checkTiles(const RectC &rect) const
@ -97,3 +97,11 @@ QString DEMLoader::tileFile(const DEM::Tile &tile) const
{
return _dir.absoluteFilePath(tile.baseName());
}
void DEMLoader::setAuthorization(const Authorization &authorization)
{
QList<HTTPHeader> headers;
if (!authorization.isNull())
headers.append(authorization.header());
_headers = headers;
}

View File

@ -16,8 +16,7 @@ public:
DEMLoader(const QString &dir, QObject *parent = 0);
void setUrl(const QString &url) {_url = url;}
void setAuthorization(const Authorization &authorization)
{_authorization = authorization;}
void setAuthorization(const Authorization &authorization);
bool loadTiles(const RectC &rect);
bool checkTiles(const RectC &rect) const;
@ -34,7 +33,7 @@ private:
Downloader *_downloader;
QString _url;
QDir _dir;
Authorization _authorization;
QList<HTTPHeader> _headers;
};
#endif // DEMLOADER_H

View File

@ -33,13 +33,16 @@ Path Route::path() const
Graph Route::gpsElevation() const
{
Graph graph;
graph.append(GraphSegment(QDateTime()));
GraphSegment &gs = graph.last();
QDateTime date;
GraphSegment gs(date);
for (int i = 0; i < _data.size(); i++)
if (_data.at(i).hasElevation())
gs.append(GraphPoint(_distance.at(i), NAN, _data.at(i).elevation()));
if (gs.size() >= 2)
graph.append(gs);
if (_data.style().color().isValid())
graph.setColor(_data.style().color());
@ -49,8 +52,8 @@ Graph Route::gpsElevation() const
Graph Route::demElevation() const
{
Graph graph;
graph.append(GraphSegment(QDateTime()));
GraphSegment &gs = graph.last();
QDateTime date;
GraphSegment gs(date);
for (int i = 0; i < _data.size(); i++) {
qreal dem = DEM::elevation(_data.at(i).coordinates());
@ -58,6 +61,9 @@ Graph Route::demElevation() const
gs.append(GraphPoint(_distance.at(i), NAN, dem));
}
if (gs.size() >= 2)
graph.append(gs);
if (_data.style().color().isValid())
graph.setColor(_data.style().color());

View File

@ -446,12 +446,14 @@ void RasterTile::processPoints(QList<TextItem*> &textItems)
: font(style.textFontSize());
const QColor *color = style.textColor().isValid()
? &style.textColor() : &textColor;
const QColor *hcolor = Style::isDepthPoint(point.type)
? 0 : &haloColor;
if ((!label || !fnt) && !img)
continue;
TextPointItem *item = new TextPointItem(QPoint(point.coordinates.lon(),
point.coordinates.lat()), label, fnt, img, color, &haloColor, 0,
point.coordinates.lat()), label, fnt, img, color, hcolor, 0,
ICON_PADDING);
if (item->isValid() && !item->collides(textItems))
textItems.append(item);

View File

@ -1,5 +1,6 @@
#include "common/rectc.h"
#include "common/garmin.h"
#include "common/hash.h"
#include "deltastream.h"
#include "huffmanstream.h"
#include "style.h"
@ -13,12 +14,10 @@ using namespace IMG;
#define MASK(bits) ((1U << (bits)) - 1U)
static quint64 pointId(const QPoint &pos, quint32 type)
static quint64 pointId(const QPoint &pos, quint32 type, const QString &label)
{
quint64 id;
uint hash = (uint)qHash(QPair<int, int>(pos.x(), pos.y()));
id = ((quint64)type)<<32 | hash;
quint64 hash = qHash(pos) ^ qHash(label);
quint64 id = ((quint64)type)<<40 | (hash & 0xFFFFFFFFFF);
// Increase rendering priorities for some special items
if (!Style::isCountry(type) && !Style::isMarina(type))
@ -484,11 +483,11 @@ bool RGNFile::pointObjects(Handle &hdl, const SubDiv *subdiv,
point.type = (quint16)type<<8 | subtype;
point.coordinates = Coordinates(toWGS24(pos.x()), toWGS24(pos.y()));
point.id = pointId(pos, point.type);
if (lbl && (labelPtr & 0x3FFFFF))
point.label = lbl->label(lblHdl, labelPtr & 0x3FFFFF,
labelPtr & 0x400000, !(Style::isCountry(point.type)
|| Style::isState(point.type)), Style::isSpot(point.type));
point.id = pointId(pos, point.type, point.label.text());
points->append(point);
}
@ -537,9 +536,9 @@ bool RGNFile::extPointObjects(Handle &hdl, const SubDiv *subdiv,
continue;
point.coordinates = Coordinates(toWGS24(p.x()), toWGS24(p.y()));
point.id = pointId(p, point.type);
if (lbl && (labelPtr & 0x3FFFFF))
point.label = lbl->label(lblHdl, labelPtr & 0x3FFFFF);
point.id = pointId(p, point.type, point.label.text());
points->append(point);
}

View File

@ -5,34 +5,26 @@
#define SAMPLES 100
void Map::growLeft(const QPointF &p, RectC &rect)
static void growLeft(const Coordinates &c, RectC &rect)
{
Coordinates c(xy2ll(p));
if (c.lon() < rect.left())
rect.setLeft(c.lon());
}
void Map::growRight(const QPointF &p, RectC &rect)
static void growRight(const Coordinates &c, RectC &rect)
{
Coordinates c(xy2ll(p));
if (c.lon() > rect.right())
rect.setRight(c.lon());
}
void Map::growTop(const QPointF &p, RectC &rect)
static void growTop(const Coordinates &c, RectC &rect)
{
Coordinates c(xy2ll(p));
if (c.lat() > rect.top())
rect.setTop(c.lat());
}
void Map::growBottom(const QPointF &p, RectC &rect)
static void growBottom(const Coordinates &c, RectC &rect)
{
Coordinates c(xy2ll(p));
if (c.lat() < rect.bottom())
rect.setBottom(c.lat());
}
@ -53,14 +45,14 @@ RectC Map::llBounds(const Projection &proj)
for (int i = 0; i <= SAMPLES; i++) {
double x = b.left() + i * dx;
growBottom(QPointF(x, b.bottom()), rect);
growTop(QPointF(x, b.top()), rect);
growBottom(xy2ll(QPointF(x, b.bottom())), rect);
growTop(xy2ll(QPointF(x, b.top())), rect);
}
for (int i = 0; i <= SAMPLES; i++) {
double y = b.top() + i * dy;
growLeft(QPointF(b.left(), y), rect);
growRight(QPointF(b.right(), y), rect);
growLeft(xy2ll(QPointF(b.left(), y)), rect);
growRight(xy2ll(QPointF(b.right(), y)), rect);
}
return rect;

View File

@ -62,11 +62,6 @@ signals:
void mapLoaded();
private:
void growLeft(const QPointF &p, RectC &rect);
void growRight(const QPointF &p, RectC &rect);
void growTop(const QPointF &p, RectC &rect);
void growBottom(const QPointF &p, RectC &rect);
QString _path;
};

View File

@ -584,8 +584,10 @@ bool MapData::readPaths(const VectorTile *tile, int zoom, QList<Path> *list)
if (!subfile.seek(subfile.pos() + val))
return false;
paths.reserve(paths[zoom - info.min]);
for (unsigned i = 0; i < paths[zoom - info.min]; i++) {
Path p(subfile.offset() + subfile.pos());
Path p;
qint32 lon = 0, lat = 0;
if (!(subfile.readVUInt32(unused) && subfile.readUInt16(bitmap)
@ -665,6 +667,8 @@ bool MapData::readPoints(const VectorTile *tile, int zoom, QList<Point> *list)
if (!subfile.readVUInt32(unused))
return false;
list->reserve(points[zoom - info.min]);
for (unsigned i = 0; i < points[zoom - info.min]; i++) {
qint32 lat, lon;

View File

@ -36,10 +36,7 @@ public:
};
struct Point {
Point(const Coordinates &c) : coordinates(c)
{
id = (quint64)qHash(QPair<double, double>(c.lon(), c.lat()));
}
Point(const Coordinates &c) : id(qHash(c)), coordinates(c) {}
quint64 id;
Coordinates coordinates;
@ -48,9 +45,6 @@ public:
};
struct Path {
Path(quint64 id) : id(id) {}
quint64 id;
Polygon poly;
QVector<Tag> tags;
Coordinates labelPos;
@ -59,8 +53,6 @@ public:
bool operator<(const Path &other) const
{return layer < other.layer;}
bool operator==(const Path &other) const
{return (id == other.id);}
};
RectC bounds() const;
@ -190,11 +182,6 @@ inline HASH_T qHash(const MapData::Tag &tag)
return ::qHash(tag.key) ^ ::qHash(tag.value);
}
inline HASH_T qHash(const MapData::Path &path)
{
return ::qHash(path.id);
}
}
#ifndef QT_NO_DEBUG

View File

@ -224,9 +224,10 @@ QPainterPath RasterTile::painterPath(const Polygon &polygon, bool curve) const
}
path.quadTo(p2, p3);
} else {
path.moveTo(ll2xy(subpath.first()));
for (int j = 1; j < subpath.size(); j++)
path.lineTo(ll2xy(subpath.at(j)));
QVector<QPointF> p(subpath.size());
for (int j = 0; j < subpath.size(); j++)
p[j] = ll2xy(subpath.at(j));
path.addPolygon(p);
}
}

View File

@ -14,7 +14,6 @@ public:
: _file(file), _offset(offset), _size(size), _pos(-1),
_blockNum(-1), _blockPos(-1) {}
quint64 offset() const {return _offset;}
quint64 pos() const {return _pos;}
bool seek(quint64 pos);

View File

@ -189,14 +189,22 @@ void MapSource::map(QXmlStreamReader &reader, Config &config)
else
config.dimensions.append(KV<QString, QString>
(attr.value("id").toString(), reader.readElementText()));
} else if (reader.name() == QLatin1String("header")) {
QXmlStreamAttributes attr = reader.attributes();
if (!attr.hasAttribute("name"))
reader.raiseError("Missing header name");
else
config.headers.append(HTTPHeader(
attr.value("name").toString().toLatin1(),
reader.readElementText().toLatin1()));
} else if (reader.name() == QLatin1String("crs")) {
config.coordinateSystem = coordinateSystem(reader);
config.crs = reader.readElementText();
} else if (reader.name() == QLatin1String("authorization")) {
QXmlStreamAttributes attr = reader.attributes();
config.authorization = Authorization(
attr.value("username").toString(),
Authorization auth(attr.value("username").toString(),
attr.value("password").toString());
config.headers.append(auth.header());
reader.skipCurrentElement();
} else if (reader.name() == QLatin1String("tile")) {
tile(reader, config);
@ -252,24 +260,24 @@ Map *MapSource::create(const QString &path, bool *isDir)
case WMTS:
return new WMTSMap(path, config.name, WMTS::Setup(config.url,
config.layer, config.set, config.style, config.format, config.rest,
config.coordinateSystem, config.dimensions, config.authorization),
config.coordinateSystem, config.dimensions, config.headers),
config.tileRatio);
case WMS:
return new WMSMap(path, config.name, WMS::Setup(config.url,
config.layer, config.style, config.format, config.crs,
config.coordinateSystem, config.dimensions, config.authorization),
config.coordinateSystem, config.dimensions, config.headers),
config.tileSize);
case TMS:
return new OnlineMap(path, config.name, config.url, config.zooms,
config.bounds, config.tileRatio, config.authorization,
config.bounds, config.tileRatio, config.headers,
config.tileSize, config.scalable, true, false);
case OSM:
return new OnlineMap(path, config.name, config.url, config.zooms,
config.bounds, config.tileRatio, config.authorization,
config.bounds, config.tileRatio, config.headers,
config.tileSize, config.scalable, false, false);
case QuadTiles:
return new OnlineMap(path, config.name, config.url, config.zooms,
config.bounds, config.tileRatio, config.authorization,
config.bounds, config.tileRatio, config.headers,
config.tileSize, config.scalable, false, true);
default:
return new InvalidMap(path, "Invalid map type");

View File

@ -40,7 +40,7 @@ private:
CoordinateSystem coordinateSystem;
bool rest;
QList<KV<QString, QString> > dimensions;
Authorization authorization;
QList<HTTPHeader> headers;
qreal tileRatio;
int tileSize;
bool scalable;

View File

@ -10,7 +10,7 @@
OnlineMap::OnlineMap(const QString &fileName, const QString &name,
const QString &url, const Range &zooms, const RectC &bounds, qreal tileRatio,
const Authorization &authorization, int tileSize, bool scalable, bool invertY,
const QList<HTTPHeader> &headers, int tileSize, bool scalable, bool invertY,
bool quadTiles, QObject *parent)
: Map(fileName, parent), _name(name), _zooms(zooms), _bounds(bounds),
_zoom(_zooms.max()), _tileSize(tileSize), _mapRatio(1.0),
@ -19,7 +19,7 @@ OnlineMap::OnlineMap(const QString &fileName, const QString &name,
_tileLoader = new TileLoader(QDir(ProgramPaths::tilesDir()).filePath(_name),
this);
_tileLoader->setUrl(url);
_tileLoader->setAuthorization(authorization);
_tileLoader->setHeaders(headers);
_tileLoader->setQuadTiles(quadTiles);
connect(_tileLoader, &TileLoader::finished, this, &OnlineMap::tilesLoaded);
}

View File

@ -13,7 +13,7 @@ class OnlineMap : public Map
public:
OnlineMap(const QString &fileName, const QString &name, const QString &url,
const Range &zooms, const RectC &bounds, qreal tileRatio,
const Authorization &authorization, int tileSize, bool scalable,
const QList<HTTPHeader> &headers, int tileSize, bool scalable,
bool invertY, bool quadTiles, QObject *parent = 0);
QString name() const {return _name;}

View File

@ -17,7 +17,7 @@ public:
const QVariant &zoom() const {return _zoom;}
const QPoint &xy() const {return _xy;}
const RectD &bbox() const {return _bbox;}
QPixmap& pixmap() {return _pixmap;}
QPixmap &pixmap() {return _pixmap;}
private:
QPoint _xy;

View File

@ -61,6 +61,7 @@ TileLoader::TileLoader(const QString &dir, QObject *parent)
connect(_downloader, &Downloader::finished, this, &TileLoader::finished);
}
void TileLoader::loadTilesAsync(QVector<FetchTile> &list)
{
QList<Download> dl;
@ -87,7 +88,7 @@ void TileLoader::loadTilesAsync(QVector<FetchTile> &list)
}
if (!dl.empty())
_downloader->get(dl, _authorization);
_downloader->get(dl, _headers);
QFuture<void> future = QtConcurrent::map(imgs, &TileImage::load);
future.waitForFinished();
@ -129,7 +130,7 @@ void TileLoader::loadTilesSync(QVector<FetchTile> &list)
if (!dl.empty()) {
QEventLoop wait;
connect(_downloader, &Downloader::finished, &wait, &QEventLoop::quit);
if (_downloader->get(dl, _authorization))
if (_downloader->get(dl, _headers))
wait.exec();
for (int i = 0; i < tl.size(); i++) {
@ -142,6 +143,11 @@ void TileLoader::loadTilesSync(QVector<FetchTile> &list)
QFuture<void> future = QtConcurrent::map(imgs, &TileImage::load);
future.waitForFinished();
for (int i = 0; i < imgs.size(); i++) {
TileImage &ti = imgs[i];
QPixmapCache::insert(ti.file(), ti.tile()->pixmap());
}
}
void TileLoader::clearCache()

View File

@ -14,8 +14,7 @@ public:
TileLoader(const QString &dir, QObject *parent = 0);
void setUrl(const QString &url) {_url = url;}
void setAuthorization(const Authorization &authorization)
{_authorization = authorization;}
void setHeaders(const QList<HTTPHeader> &headers) {_headers = headers;}
void setScaledSize(int size);
void setQuadTiles(bool quadTiles) {_quadTiles = quadTiles;}
@ -33,7 +32,7 @@ private:
Downloader *_downloader;
QString _url;
QString _dir;
Authorization _authorization;
QList<HTTPHeader> _headers;
int _scaledSize;
bool _quadTiles;
};

View File

@ -345,7 +345,7 @@ WMS::WMS(const QString &file, const WMS::Setup &setup, QObject *parent)
QList<Download> dl;
dl.append(Download(url, _path));
_valid = downloader->get(dl, _setup.authorization());
_valid = downloader->get(dl, _setup.headers());
} else {
_ready = true;
_valid = parseCapabilities();

View File

@ -23,13 +23,13 @@ public:
Setup(const QString &url, const QString &layer, const QString &style,
const QString &format, const QString &crs, const CoordinateSystem &cs,
const QList<KV<QString, QString> > &dimensions,
const Authorization &authorization = Authorization())
const QList<HTTPHeader> &headers)
: _url(url), _layer(layer), _style(style), _format(format),
_crs(crs), _cs(cs), _dimensions(dimensions),
_authorization(authorization) {}
_headers(headers) {}
const QString &url() const {return _url;}
const Authorization &authorization() const {return _authorization;}
const QList<HTTPHeader> &headers() const {return _headers;}
const QString &layer() const {return _layer;}
const QString &style() const {return _style;}
const QString &format() const {return _format;}
@ -46,7 +46,7 @@ public:
QString _crs;
CoordinateSystem _cs;
QList<KV<QString, QString> > _dimensions;
Authorization _authorization;
QList<HTTPHeader> _headers;
};

View File

@ -74,7 +74,7 @@ WMSMap::WMSMap(const QString &fileName, const QString &name,
QString tilesDir(QDir(ProgramPaths::tilesDir()).filePath(_name));
_tileLoader = new TileLoader(tilesDir, this);
_tileLoader->setAuthorization(setup.authorization());
_tileLoader->setHeaders(setup.headers());
connect(_tileLoader, &TileLoader::finished, this, &WMSMap::tilesLoaded);
_wms = new WMS(QDir(tilesDir).filePath(CAPABILITIES_FILE), setup, this);

View File

@ -361,7 +361,7 @@ WMTS::WMTS(const QString &file, const WMTS::Setup &setup, QObject *parent)
QList<Download> dl;
dl.append(Download(url.toString(), _path));
_valid = downloader->get(dl, _setup.authorization());
_valid = downloader->get(dl, _setup.headers());
} else {
_ready = true;
_valid = init();

View File

@ -27,13 +27,13 @@ public:
const QString &style, const QString &format, bool rest,
const CoordinateSystem &cs,
const QList<KV<QString, QString> > &dimensions,
const Authorization &authorization = Authorization())
const QList<HTTPHeader> &headers)
: _url(url), _layer(layer), _set(set), _style(style),
_format(format), _rest(rest), _cs(cs), _dimensions(dimensions),
_authorization(authorization) {}
_headers(headers) {}
const QString &url() const {return _url;}
const Authorization &authorization() const {return _authorization;}
const QList<HTTPHeader> &headers() const {return _headers;}
const QString &layer() const {return _layer;}
const QString &set() const {return _set;}
const QString &style() const {return _style;}
@ -52,7 +52,7 @@ public:
bool _rest;
CoordinateSystem _cs;
QList<KV<QString, QString> > _dimensions;
Authorization _authorization;
QList<HTTPHeader> _headers;
};
class Zoom

View File

@ -20,7 +20,7 @@ WMTSMap::WMTSMap(const QString &fileName, const QString &name,
QString tilesDir(QDir(ProgramPaths::tilesDir()).filePath(_name));
_tileLoader = new TileLoader(tilesDir, this);
_tileLoader->setAuthorization(setup.authorization());
_tileLoader->setHeaders(setup.headers());
connect(_tileLoader, &TileLoader::finished, this, &WMTSMap::tilesLoaded);
_wmts = new WMTS(QDir(tilesDir).filePath(CAPABILITIES_FILE), setup, this);