Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
geotiledmapreply_esri.cpp
Go to the documentation of this file.
1
// Copyright (C) 2013-2018 Esri <contracts@esri.com>
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4
#
include
"geotiledmapreply_esri.h"
5
6
#
include
<
QtLocation
/
private
/
qgeotilespec_p
.
h
>
7
8
QT_BEGIN_NAMESPACE
9
10
static
const
unsigned
char
pngSignature
[] = {0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00};
11
static
const
unsigned
char
jpegSignature
[] = {0xFF, 0xD8, 0xFF, 0x00};
12
static
const
unsigned
char
gifSignature
[] = {0x47, 0x49, 0x46, 0x38, 0x00};
13
14
GeoTiledMapReplyEsri::GeoTiledMapReplyEsri(QNetworkReply *reply,
const
QGeoTileSpec &spec,
15
QObject *parent) :
16
QGeoTiledMapReply(spec, parent)
17
{
18
if
(!reply) {
19
setError(UnknownError, QStringLiteral(
"Null reply"
));
20
return
;
21
}
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);
28
}
29
30
GeoTiledMapReplyEsri::~GeoTiledMapReplyEsri()
31
{
32
}
33
34
void
GeoTiledMapReplyEsri::networkReplyFinished()
35
{
36
QNetworkReply *reply =
static_cast
<QNetworkReply *>(sender());
37
reply->deleteLater();
38
39
if
(reply->error() != QNetworkReply::NoError)
40
return
;
41
42
QByteArray
const
& imageData = reply->readAll();
43
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"
));
51
else
52
validFormat =
false
;
53
54
if
(validFormat)
55
setMapImageData(imageData);
56
57
setFinished(
true
);
58
}
59
60
void
GeoTiledMapReplyEsri::networkReplyError(QNetworkReply::NetworkError error)
61
{
62
QNetworkReply *reply =
static_cast
<QNetworkReply *>(sender());
63
reply->deleteLater();
64
if
(error == QNetworkReply::OperationCanceledError)
65
setFinished(
true
);
66
else
67
setError(QGeoTiledMapReply::CommunicationError, reply->errorString());
68
}
69
70
QT_END_NAMESPACE
pngSignature
static QT_BEGIN_NAMESPACE const unsigned char pngSignature[]
Definition
geotiledmapreply_esri.cpp:10
jpegSignature
static const unsigned char jpegSignature[]
Definition
geotiledmapreply_esri.cpp:11
gifSignature
static const unsigned char gifSignature[]
Definition
geotiledmapreply_esri.cpp:12
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qtlocation
src
plugins
geoservices
esri
geotiledmapreply_esri.cpp
Generated on
for Qt by
1.18.0