QGCMapEngine.cpp 17.4 KB
Newer Older
1 2 3 4 5 6 7 8
/****************************************************************************
 *
 *   (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/
dogmaphobic's avatar
dogmaphobic committed
9 10 11 12 13 14 15 16 17 18 19 20 21 22


/**
 * @file
 *   @brief Map Tile Cache
 *
 *   @author Gus Grubba <mavlink@grubba.com>
 *
 */

#include <math.h>
#include <QSettings>
#include <QStandardPaths>
#include <QDir>
Gus Grubba's avatar
Gus Grubba committed
23
#include <stdio.h>
dogmaphobic's avatar
dogmaphobic committed
24 25 26 27 28 29 30 31 32 33 34

#include "QGCMapEngine.h"
#include "QGCMapTileSet.h"

Q_DECLARE_METATYPE(QGCMapTask::TaskType)
Q_DECLARE_METATYPE(QGCTile)
Q_DECLARE_METATYPE(QList<QGCTile*>)

static const char* kDbFileName = "qgcMapCache.db";
static QLocale kLocale;

dogmaphobic's avatar
dogmaphobic committed
35
#define CACHE_PATH_VERSION  "300"
36

dogmaphobic's avatar
dogmaphobic committed
37 38 39 40 41 42 43 44 45
struct stQGeoTileCacheQGCMapTypes {
    const char* name;
    UrlFactory::MapType type;
};

//-- IMPORTANT
//   Changes here must reflect those in QGeoTiledMappingManagerEngineQGC.cpp

stQGeoTileCacheQGCMapTypes kMapTypes[] = {
46
#ifndef QGC_LIMITED_MAPS
dogmaphobic's avatar
dogmaphobic committed
47 48 49
    {"Google Street Map",       UrlFactory::GoogleMap},
    {"Google Satellite Map",    UrlFactory::GoogleSatellite},
    {"Google Terrain Map",      UrlFactory::GoogleTerrain},
50
#endif
dogmaphobic's avatar
dogmaphobic committed
51 52 53
    {"Bing Street Map",         UrlFactory::BingMap},
    {"Bing Satellite Map",      UrlFactory::BingSatellite},
    {"Bing Hybrid Map",         UrlFactory::BingHybrid},
54
    {"Statkart Topo2",          UrlFactory::StatkartTopo},
Gus Grubba's avatar
Gus Grubba committed
55
    /*
dogmaphobic's avatar
dogmaphobic committed
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
    {"MapQuest Street Map",     UrlFactory::MapQuestMap},
    {"MapQuest Satellite Map",  UrlFactory::MapQuestSat}
    {"Open Street Map",         UrlFactory::OpenStreetMap}
     */
};

#define NUM_MAPS (sizeof(kMapTypes) / sizeof(stQGeoTileCacheQGCMapTypes))

stQGeoTileCacheQGCMapTypes kMapBoxTypes[] = {
    {"MapBox Street Map",       UrlFactory::MapBoxStreets},
    {"MapBox Satellite Map",    UrlFactory::MapBoxSatellite},
    {"MapBox High Contrast Map",UrlFactory::MapBoxHighContrast},
    {"MapBox Light Map",        UrlFactory::MapBoxLight},
    {"MapBox Dark Map",         UrlFactory::MapBoxDark},
    {"MapBox Hybrid Map",       UrlFactory::MapBoxHybrid},
    {"MapBox Wheat Paste Map",  UrlFactory::MapBoxWheatPaste},
    {"MapBox Streets Basic Map",UrlFactory::MapBoxStreetsBasic},
    {"MapBox Comic Map",        UrlFactory::MapBoxComic},
    {"MapBox Outdoors Map",     UrlFactory::MapBoxOutdoors},
    {"MapBox Run, Byke and Hike Map",   UrlFactory::MapBoxRunBikeHike},
    {"MapBox Pencil Map",       UrlFactory::MapBoxPencil},
    {"MapBox Pirates Map",      UrlFactory::MapBoxPirates},
    {"MapBox Emerald Map",      UrlFactory::MapBoxEmerald}
};

