Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/QmlControls/OfflineMapEditor.qml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ FlightMap {
property var _settings: _settingsManager ? _settingsManager.offlineMapsSettings : null
property var _fmSettings: _settingsManager ? _settingsManager.flightMapSettings : null
property var _appSettings: _settingsManager.appSettings
property Fact _tiandituFact: _settingsManager ? _settingsManager.appSettings.tiandituToken : null
property Fact _mapboxFact: _settingsManager ? _settingsManager.appSettings.mapboxToken : null
property Fact _mapboxAccountFact: _settingsManager ? _settingsManager.appSettings.mapboxAccount : null
property Fact _mapboxStyleFact: _settingsManager ? _settingsManager.appSettings.mapboxStyle : null
Expand Down
2 changes: 2 additions & 0 deletions src/QtLocationPlugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ qt_add_plugin(QGCLocation
Providers/MapboxMapProvider.h
Providers/MapProvider.cpp
Providers/MapProvider.h
Providers/TianDiTuProvider.cpp
Providers/TianDiTuProvider.h
QGCCachedTileSet.cpp
QGCCachedTileSet.h
QGCCacheTile.h
Expand Down
29 changes: 29 additions & 0 deletions src/QtLocationPlugin/Providers/TianDiTuProvider.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/****************************************************************************
*
* (c) 2009-2024 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.
*
****************************************************************************/

#include "TianDiTuProvider.h"
#include "SettingsManager.h"
#include "AppSettings.h"

QString TianDiTuProvider::_getURL(int x, int y, int zoom) const
{
//"https://t%1.tianditu.gov.cn/DataServer?tk=%2&T=%3&x=%4&y=%5&l=%6"
const QString tiandituToken = SettingsManager::instance()->appSettings()->tiandituToken()->rawValue().toString();
if (!tiandituToken.isEmpty()) {
return _mapUrl
.arg(_getServerNum(x, y, 8))
.arg(tiandituToken)
.arg(_mapType)
.arg(x)
.arg(y)
.arg(zoom)
;
}
return QString();
}
55 changes: 55 additions & 0 deletions src/QtLocationPlugin/Providers/TianDiTuProvider.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/****************************************************************************
*
* (c) 2009-2024 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.
*
****************************************************************************/

#pragma once

#include "MapProvider.h"

static constexpr const quint32 AVERAGE_TIANDITU_STREET_MAP = 1297;
static constexpr const quint32 AVERAGE_TIANDITU_SAT_MAP = 19597;

class TianDiTuProvider : public MapProvider
{
protected:
TianDiTuProvider(const QString &mapName, const QString &mapTypeCode, const QString &imageFormat, quint32 averageSize,
QGeoMapType::MapStyle mapType)
: MapProvider(mapName, QStringLiteral("https://map.tianditu.gov.cn/"), imageFormat, averageSize, mapType)
, _mapType(mapTypeCode) {}

private:
QString _getURL(int x, int y, int zoom) const final;

const QString _mapType;
const QString _mapUrl = QStringLiteral("https://t%1.tianditu.gov.cn/DataServer?tk=%2&T=%3&x=%4&y=%5&l=%6");
};

class TianDiTuRoadProvider : public TianDiTuProvider
{
public:
TianDiTuRoadProvider()
: TianDiTuProvider(
QObject::tr("TianDiTu Road"),
QStringLiteral("cia_w"),
Copy link

Copilot AI Oct 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The map type code for the road map uses 'cia_w', which is the annotations/labels layer in TianDiTu, not the base road tiles. Use 'vec_w' for the street/vector base layer so the Road provider returns actual base map tiles.

Suggested change
QStringLiteral("cia_w"),
QStringLiteral("vec_w"),

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

according the http://lbs.tianditu.gov.cn/server/MapService.html ,
vec_w is 矢量底图(Vector base map), there is no streat name in it.
cia_w is 影像注记(Image annotation), there is streat name in it.

I don't know much about map development, but we want the road with streat name.
example: use cia_w , and change 'Road' to a more suitable Provider type, is there any suggestion for it?

QStringLiteral("png"),
AVERAGE_TIANDITU_STREET_MAP,
QGeoMapType::StreetMap) {}
};

class TianDiTuSatelliteProvider : public TianDiTuProvider
{
public:
TianDiTuSatelliteProvider()
: TianDiTuProvider(
QObject::tr("TianDiTu Satellite"),
QStringLiteral("img_w"),
QStringLiteral("jpg"),
AVERAGE_TIANDITU_SAT_MAP,
QGeoMapType::SatelliteMapDay) {}
};

3 changes: 3 additions & 0 deletions src/QtLocationPlugin/QGCMapUrlEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "GenericMapProvider.h"
#include "GoogleMapProvider.h"
#include "MapboxMapProvider.h"
#include "TianDiTuProvider.h"
#include "QGCLoggingCategory.h"

QGC_LOGGING_CATEGORY(QGCMapUrlEngineLog, "qgc.qtlocationplugin.qgcmapurlengine")
Expand All @@ -33,6 +34,8 @@ const QList<SharedMapProvider> UrlFactory::_providers = {
std::make_shared<BingSatelliteMapProvider>(),
std::make_shared<BingHybridMapProvider>(),

std::make_shared<TianDiTuRoadProvider>(),
std::make_shared<TianDiTuSatelliteProvider>(),
std::make_shared<StatkartTopoMapProvider>(),
std::make_shared<StatkartBaseMapProvider>(),
std::make_shared<SvalbardMapProvider>(),
Expand Down
7 changes: 7 additions & 0 deletions src/Settings/App.SettingsGroup.json
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,13 @@
"default": false,
"qgcRebootRequired": true
},
{
"name": "tiandituToken",
"shortDesc": "Access token to TianDiTu maps",
"longDesc": "Your personal access token for TianDiTu maps",
"type": "string",
"default": ""
},
{
"name": "mapboxToken",
"shortDesc": "Access token to Mapbox maps",
Expand Down
1 change: 1 addition & 0 deletions src/Settings/AppSettings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ DECLARE_SETTINGSFACT(AppSettings, androidSaveToSDCard)
DECLARE_SETTINGSFACT(AppSettings, useChecklist)
DECLARE_SETTINGSFACT(AppSettings, enforceChecklist)
DECLARE_SETTINGSFACT(AppSettings, enableMultiVehiclePanel)
DECLARE_SETTINGSFACT(AppSettings, tiandituToken)
DECLARE_SETTINGSFACT(AppSettings, mapboxToken)
DECLARE_SETTINGSFACT(AppSettings, mapboxAccount)
DECLARE_SETTINGSFACT(AppSettings, mapboxStyle)
Expand Down
1 change: 1 addition & 0 deletions src/Settings/AppSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class AppSettings : public SettingsGroup
DEFINE_SETTINGFACT(useChecklist)
DEFINE_SETTINGFACT(enforceChecklist)
DEFINE_SETTINGFACT(enableMultiVehiclePanel)
DEFINE_SETTINGFACT(tiandituToken)
DEFINE_SETTINGFACT(mapboxToken)
DEFINE_SETTINGFACT(mapboxAccount)
DEFINE_SETTINGFACT(mapboxStyle)
Expand Down
7 changes: 7 additions & 0 deletions src/UI/AppSettings/MapSettings.qml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Item {
property Fact _mapProviderFact: _settingsManager.flightMapSettings.mapProvider
property Fact _mapTypeFact: _settingsManager.flightMapSettings.mapType
property Fact _elevationProviderFact: _settingsManager.flightMapSettings.elevationMapProvider
property Fact _tiandituFac: _settingsManager ? _settingsManager.appSettings.tiandituToken : null
property Fact _mapboxFact: _settingsManager ? _settingsManager.appSettings.mapboxToken : null
property Fact _mapboxAccountFact: _settingsManager ? _settingsManager.appSettings.mapboxAccount : null
property Fact _mapboxStyleFact: _settingsManager ? _settingsManager.appSettings.mapboxStyle : null
Expand Down Expand Up @@ -164,6 +165,12 @@ Item {
heading: qsTr("Tokens")
headingDescription: qsTr("Allows access to additional providers")

LabelledFactTextField {
textFieldPreferredWidth: _largeTextFieldWidth
label: qsTr("TianDiTu")
fact: _appSettings.tiandituToken
}

LabelledFactTextField {
textFieldPreferredWidth: _largeTextFieldWidth
label: qsTr("Mapbox")
Expand Down
Loading