7
7
*
8
8
****************************************************************************/
9
9
10
- /* *
11
- * @file
12
- * @brief Map Tile Set
13
- *
14
- * @author Gus Grubba <[email protected] >
15
- *
16
- */
17
-
18
10
#include " QGCCachedTileSet.h"
19
11
12
+ #include < QtNetwork/QNetworkProxy>
13
+
20
14
#include " ElevationMapProvider.h"
15
+ #include < QGCApplication.h>
16
+ #include < QGCFileDownload.h>
17
+ #include < QGCLoggingCategory.h>
21
18
#include " QGCMapEngine.h"
22
19
#include " QGCMapEngineManager.h"
23
20
#include " QGCMapTasks.h"
24
21
#include " QGCMapUrlEngine.h"
25
22
#include " QGeoFileTileCacheQGC.h"
26
23
#include " QGeoTileFetcherQGC.h"
27
24
28
- #include < QGCApplication.h>
29
- #include < QGCFileDownload.h>
30
- #include < QGCLoggingCategory.h>
31
-
32
- #include < QtNetwork/QNetworkProxy>
33
25
34
26
QGC_LOGGING_CATEGORY (QGCCachedTileSetLog, " qgc.qtlocation.qgccachedtileset" )
35
27
36
28
QGCCachedTileSet::QGCCachedTileSet(const QString &name, QObject *parent)
37
29
: QObject(parent)
38
30
, _name(name)
39
31
{
40
- // qCDebug(QGCCachedTileSetLog) << Q_FUNC_INFO << this;
32
+ qCDebug (QGCCachedTileSetLog) << this ;
41
33
}
42
34
43
35
QGCCachedTileSet::~QGCCachedTileSet ()
44
36
{
45
- // qCDebug(QGCCachedTileSetLog) << Q_FUNC_INFO << this;
37
+ qCDebug (QGCCachedTileSetLog) << this ;
46
38
}
47
39
48
40
QString QGCCachedTileSet::downloadStatus () const
@@ -118,7 +110,7 @@ void QGCCachedTileSet::_tileListFetched(const QQueue<QGCTile*> &tiles)
118
110
#endif
119
111
}
120
112
121
- ( void ) _tilesToDownload.append (tiles);
113
+ _tilesToDownload.append (tiles);
122
114
_prepareDownload ();
123
115
}
124
116
@@ -132,7 +124,7 @@ void QGCCachedTileSet::_doneWithDownload()
132
124
if (_savedTileSize != 0 ) {
133
125
avg = _savedTileSize / _savedTileCount;
134
126
} else {
135
- qCWarning (QGCCachedTileSetLog) << Q_FUNC_INFO << " _savedTileSize=0" ;
127
+ qCWarning (QGCCachedTileSetLog) << " _savedTileSize=0" ;
136
128
}
137
129
138
130
setUniqueTileSize (_uniqueTileCount * avg);
@@ -160,17 +152,17 @@ void QGCCachedTileSet::_prepareDownload()
160
152
}
161
153
162
154
QGCTile* const tile = _tilesToDownload.dequeue ();
163
- const int mapId = UrlFactory::getQtMapIdFromProviderType (tile->type () );
164
- QNetworkRequest request = QGeoTileFetcherQGC::getNetworkRequest (mapId, tile->x () , tile->y () , tile->z () );
155
+ const int mapId = UrlFactory::getQtMapIdFromProviderType (tile->type );
156
+ QNetworkRequest request = QGeoTileFetcherQGC::getNetworkRequest (mapId, tile->x , tile->y , tile->z );
165
157
request.setOriginatingObject (this );
166
- request.setAttribute (QNetworkRequest::User, tile->hash () );
158
+ request.setAttribute (QNetworkRequest::User, tile->hash );
167
159
168
160
QNetworkReply* const reply = _networkManager->get (request);
169
161
reply->setParent (this );
170
162
QGCFileDownload::setIgnoreSSLErrorsIfNeeded (*reply);
171
163
(void ) connect (reply, &QNetworkReply::finished, this , &QGCCachedTileSet::_networkReplyFinished);
172
164
(void ) connect (reply, &QNetworkReply::errorOccurred, this , &QGCCachedTileSet::_networkReplyError);
173
- (void ) _replies.insert (tile->hash () , reply);
165
+ (void ) _replies.insert (tile->hash , reply);
174
166
175
167
delete tile;
176
168
if (!_batchRequested && !_noMoreTiles && (_tilesToDownload.count () < (QGeoTileFetcherQGC::concurrentDownloads (_type) * 10 ))) {
@@ -183,7 +175,7 @@ void QGCCachedTileSet::_networkReplyFinished()
183
175
{
184
176
QNetworkReply* const reply = qobject_cast<QNetworkReply*>(QObject::sender ());
185
177
if (!reply) {
186
- qCWarning (QGCCachedTileSetLog) << Q_FUNC_INFO << " NULL Reply" ;
178
+ qCWarning (QGCCachedTileSetLog) << " NULL Reply" ;
187
179
return ;
188
180
}
189
181
reply->deleteLater ();
@@ -193,26 +185,26 @@ void QGCCachedTileSet::_networkReplyFinished()
193
185
}
194
186
195
187
if (!reply->isOpen ()) {
196
- qCWarning (QGCCachedTileSetLog) << Q_FUNC_INFO << " Empty Reply" ;
188
+ qCWarning (QGCCachedTileSetLog) << " Empty Reply" ;
197
189
return ;
198
190
}
199
191
200
192
const QString hash = reply->request ().attribute (QNetworkRequest::User).toString ();
201
193
if (hash.isEmpty ()) {
202
- qCWarning (QGCCachedTileSetLog) << Q_FUNC_INFO << " Empty Hash" ;
194
+ qCWarning (QGCCachedTileSetLog) << " Empty Hash" ;
203
195
return ;
204
196
}
205
197
206
198
if (_replies.contains (hash)) {
207
199
(void ) _replies.remove (hash);
208
200
} else {
209
- qCWarning (QGCCachedTileSetLog) << Q_FUNC_INFO << " Reply not in list: " << hash;
201
+ qCWarning (QGCCachedTileSetLog) << " Reply not in list: " << hash;
210
202
}
211
203
qCDebug (QGCCachedTileSetLog) << " Tile fetched:" << hash;
212
204
213
205
QByteArray image = reply->readAll ();
214
206
if (image.isEmpty ()) {
215
- qCWarning (QGCCachedTileSetLog) << Q_FUNC_INFO << " Empty Image" ;
207
+ qCWarning (QGCCachedTileSetLog) << " Empty Image" ;
216
208
return ;
217
209
}
218
210
@@ -224,14 +216,14 @@ void QGCCachedTileSet::_networkReplyFinished()
224
216
const SharedElevationProvider elevationProvider = std::dynamic_pointer_cast<const ElevationProvider>(mapProvider);
225
217
image = elevationProvider->serialize (image);
226
218
if (image.isEmpty ()) {
227
- qCWarning (QGCCachedTileSetLog) << Q_FUNC_INFO << " Failed to Serialize Terrain Tile" ;
219
+ qCWarning (QGCCachedTileSetLog) << " Failed to Serialize Terrain Tile" ;
228
220
return ;
229
221
}
230
222
}
231
223
232
224
const QString format = mapProvider->getImageFormat (image);
233
225
if (format.isEmpty ()) {
234
- qCWarning (QGCCachedTileSetLog) << Q_FUNC_INFO << " Empty Format" ;
226
+ qCWarning (QGCCachedTileSetLog) << " Empty Format" ;
235
227
return ;
236
228
}
237
229
@@ -258,24 +250,24 @@ void QGCCachedTileSet::_networkReplyError(QNetworkReply::NetworkError error)
258
250
if (!reply) {
259
251
return ;
260
252
}
261
- qCDebug (QGCCachedTileSetLog) << Q_FUNC_INFO << " Error fetching tile" << reply->errorString ();
253
+ qCDebug (QGCCachedTileSetLog) << " Error fetching tile" << reply->errorString ();
262
254
263
255
setErrorCount (_errorCount + 1 );
264
256
265
257
const QString hash = reply->request ().attribute (QNetworkRequest::User).toString ();
266
258
if (hash.isEmpty ()) {
267
- qCWarning (QGCCachedTileSetLog) << Q_FUNC_INFO << " Empty Hash" ;
259
+ qCWarning (QGCCachedTileSetLog) << " Empty Hash" ;
268
260
return ;
269
261
}
270
262
271
263
if (_replies.contains (hash)) {
272
264
(void ) _replies.remove (hash);
273
265
} else {
274
- qCWarning (QGCCachedTileSetLog) << Q_FUNC_INFO << " Reply not in list:" << hash;
266
+ qCWarning (QGCCachedTileSetLog) << " Reply not in list:" << hash;
275
267
}
276
268
277
269
if (error != QNetworkReply::OperationCanceledError) {
278
- qCWarning (QGCCachedTileSetLog) << Q_FUNC_INFO << " Error:" << reply->errorString ();
270
+ qCWarning (QGCCachedTileSetLog) << " Error:" << reply->errorString ();
279
271
}
280
272
281
273
QGCUpdateTileDownloadStateTask* const task = new QGCUpdateTileDownloadStateTask (_id, QGCTile::StateError, hash);
0 commit comments