#define NUM_MAPBOXMAPS (sizeof(kMapBoxTypes) / sizeof(stQGeoTileCacheQGCMapTypes))

Gus Grubba's avatar
Gus Grubba committed
83 84 85 86 87 88 89 90
stQGeoTileCacheQGCMapTypes kEsriTypes[] = {
    {"Esri Street Map",       UrlFactory::EsriWorldStreet},
    {"Esri Satellite Map",    UrlFactory::EsriWorldSatellite},
    {"Esri Terrain Map",      UrlFactory::EsriTerrain}
};

#define NUM_ESRIMAPS (sizeof(kEsriTypes) / sizeof(stQGeoTileCacheQGCMapTypes))

dogmaphobic's avatar
dogmaphobic committed
91
static const char* kMapBoxTokenKey  = "MapBoxToken";
Gus Grubba's avatar
Gus Grubba committed
92
static const char* kEsriTokenKey    = "EsriToken";
dogmaphobic's avatar
dogmaphobic committed
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
static const char* kMaxDiskCacheKey = "MaxDiskCache";
static const char* kMaxMemCacheKey  = "MaxMemoryCache";

//-----------------------------------------------------------------------------
// Singleton
static QGCMapEngine* kMapEngine = NULL;
QGCMapEngine*
getQGCMapEngine()
{
    if(!kMapEngine)
        kMapEngine = new QGCMapEngine();
    return kMapEngine;
}

//-----------------------------------------------------------------------------
void
destroyMapEngine()
{
    if(kMapEngine) {
        delete kMapEngine;
        kMapEngine = NULL;
    }
}

//-----------------------------------------------------------------------------
QGCMapEngine::QGCMapEngine()
119
    : _urlFactory(new UrlFactory())
dogmaphobic's avatar
dogmaphobic committed
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
#ifdef WE_ARE_KOSHER
    //-- TODO: Get proper version
    #if defined Q_OS_MAC
        , _userAgent("QGroundControl (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.75.14 (KHTML, like Gecko) Version/2.9.0")
    #elif defined Q_OS_WIN32
        , _userAgent("QGroundControl (Windows; Windows NT 6.0) (KHTML, like Gecko) Version/2.9.0")
    #else
        , _userAgent("QGroundControl (X11; Ubuntu; Linux x86_64) (KHTML, like Gecko) Version/2.9.0")
    #endif
#else
    #if defined Q_OS_MAC
        , _userAgent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:25.0) Gecko/20100101 Firefox/25.0")
    #elif defined Q_OS_WIN32
        , _userAgent("Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20130401 Firefox/31.0")
    #else
        , _userAgent("Mozilla/5.0 (X11; Linux i586; rv:31.0) Gecko/20100101 Firefox/31.0")
    #endif
#endif
    , _maxDiskCache(0)
    , _maxMemCache(0)
    , _prunning(false)
dogmaphobic's avatar
dogmaphobic committed
141
    , _cacheWasReset(false)
142
    , _isInternetActive(false)
dogmaphobic's avatar
dogmaphobic committed
143 144 145 146
{
    qRegisterMetaType<QGCMapTask::TaskType>();
    qRegisterMetaType<QGCTile>();
    qRegisterMetaType<QList<QGCTile*>>();
147 148
    connect(&_worker, &QGCCacheWorker::updateTotals,   this, &QGCMapEngine::_updateTotals);
    connect(&_worker, &QGCCacheWorker::internetStatus, this, &QGCMapEngine::_internetStatus);
dogmaphobic's avatar
dogmaphobic committed
149 150 151 152 153 154 155 156 157 158 159
}

//-----------------------------------------------------------------------------
QGCMapEngine::~QGCMapEngine()
{
    _worker.quit();
    _worker.wait();
    if(_urlFactory)
        delete _urlFactory;
}

