1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-24 11:45:53 +01:00

Properly handle PhotoOverlay icon URLs

This commit is contained in:
Martin Tůma 2022-09-02 09:55:11 +02:00
parent e15deccfca
commit b156e25023

View File

@ -15,6 +15,8 @@
#include <QTemporaryDir> #include <QTemporaryDir>
#include <QCryptographicHash> #include <QCryptographicHash>
#include <QtEndian> #include <QtEndian>
#include <QUrl>
#include <QRegularExpression>
#include <private/qzipreader_p.h> #include <private/qzipreader_p.h>
#include "kmlparser.h" #include "kmlparser.h"
@ -523,7 +525,7 @@ void KMLParser::multiGeometry(QList<TrackData> &tracks, QList<Area> &areas,
void KMLParser::photoOverlay(const Ctx &ctx, QVector<Waypoint> &waypoints, void KMLParser::photoOverlay(const Ctx &ctx, QVector<Waypoint> &waypoints,
QMap<QString, QPixmap> &icons) QMap<QString, QPixmap> &icons)
{ {
QString name, desc, phone, address, path, id; QString name, desc, phone, address, path, link, id;
QDateTime timestamp; QDateTime timestamp;
while (_reader.readNextStartElement()) { while (_reader.readNextStartElement()) {
@ -541,6 +543,14 @@ void KMLParser::photoOverlay(const Ctx &ctx, QVector<Waypoint> &waypoints,
style(ctx.dir, icons); style(ctx.dir, icons);
else if (_reader.name() == QLatin1String("Icon")) { else if (_reader.name() == QLatin1String("Icon")) {
QString image(icon()); QString image(icon());
QRegularExpression re("\\$\\[[^\\]]+\\]");
image.replace(re, "0");
QUrl url(image);
if (url.scheme() == "http" || url.scheme() == "https")
link = image;
else {
if (ctx.zip) { if (ctx.zip) {
if (tempDir().isValid()) { if (tempDir().isValid()) {
QFileInfo fi(image); QFileInfo fi(image);
@ -553,6 +563,7 @@ void KMLParser::photoOverlay(const Ctx &ctx, QVector<Waypoint> &waypoints,
} }
} else } else
path = ctx.dir.absoluteFilePath(image); path = ctx.dir.absoluteFilePath(image);
}
} else if (_reader.name() == QLatin1String("Point")) { } else if (_reader.name() == QLatin1String("Point")) {
waypoints.append(Waypoint()); waypoints.append(Waypoint());
Waypoint &w = waypoints.last(); Waypoint &w = waypoints.last();
@ -562,7 +573,10 @@ void KMLParser::photoOverlay(const Ctx &ctx, QVector<Waypoint> &waypoints,
w.setAddress(address); w.setAddress(address);
w.setPhone(phone); w.setPhone(phone);
w.setIcon(icons.value(id)); w.setIcon(icons.value(id));
if (!path.isNull())
w.addImage(path); w.addImage(path);
if (!link.isNull())
w.addLink(Link(link, "Photo Overlay"));
point(w); point(w);
} else if (_reader.name() == QLatin1String("styleUrl")) { } else if (_reader.name() == QLatin1String("styleUrl")) {
id = _reader.readElementText(); id = _reader.readElementText();