QGC (QGroundControl) ground station teaches you how to change it-the addition of Gaode map and online resource of tile map


All the love must spare no effort. If you really like it, give it higher priority and more time!

For other articles about QGC ground station, please click here:     QGC ground station


1. Demonstration effect

    The map source on the QGC ground station is either unusable or relatively old. Google Maps is best to use, but it is troublesome, you know. Here is how to add a high German map. Other maps are similar. The effect after adding is as follows:

Insert picture description here
In fact, sometimes it can’t be loaded, so it’s better to download it offline in advance.

2. Code addition

     The following code was added in v4.0.11, and the source code can be clicked here: "Comprehensive guide to build a new version of QGC ground station environment under win10 (v4.0.x QGroundControl ground station build)"

● Modification 1:

     Add GaodeSatMapProvider Gaode map class definition at the end of GenericMapProvider.h.

//D:\gcs\qgc-src\v4.0.11\qgroundcontrol\src\QtLocationPlugin\GenericMapProvider.h:80
class GaodeSatMapProvider : public MapProvider {
    
    
    Q_OBJECT
  public:
    GaodeSatMapProvider(QObject* parent = nullptr)
        : MapProvider(QStringLiteral("webapi.amap.com"), QStringLiteral("jpg"),
                      AVERAGE_TILE_SIZE, QGeoMapType::SatelliteMapDay, parent) {
    
    }
	//"webapi.amap.com" 和 "jpg" 似乎不重要,懂地朋友还请赐教
	
    QString _getURL(const int x, const int y, const int zoom, QNetworkAccessManager* networkManager) override;

  private:
    const QString _versionBingMaps = QStringLiteral("563");
};

● Modification 2:

     Add the _getURL() method at the end of GenericMapProvider.cpp. It is the link to the tile resource, which will be introduced in detail later. This is the most critical step. The key to adding different maps is to add different tile resources.

// src\QtLocationPlugin\GenericMapProvider.cpp:79
QString GaodeSatMapProvider::_getURL(const int x, const int y, const int zoom, QNetworkAccessManager* networkManager) {
    
    
    Q_UNUSED(networkManager)

      return QStringLiteral("http://webst01.is.autonavi.com/appmaptile?style=6&x=%1&y=%2&z=%3").arg(x).arg(y).arg(zoom);   //高德影像 OK
}

● Modification 3:

     Instantiate the map class you created, which can be added at the end of the function. After joining, it has been added to the QGC map source selection list.

// src\QtLocationPlugin\QGCMapUrlEngine.cpp:36
UrlFactory::UrlFactory() : _timeout(5 * 1000) {
    
    
...
    _providersTable["高德 卫星地图"] = new GaodeSatMapProvider(this);
}

3. Tile map online resources

If you want to add other map sources, just copy it after changing the class name in Modification 1 and Modification 3. The key is that you need to change the online resource of different tiles in Modification 2. The following pro-test is valid.

Update year and month: March 2020

3.1 Gaode Map

Reference 1: 2017 version of Gaode map tile analysis

//上文的
return QStringLiteral("http://webst01.is.autonavi.com/appmaptile?style=6&x=%1&y=%2&z=%3").arg(x).arg(y).arg(zoom);
//替换 **修改2** 的瓦片资源:
return QStringLiteral("http://wprd01.is.autonavi.com/appmaptile?x=%1&y=%2&z=%3&lang=zh_cn&size=1&scl=1&style=6").arg(x).arg(y).arg(zoom);   

The former is the new address of AutoNavi, and the latter is the old address. For the former, lang can be set to Chinese through zh_cn, English is set to en, size is basically useless, scl is set to label or base map, scl=1 means annotation, scl=2 means base map (vector or image), style sets image and road network, style=6 is the image map, style=7 is the vector road network, and style=8 is the image road network.

3.2 Sky Map

Reference 2: Tianditu WMTS service and rules

return QStringLiteral("http://t0.tianditu.gov.cn/img_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=img&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX=%1&TILEROW=%2&TILECOL=%3&tk=%4").arg(zoom).arg(y).arg(x).arg(QStringLiteral("3a351e098b778e937c05a85f4bdc2e4e"));   //网页版密钥

t0.tianditu.gov.cn ----- server address {t0 ~ t7}, it is found that t0 is not easy to use, you can define a few more for selection.

The key buddies apply by yourself. The above is the key that I personally applied. Remember to apply for the browser-side key. The link is as follows: https://console.tianditu.gov.cn/api/key

After use, it is found that there will always be a phenomenon of lag, and even cause QGC to crash. When using it, pay attention to it. If there is a solution, you can leave a message to communicate~

Other map sources will be added later when used.


If there are any welcome messages that I did not understand or make mistakes above, I will always be there~

For other articles about QGC ground station, please click here:     QGC ground station

Guess you like

Origin blog.csdn.net/qq_16504163/article/details/113985988