6#include <QtLocation/private/qgeotilespec_p.h>
10static const unsigned char pngSignature[] = {0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00};
12static const unsigned char gifSignature[] = {0x47, 0x49, 0x46, 0x38, 0x00};
14GeoTiledMapReplyEsri::GeoTiledMapReplyEsri(QNetworkReply *reply,
const QGeoTileSpec &spec,
16 QGeoTiledMapReply(spec, parent)
19 setError(UnknownError, QStringLiteral(
"Null reply"));
22 connect(reply, &QNetworkReply::finished,
23 this, &GeoTiledMapReplyEsri::networkReplyFinished);
24 connect(reply, &QNetworkReply::errorOccurred,
25 this, &GeoTiledMapReplyEsri::networkReplyError);
26 connect(
this, &QGeoTiledMapReply::aborted, reply, &QNetworkReply::abort);
27 connect(
this, &QObject::destroyed, reply, &QObject::deleteLater);
30GeoTiledMapReplyEsri::~GeoTiledMapReplyEsri()
34void GeoTiledMapReplyEsri::networkReplyFinished()
36 QNetworkReply *reply =
static_cast<QNetworkReply *>(sender());
39 if (reply->error() != QNetworkReply::NoError)
42 QByteArray
const& imageData = reply->readAll();
44 bool validFormat =
true;
45 if (imageData.startsWith(
reinterpret_cast<
const char*>(
pngSignature)))
46 setMapImageFormat(QStringLiteral(
"png"));
47 else if (imageData.startsWith(
reinterpret_cast<
const char*>(
jpegSignature)))
48 setMapImageFormat(QStringLiteral(
"jpg"));
49 else if (imageData.startsWith(
reinterpret_cast<
const char*>(
gifSignature)))
50 setMapImageFormat(QStringLiteral(
"gif"));
55 setMapImageData(imageData);
60void GeoTiledMapReplyEsri::networkReplyError(QNetworkReply::NetworkError error)
62 QNetworkReply *reply =
static_cast<QNetworkReply *>(sender());
64 if (error == QNetworkReply::OperationCanceledError)
67 setError(QGeoTiledMapReply::CommunicationError, reply->errorString());
static QT_BEGIN_NAMESPACE const unsigned char pngSignature[]
static const unsigned char jpegSignature[]
static const unsigned char gifSignature[]