dogmaphobic's avatar
dogmaphobic committed
160 161 162 163 164 165 166 167 168 169 170
//-----------------------------------------------------------------------------
void
QGCMapEngine::_checkWipeDirectory(const QString& dirPath)
{
    QDir dir(dirPath);
    if (dir.exists(dirPath)) {
        _cacheWasReset = true;
        _wipeDirectory(dirPath);
    }
}

dogmaphobic's avatar
dogmaphobic committed
171 172
//-----------------------------------------------------------------------------
void
dogmaphobic's avatar
dogmaphobic committed
173
QGCMapEngine::_wipeOldCaches()
dogmaphobic's avatar
dogmaphobic committed
174
{
dogmaphobic's avatar
dogmaphobic committed
175 176 177 178 179 180
    QString oldCacheDir;
#ifdef __mobile__
    oldCacheDir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)      + QLatin1String("/QGCMapCache55");
#else
    oldCacheDir = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) + QLatin1String("/QGCMapCache55");
#endif
dogmaphobic's avatar
dogmaphobic committed
181
    _checkWipeDirectory(oldCacheDir);
dogmaphobic's avatar
dogmaphobic committed
182
#ifdef __mobile__
dogmaphobic's avatar
dogmaphobic committed
183
    oldCacheDir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)      + QLatin1String("/QGCMapCache100");
dogmaphobic's avatar
dogmaphobic committed
184
#else
dogmaphobic's avatar
dogmaphobic committed
185
    oldCacheDir = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) + QLatin1String("/QGCMapCache100");
186
#endif
dogmaphobic's avatar
dogmaphobic committed
187
    _checkWipeDirectory(oldCacheDir);
dogmaphobic's avatar
dogmaphobic committed
188 189 190 191 192 193 194 195
}

//-----------------------------------------------------------------------------
void
QGCMapEngine::init()
{
    //-- Delete old style caches (if present)
    _wipeOldCaches();
196 197 198 199 200
    //-- Figure out cache path
#ifdef __mobile__
    QString cacheDir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)      + QLatin1String("/QGCMapCache" CACHE_PATH_VERSION);
#else
    QString cacheDir = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) + QLatin1String("/QGCMapCache" CACHE_PATH_VERSION);
dogmaphobic's avatar
dogmaphobic committed
201 202 203 204 205 206 207 208 209 210 211 212 213
#endif
    if(!QDir::root().mkpath(cacheDir)) {
        qWarning() << "Could not create mapping disk cache directory: " << cacheDir;
        cacheDir = QDir::homePath() + QLatin1String("/.qgcmapscache/");
        if(!QDir::root().mkpath(cacheDir)) {
            qWarning() << "Could not create mapping disk cache directory: " << cacheDir;
            cacheDir.clear();
        }
    }
    _cachePath = cacheDir;
    if(!_cachePath.isEmpty()) {
        _cacheFile = kDbFileName;
        _worker.setDatabaseFile(_cachePath + "/" + _cacheFile);
214
        qDebug() << "Map Cache in:" << _cachePath << "/" << _cacheFile;
dogmaphobic's avatar
dogmaphobic committed
215 216 217 218 219 220 221
    } else {
        qCritical() << "Could not find suitable map cache directory.";
    }
    QGCMapTask* task = new QGCMapTask(QGCMapTask::taskInit);
    _worker.enqueueTask(task);
}

222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243
//-----------------------------------------------------------------------------
bool
QGCMapEngine::_wipeDirectory(const QString& dirPath)
{
    bool result = true;
    QDir dir(dirPath);
    if (dir.exists(dirPath)) {
        Q_FOREACH(QFileInfo info, dir.entryInfoList(QDir::NoDotAndDotDot | QDir::System | QDir::Hidden  | QDir::AllDirs | QDir::Files, QDir::DirsFirst)) {
            if (info.isDir()) {
                result = _wipeDirectory(info.absoluteFilePath());
            } else {
                result = QFile::remove(info.absoluteFilePath());
            }
            if (!result) {
                return result;
            }
        }
        result = dir.rmdir(dirPath);
    }
    return result;
}

dogmaphobic's avatar
dogmaphobic committed
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270
//-----------------------------------------------------------------------------
void
QGCMapEngine::addTask(QGCMapTask* task)
{
    _worker.enqueueTask(task);
}

