From 359e37f9c094c26d560fc049f70a53ea7be2bc6e Mon Sep 17 00:00:00 2001 From: DonLakeFlyer Date: Sat, 11 Jul 2020 09:58:01 -0700 Subject: [PATCH] Add getMapProviderFromId support --- src/QtLocationPlugin/QGCMapUrlEngine.cpp | 11 +++++++++++ src/QtLocationPlugin/QGCMapUrlEngine.h | 1 + 2 files changed, 12 insertions(+) diff --git a/src/QtLocationPlugin/QGCMapUrlEngine.cpp b/src/QtLocationPlugin/QGCMapUrlEngine.cpp index cc6be0266..31513f329 100644 --- a/src/QtLocationPlugin/QGCMapUrlEngine.cpp +++ b/src/QtLocationPlugin/QGCMapUrlEngine.cpp @@ -155,6 +155,17 @@ QString UrlFactory::getTypeFromId(int id) { return ""; } +MapProvider* UrlFactory::getMapProviderFromId(int id) +{ + QString type = getTypeFromId(id); + if (!type.isEmpty()) { + if (_providersTable.find(type) != _providersTable.end()) { + return _providersTable[type]; + } + } + 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 diff --git a/src/QtLocationPlugin/QGCMapUrlEngine.h b/src/QtLocationPlugin/QGCMapUrlEngine.h index 6809926d9..898cf4747 100644 --- a/src/QtLocationPlugin/QGCMapUrlEngine.h +++ b/src/QtLocationPlugin/QGCMapUrlEngine.h @@ -48,6 +48,7 @@ public: int getIdFromType(QString type); QString getTypeFromId(int id); + MapProvider* getMapProviderFromId(int id); QGCTileSet getTileCount(int zoom, double topleftLon, double topleftLat, double bottomRightLon, double bottomRightLat, -- 2.22.0