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:
parent
e15deccfca
commit
b156e25023
@ -15,6 +15,8 @@
|
||||
#include <QTemporaryDir>
|
||||
#include <QCryptographicHash>
|
||||
#include <QtEndian>
|
||||
#include <QUrl>
|
||||
#include <QRegularExpression>
|
||||
#include <private/qzipreader_p.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,
|
||||
QMap<QString, QPixmap> &icons)
|
||||
{
|
||||
QString name, desc, phone, address, path, id;
|
||||
QString name, desc, phone, address, path, link, id;
|
||||
QDateTime timestamp;
|
||||
|
||||
while (_reader.readNextStartElement()) {
|
||||
@ -541,6 +543,14 @@ void KMLParser::photoOverlay(const Ctx &ctx, QVector<Waypoint> &waypoints,
|
||||
style(ctx.dir, icons);
|
||||
else if (_reader.name() == QLatin1String("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 (tempDir().isValid()) {
|
||||
QFileInfo fi(image);
|
||||
@ -553,6 +563,7 @@ void KMLParser::photoOverlay(const Ctx &ctx, QVector<Waypoint> &waypoints,
|
||||
}
|
||||
} else
|
||||
path = ctx.dir.absoluteFilePath(image);
|
||||
}
|
||||
} else if (_reader.name() == QLatin1String("Point")) {
|
||||
waypoints.append(Waypoint());
|
||||
Waypoint &w = waypoints.last();
|
||||
@ -562,7 +573,10 @@ void KMLParser::photoOverlay(const Ctx &ctx, QVector<Waypoint> &waypoints,
|
||||
w.setAddress(address);
|
||||
w.setPhone(phone);
|
||||
w.setIcon(icons.value(id));
|
||||
if (!path.isNull())
|
||||
w.addImage(path);
|
||||
if (!link.isNull())
|
||||
w.addLink(Link(link, "Photo Overlay"));
|
||||
point(w);
|
||||
} else if (_reader.name() == QLatin1String("styleUrl")) {
|
||||
id = _reader.readElementText();
|
||||
|
Loading…
Reference in New Issue
Block a user