//-----------------------------------------------------------------------------
void
QGCMapEngine::cacheTile(UrlFactory::MapType type, int x, int y, int z, const QByteArray& image, const QString &format, qulonglong set)
{
    QString hash = getTileHash(type, x, y, z);
    cacheTile(type, hash, image, format, set);
}

//-----------------------------------------------------------------------------
void
QGCMapEngine::cacheTile(UrlFactory::MapType type, const QString& hash, const QByteArray& image, const QString& format, qulonglong set)
{
    QGCSaveTileTask* task = new QGCSaveTileTask(new QGCCacheTile(hash, image, format, type, set));
    _worker.enqueueTask(task);
}

//-----------------------------------------------------------------------------
QString
QGCMapEngine::getTileHash(UrlFactory::MapType type, int x, int y, int z)
{
Gus Grubba's avatar
Gus Grubba committed
271
    return QString().sprintf("%04d%08d%08d%03d", (int)type, x, y, z);
dogmaphobic's avatar
dogmaphobic committed
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295
}

//-----------------------------------------------------------------------------
UrlFactory::MapType
QGCMapEngine::hashToType(const QString& hash)
{
    QString type = hash.mid(0,4);
    return (UrlFactory::MapType)type.toInt();
}

//-----------------------------------------------------------------------------
QGCFetchTileTask*
QGCMapEngine::createFetchTileTask(UrlFactory::MapType type, int x, int y, int z)
{
    QString hash = getTileHash(type, x, y, z);
    QGCFetchTileTask* task = new QGCFetchTileTask(hash);
    return task;
}

//-----------------------------------------------------------------------------
QGCTileSet
QGCMapEngine::getTileCount(int zoom, double topleftLon, double topleftLat, double bottomRightLon, double bottomRightLat, UrlFactory::MapType mapType)
{
    if(zoom <  1) zoom = 1;
296
    if(zoom > MAX_MAP_ZOOM) zoom = MAX_MAP_ZOOM;
dogmaphobic's avatar
dogmaphobic committed
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333
    QGCTileSet set;
    set.tileX0 = long2tileX(topleftLon,     zoom);
    set.tileY0 = lat2tileY(topleftLat,      zoom);
    set.tileX1 = long2tileX(bottomRightLon, zoom);
    set.tileY1 = lat2tileY(bottomRightLat,  zoom);
    set.tileCount = (quint64)((quint64)set.tileX1 - (quint64)set.tileX0 + 1) * (quint64)((quint64)set.tileY1 - (quint64)set.tileY0 + 1);
    set.tileSize  = UrlFactory::averageSizeForType(mapType) * set.tileCount;
    return set;
}

//-----------------------------------------------------------------------------
int
QGCMapEngine::long2tileX(double lon, int z)
{
    return (int)(floor((lon + 180.0) / 360.0 * pow(2.0, z)));
}

//-----------------------------------------------------------------------------
int
QGCMapEngine::lat2tileY(double lat, int z)
{
    return (int)(floor((1.0 - log( tan(lat * M_PI/180.0) + 1.0 / cos(lat * M_PI/180.0)) / M_PI) / 2.0 * pow(2.0, z)));
}

//-----------------------------------------------------------------------------
UrlFactory::MapType
QGCMapEngine::getTypeFromName(const QString& name)
{
    size_t i;
    for(i = 0; i < NUM_MAPS; i++) {
        if(name.compare(kMapTypes[i].name, Qt::CaseInsensitive) == 0)
            return kMapTypes[i].type;
    }
    for(i = 0; i < NUM_MAPBOXMAPS; i++) {
        if(name.compare(kMapBoxTypes[i].name, Qt::CaseInsensitive) == 0)
            return kMapBoxTypes[i].type;
    }
Gus Grubba's avatar
Gus Grubba committed
334 335 336 337
    for(i = 0; i < NUM_ESRIMAPS; i++) {
        if(name.compare(kEsriTypes[i].name, Qt::CaseInsensitive) == 0)
            return kEsriTypes[i].type;
    }
dogmaphobic's avatar
dogmaphobic committed
338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353
    return UrlFactory::Invalid;
}

