diff --git a/src/QtLocationPlugin/QGCMapEngine.cpp b/src/QtLocationPlugin/QGCMapEngine.cpp index 15774db3683e..6f29fc645710 100644 --- a/src/QtLocationPlugin/QGCMapEngine.cpp +++ b/src/QtLocationPlugin/QGCMapEngine.cpp @@ -200,7 +200,7 @@ QGCMapEngine::addTask(QGCMapTask* task) //----------------------------------------------------------------------------- void -QGCMapEngine::cacheTile(QString type, int x, int y, int z, const QByteArray& image, const QString &format, qulonglong set) +QGCMapEngine::cacheTile(const QString& 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); @@ -208,7 +208,7 @@ QGCMapEngine::cacheTile(QString type, int x, int y, int z, const QByteArray& ima //----------------------------------------------------------------------------- void -QGCMapEngine::cacheTile(QString type, const QString& hash, const QByteArray& image, const QString& format, qulonglong set) +QGCMapEngine::cacheTile(const QString& type, const QString& hash, const QByteArray& image, const QString& format, qulonglong set) { AppSettings* appSettings = qgcApp()->toolbox()->settingsManager()->appSettings(); //-- If we are allowed to persist data, save tile to cache @@ -220,7 +220,7 @@ QGCMapEngine::cacheTile(QString type, const QString& hash, const QByteArray& ima //----------------------------------------------------------------------------- QString -QGCMapEngine::getTileHash(QString type, int x, int y, int z) +QGCMapEngine::getTileHash(const QString& type, int x, int y, int z) { return QString::asprintf("%010d%08d%08d%03d", getQGCMapEngine()->urlFactory()->getIdFromType(type), x, y, z); } @@ -235,7 +235,7 @@ QGCMapEngine::hashToType(const QString& hash) //----------------------------------------------------------------------------- QGCFetchTileTask* -QGCMapEngine::createFetchTileTask(QString type, int x, int y, int z) +QGCMapEngine::createFetchTileTask(const QString& type, int x, int y, int z) { QString hash = getTileHash(type, x, y, z); QGCFetchTileTask* task = new QGCFetchTileTask(hash); @@ -244,7 +244,7 @@ QGCMapEngine::createFetchTileTask(QString type, int x, int y, int z) //----------------------------------------------------------------------------- QGCTileSet -QGCMapEngine::getTileCount(int zoom, double topleftLon, double topleftLat, double bottomRightLon, double bottomRightLat, QString mapType) +QGCMapEngine::getTileCount(int zoom, double topleftLon, double topleftLat, double bottomRightLon, double bottomRightLat, const QString& mapType) { if(zoom < 1) zoom = 1; if(zoom > MAX_MAP_ZOOM) zoom = MAX_MAP_ZOOM; @@ -368,7 +368,7 @@ QGCMapEngine::_pruned() //----------------------------------------------------------------------------- int -QGCMapEngine::concurrentDownloads(QString type) +QGCMapEngine::concurrentDownloads(const QString& type) { Q_UNUSED(type); // TODO : We may want different values depending on diff --git a/src/QtLocationPlugin/QGCMapEngine.h b/src/QtLocationPlugin/QGCMapEngine.h index 4f4668d64c4b..5f8bce7f2c14 100644 --- a/src/QtLocationPlugin/QGCMapEngine.h +++ b/src/QtLocationPlugin/QGCMapEngine.h @@ -36,13 +36,13 @@ class QGCMapEngine : public QObject void init (); void addTask (QGCMapTask *task); - void cacheTile (QString type, int x, int y, int z, const QByteArray& image, const QString& format, qulonglong set = UINT64_MAX); - void cacheTile (QString type, const QString& hash, const QByteArray& image, const QString& format, qulonglong set = UINT64_MAX); - QGCFetchTileTask* createFetchTileTask (QString type, int x, int y, int z); + void cacheTile (const QString& type, int x, int y, int z, const QByteArray& image, const QString& format, qulonglong set = UINT64_MAX); + void cacheTile (const QString& type, const QString& hash, const QByteArray& image, const QString& format, qulonglong set = UINT64_MAX); + QGCFetchTileTask* createFetchTileTask (const QString& type, int x, int y, int z); QStringList getMapNameList (); const QString userAgent () { return _userAgent; } void setUserAgent (const QString& ua) { _userAgent = ua; } - QString hashToType (const QString& hash); + QString hashToType (const QString& hash); quint32 getMaxDiskCache (); void setMaxDiskCache (quint32 size); quint32 getMaxMemCache (); @@ -56,13 +56,13 @@ class QGCMapEngine : public QObject UrlFactory* urlFactory () { return _urlFactory; } //-- Tile Math - static QGCTileSet getTileCount (int zoom, double topleftLon, double topleftLat, double bottomRightLon, double bottomRightLat, QString mapType); - static QString getTileHash (QString type, int x, int y, int z); - static QString getTypeFromName (const QString &name); + static QGCTileSet getTileCount (int zoom, double topleftLon, double topleftLat, double bottomRightLon, double bottomRightLat, const QString& mapType); + static QString getTileHash (const QString& type, int x, int y, int z); + static QString getTypeFromName (const QString& name); static QString bigSizeToString (quint64 size); static QString storageFreeSizeToString(quint64 size_MB); static QString numberToString (quint64 number); - static int concurrentDownloads (QString type); + static int concurrentDownloads (const QString& type); private slots: void _updateTotals (quint32 totaltiles, quint64 totalsize, quint32 defaulttiles, quint64 defaultsize); diff --git a/src/QtLocationPlugin/QGCMapUrlEngine.cpp b/src/QtLocationPlugin/QGCMapUrlEngine.cpp index d20ac2fcb3ea..a19df29f7b9b 100644 --- a/src/QtLocationPlugin/QGCMapUrlEngine.cpp +++ b/src/QtLocationPlugin/QGCMapUrlEngine.cpp @@ -109,7 +109,7 @@ QString UrlFactory::getImageFormat(int id, const QByteArray& image) { } //----------------------------------------------------------------------------- -QString UrlFactory::getImageFormat(QString type, const QByteArray& image) { +QString UrlFactory::getImageFormat(const QString& type, const QByteArray& image) { if (_providersTable.find(type) != _providersTable.end()) { return _providersTable[type]->getImageFormat(image); } else { @@ -130,7 +130,7 @@ QNetworkRequest UrlFactory::getTileURL(int id, int x, int y, int zoom, } //----------------------------------------------------------------------------- -QNetworkRequest UrlFactory::getTileURL(QString type, int x, int y, int zoom, +QNetworkRequest UrlFactory::getTileURL(const QString& type, int x, int y, int zoom, QNetworkAccessManager* networkManager) { if (_providersTable.find(type) != _providersTable.end()) { return _providersTable[type]->getTileURL(x, y, zoom, networkManager); @@ -140,7 +140,7 @@ QNetworkRequest UrlFactory::getTileURL(QString type, int x, int y, int zoom, } //----------------------------------------------------------------------------- -quint32 UrlFactory::averageSizeForType(QString type) { +quint32 UrlFactory::averageSizeForType(const QString& type) { if (_providersTable.find(type) != _providersTable.end()) { return _providersTable[type]->getAverageSize(); } @@ -180,21 +180,26 @@ MapProvider* UrlFactory::getMapProviderFromId(int id) return nullptr; } +//----------------------------------------------------------------------------- // Todo : qHash produce a uint bigger than max(int) // There is still a low probability for this to // generate similar hash for different types -int UrlFactory::getIdFromType(QString type) { return (int)(qHash(type)>>1); } +int +UrlFactory::getIdFromType(const QString& type) +{ + return (int)(qHash(type)>>1); +} //----------------------------------------------------------------------------- int -UrlFactory::long2tileX(QString mapType, double lon, int z) +UrlFactory::long2tileX(const QString& mapType, double lon, int z) { return _providersTable[mapType]->long2tileX(lon, z); } //----------------------------------------------------------------------------- int -UrlFactory::lat2tileY(QString mapType, double lat, int z) +UrlFactory::lat2tileY(const QString& mapType, double lat, int z) { return _providersTable[mapType]->lat2tileY(lat, z); } @@ -202,7 +207,7 @@ UrlFactory::lat2tileY(QString mapType, double lat, int z) //----------------------------------------------------------------------------- QGCTileSet -UrlFactory::getTileCount(int zoom, double topleftLon, double topleftLat, double bottomRightLon, double bottomRightLat, QString mapType) +UrlFactory::getTileCount(int zoom, double topleftLon, double topleftLat, double bottomRightLon, double bottomRightLat, const QString& mapType) { return _providersTable[mapType]->getTileCount(zoom, topleftLon, topleftLat, bottomRightLon, bottomRightLat); } diff --git a/src/QtLocationPlugin/QGCMapUrlEngine.h b/src/QtLocationPlugin/QGCMapUrlEngine.h index 4215ee3a6fef..f3688a8abb7f 100644 --- a/src/QtLocationPlugin/QGCMapUrlEngine.h +++ b/src/QtLocationPlugin/QGCMapUrlEngine.h @@ -35,26 +35,26 @@ class UrlFactory : public QObject { UrlFactory (); ~UrlFactory (); - QNetworkRequest getTileURL (QString type, int x, int y, int zoom, QNetworkAccessManager* networkManager); + QNetworkRequest getTileURL (const QString& type, int x, int y, int zoom, QNetworkAccessManager* networkManager); QNetworkRequest getTileURL (int id, int x, int y, int zoom, QNetworkAccessManager* networkManager); - QString getImageFormat (QString type, const QByteArray& image); + QString getImageFormat (const QString& type, const QByteArray& image); QString getImageFormat (int id , const QByteArray& image); - quint32 averageSizeForType (QString type); + quint32 averageSizeForType (const QString& type); - int long2tileX(QString mapType, double lon, int z); - int lat2tileY(QString mapType, double lat, int z); + int long2tileX(const QString& mapType, double lon, int z); + int lat2tileY(const QString& mapType, double lat, int z); QHash getProviderTable(){return _providersTable;} - int getIdFromType(QString type); + int getIdFromType(const QString& type); QString getTypeFromId(int id); MapProvider* getMapProviderFromId(int id); QGCTileSet getTileCount(int zoom, double topleftLon, double topleftLat, double bottomRightLon, double bottomRightLat, - QString mapType); + const QString& mapType); bool isElevation(int mapId);