//-----------------------------------------------------------------------------
QStringList
QGCMapEngine::getMapNameList()
{
    QStringList mapList;
    for(size_t i = 0; i < NUM_MAPS; i++) {
        mapList << kMapTypes[i].name;
    }
    if(!getMapBoxToken().isEmpty()) {
        for(size_t i = 0; i < NUM_MAPBOXMAPS; i++) {
            mapList << kMapBoxTypes[i].name;
        }
    }
Gus Grubba's avatar
Gus Grubba committed
354 355 356 357 358
    if(!getEsriToken().isEmpty()) {
        for(size_t i = 0; i < NUM_ESRIMAPS; i++) {
            mapList << kEsriTypes[i].name;
        }
    }
dogmaphobic's avatar
dogmaphobic committed
359 360 361 362 363 364 365 366 367 368 369 370
    return mapList;
}

//-----------------------------------------------------------------------------
void
QGCMapEngine::setMapBoxToken(const QString& token)
{
    QSettings settings;
    settings.setValue(kMapBoxTokenKey, token);
    _mapBoxToken = token;
}

Gus Grubba's avatar
Gus Grubba committed
371 372 373 374 375 376 377 378 379
//-----------------------------------------------------------------------------
void
QGCMapEngine::setEsriToken(const QString& token)
{
    QSettings settings;
    settings.setValue(kEsriTokenKey, token);
    _esriToken = token;
}

dogmaphobic's avatar
dogmaphobic committed
380 381 382 383 384 385 386 387 388 389 390
//-----------------------------------------------------------------------------
QString
QGCMapEngine::getMapBoxToken()
{
    if(_mapBoxToken.isEmpty()) {
        QSettings settings;
        _mapBoxToken = settings.value(kMapBoxTokenKey).toString();
    }
    return _mapBoxToken;
}

Gus Grubba's avatar
Gus Grubba committed
391 392 393 394 395 396 397 398 399 400 401
//-----------------------------------------------------------------------------
QString
QGCMapEngine::getEsriToken()
{
    if(_esriToken.isEmpty()) {
        QSettings settings;
        _esriToken = settings.value(kEsriTokenKey).toString();
    }
    return _esriToken;
}

dogmaphobic's avatar
dogmaphobic committed
402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433
//-----------------------------------------------------------------------------
quint32
QGCMapEngine::getMaxDiskCache()
{
    if(!_maxDiskCache) {
        QSettings settings;
        _maxDiskCache = settings.value(kMaxDiskCacheKey, 1024).toUInt();
    }
    return _maxDiskCache;
}

//-----------------------------------------------------------------------------
void
QGCMapEngine::setMaxDiskCache(quint32 size)
{
    QSettings settings;
    settings.setValue(kMaxDiskCacheKey, size);
    _maxDiskCache = size;
}

//-----------------------------------------------------------------------------
quint32
QGCMapEngine::getMaxMemCache()
{
    if(!_maxMemCache) {
        QSettings settings;
#ifdef __mobile__
        _maxMemCache = settings.value(kMaxMemCacheKey, 16).toUInt();
#else
        _maxMemCache = settings.value(kMaxMemCacheKey, 128).toUInt();
#endif
    }
434 435 436
    //-- Size in MB
    if(_maxMemCache > 1024)
        _maxMemCache = 1024;
dogmaphobic's avatar
dogmaphobic committed
437 438 439 440 441 442 443
    return _maxMemCache;
}

//-----------------------------------------------------------------------------
void
QGCMapEngine::setMaxMemCache(quint32 size)
{
444 445 446
    //-- Size in MB
    if(size > 1024)
        size = 1024;
dogmaphobic's avatar
dogmaphobic committed
447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469
    QSettings settings;
    settings.setValue(kMaxMemCacheKey, size);
    _maxMemCache = size;
}

//-----------------------------------------------------------------------------
QString
QGCMapEngine::bigSizeToString(quint64 size)
{
    if(size < 1024)
        return kLocale.toString(size);
    else if(size < 1024 * 1024)
        return kLocale.toString((double)size / 1024.0, 'f', 1) + "kB";
    else if(size < 1024 * 1024 * 1024)
        return kLocale.toString((double)size / (1024.0 * 1024.0), 'f', 1) + "MB";
    else if(size < 1024.0 * 1024.0 * 1024.0 * 1024.0)
        return kLocale.toString((double)size / (1024.0 * 1024.0 * 1024.0), 'f', 1) + "GB";
    else
        return kLocale.toString((double)size / (1024.0 * 1024.0 * 1024.0 * 1024), 'f', 1) + "TB";
}

//-----------------------------------------------------------------------------
QString
dogmaphobic's avatar
dogmaphobic committed
470
QGCMapEngine::numberToString(quint64 number)
dogmaphobic's avatar
dogmaphobic committed
471 472 473 474 475 476 477 478 479
{
    return kLocale.toString(number);
}

//-----------------------------------------------------------------------------
void
QGCMapEngine::_updateTotals(quint32 totaltiles, quint64 totalsize, quint32 defaulttiles, quint64 defaultsize)
{
    emit updateTotals(totaltiles, totalsize, defaulttiles, defaultsize);
dogmaphobic's avatar
dogmaphobic committed
480
    quint64 maxSize = (quint64)getMaxDiskCache() * 1024L * 1024L;
dogmaphobic's avatar
dogmaphobic committed
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506
    if(!_prunning && defaultsize > maxSize) {
        //-- Prune Disk Cache
        _prunning = true;
        QGCPruneCacheTask* task = new QGCPruneCacheTask(defaultsize - maxSize);
        connect(task, &QGCPruneCacheTask::pruned, this, &QGCMapEngine::_pruned);
        getQGCMapEngine()->addTask(task);
    }
}
//-----------------------------------------------------------------------------
void
QGCMapEngine::_pruned()
{
    _prunning = false;
}

//-----------------------------------------------------------------------------
int
QGCMapEngine::concurrentDownloads(UrlFactory::MapType type)
{
    switch(type) {
    case UrlFactory::GoogleMap:
    case UrlFactory::GoogleSatellite:
    case UrlFactory::GoogleTerrain:
    case UrlFactory::BingMap:
    case UrlFactory::BingSatellite:
    case UrlFactory::BingHybrid:
507
    case UrlFactory::StatkartTopo:
Gus Grubba's avatar
Gus Grubba committed
508 509 510
    case UrlFactory::EsriWorldStreet:
    case UrlFactory::EsriWorldSatellite:
    case UrlFactory::EsriTerrain:
dogmaphobic's avatar
dogmaphobic committed
511
        return 12;
Gus Grubba's avatar
Gus Grubba committed
512
    /*
dogmaphobic's avatar
dogmaphobic committed
513 514 515
    case UrlFactory::MapQuestMap:
    case UrlFactory::MapQuestSat:
        return 8;
Gus Grubba's avatar
Gus Grubba committed
516
    */
dogmaphobic's avatar
dogmaphobic committed
517 518 519 520 521 522 523 524 525 526 527 528 529 530
    default:
        break;
    }
    return 6;
}

//-----------------------------------------------------------------------------
QGCCreateTileSetTask::~QGCCreateTileSetTask()
{
    //-- If not sent out, delete it
    if(!_saved && _tileSet)
        delete _tileSet;
}

531 532 533 534 535 536 537 538 539 540 541 542 543 544
//-----------------------------------------------------------------------------
void
QGCMapEngine::testInternet()
{
    getQGCMapEngine()->addTask(new QGCTestInternetTask());
}

//-----------------------------------------------------------------------------
void
QGCMapEngine::_internetStatus(bool active)
{
    _isInternetActive = active;
}

dogmaphobic's avatar
dogmaphobic committed
545 546
// Resolution math: https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#Resolution_and_Scale