ADS-B: Add mapboxgl support, as osm maps do not work in Qt 5.15.3

pull/1280/head
Jon Beniston 2022-06-06 11:52:29 +01:00
rodzic fb516d1ef1
commit 3a71ba0fb9
7 zmienionych plików z 268 dodań i 199 usunięć

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 32 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 25 KiB

Wyświetl plik

@ -45,7 +45,9 @@ ADSBDemodDisplayDialog::ADSBDemodDisplayDialog(ADSBDemodSettings *settings, QWid
}
}
ui->airspaceRange->setValue(settings->m_airspaceRange);
ui->mapProvider->setCurrentText(settings->m_mapProvider);
ui->mapType->setCurrentIndex((int)settings->m_mapType);
ui->mapBoxAPIKey->setText(settings->m_mapBoxAPIKey);
ui->navAids->setChecked(settings->m_displayNavAids);
ui->photos->setChecked(settings->m_displayPhotos);
ui->verboseModelMatching->setChecked(settings->m_verboseModelMatching);
@ -77,7 +79,9 @@ void ADSBDemodDisplayDialog::accept()
}
}
m_settings->m_airspaceRange = ui->airspaceRange->value();
m_settings->m_mapProvider = ui->mapProvider->currentText();
m_settings->m_mapType = (ADSBDemodSettings::MapType)ui->mapType->currentIndex();
m_settings->m_mapBoxAPIKey = ui->mapBoxAPIKey->text();
m_settings->m_displayNavAids = ui->navAids->isChecked();
m_settings->m_displayPhotos = ui->photos->isChecked();
m_settings->m_verboseModelMatching = ui->verboseModelMatching->isChecked();

Wyświetl plik

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>417</width>
<height>714</height>
<height>742</height>
</rect>
</property>
<property name="font">
@ -22,70 +22,7 @@
<item>
<widget class="QGroupBox" name="groupBox">
<layout class="QGridLayout" name="gridLayout">
<item row="10" column="1">
<widget class="QPushButton" name="font">
<property name="toolTip">
<string>Select a font for the table</string>
</property>
<property name="text">
<string>Select...</string>
</property>
</widget>
</item>
<item row="15" column="0">
<widget class="QLabel" name="verboseModelMatchingLabel">
<property name="text">
<string>Log 3D model matching information</string>
</property>
</widget>
</item>
<item row="13" column="0">
<widget class="QLabel" name="autoResizeTableColumnsLabel">
<property name="text">
<string>Resize columns after adding aircraft</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="units">
<property name="toolTip">
<string>The units to use for altitude, speed and climb rate</string>
</property>
<item>
<property name="text">
<string>ft, kn, ft/min</string>
</property>
</item>
<item>
<property name="text">
<string>m, kph, m/s</string>
</property>
</item>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="airportSize">
<property name="toolTip">
<string>Sets the minimum airport size that will be displayed on the map</string>
</property>
<item>
<property name="text">
<string>Small</string>
</property>
</item>
<item>
<property name="text">
<string>Medium</string>
</property>
</item>
<item>
<property name="text">
<string>Large</string>
</property>
</item>
</widget>
</item>
<item row="18" column="1">
<item row="20" column="1">
<widget class="QSpinBox" name="airfieldElevation">
<property name="toolTip">
<string>Barometric altitude reported by aircraft when on airfield surface</string>
@ -101,42 +38,14 @@
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="airspaceRangeLabel">
<property name="text">
<string>Airspace display distance (km)</string>
</property>
</widget>
</item>
<item row="16" column="1">
<widget class="QLineEdit" name="aviationstackAPIKey">
<property name="toolTip">
<string>aviationstack.com API key for accessing flight information</string>
</property>
</widget>
</item>
<item row="16" column="0">
<widget class="QLabel" name="aviationstackAPIKeyLabel">
<property name="text">
<string>avaitionstack API key</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="unitsLabel">
<property name="text">
<string>Units</string>
</property>
</widget>
</item>
<item row="7" column="0">
<item row="9" column="0">
<widget class="QLabel" name="displayNavAids">
<property name="text">
<string>Display NAVAIDs</string>
</property>
</widget>
</item>
<item row="8" column="1">
<item row="10" column="1">
<widget class="QCheckBox" name="photos">
<property name="toolTip">
<string>Download and display photos of highlighted aircraft</string>
@ -146,23 +55,7 @@
</property>
</widget>
</item>
<item row="14" column="1">
<widget class="QCheckBox" name="displayStats">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Display demodulator statistics</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="13" column="1">
<item row="15" column="1">
<widget class="QCheckBox" name="autoResizeTableColumns">
<property name="toolTip">
<string>Resize the columns in the table after an aircraft is added to it</string>
@ -172,17 +65,7 @@
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QSpinBox" name="airportRange">
<property name="toolTip">
<string>Displays airports within the specified distance in kilometres from My Position</string>
</property>
<property name="maximum">
<number>20000</number>
</property>
</widget>
</item>
<item row="15" column="1">
<item row="17" column="1">
<widget class="QCheckBox" name="verboseModelMatching">
<property name="toolTip">
<string>Log information about how aircraft are matched to 3D models</string>
@ -192,7 +75,7 @@
</property>
</widget>
</item>
<item row="6" column="1">
<item row="8" column="1">
<widget class="QSpinBox" name="airspaceRange">
<property name="toolTip">
<string>Displays airspace within the specified distance in kilometres from My Position</string>
@ -202,14 +85,14 @@
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="mapTypeLabel">
<item row="16" column="0">
<widget class="QLabel" name="displayStatsLabel">
<property name="text">
<string>Map type</string>
<string>Display demodulator statistics</string>
</property>
</widget>
</item>
<item row="7" column="1">
<item row="9" column="1">
<widget class="QCheckBox" name="navAids">
<property name="toolTip">
<string>Display NAVAIDs such as VORs and NDBs</string>
@ -219,38 +102,24 @@
</property>
</widget>
</item>
<item row="14" column="0">
<widget class="QLabel" name="displayStatsLabel">
<item row="2" column="0">
<widget class="QLabel" name="mapTypeLabel">
<property name="text">
<string>Display demodulator statistics</string>
<string>Map type</string>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QLabel" name="fontLabel">
<property name="text">
<string>Table font</string>
</property>
</widget>
</item>
<item row="4" column="0">
<item row="6" column="0">
<widget class="QLabel" name="airportRangeLabel">
<property name="text">
<string>Airport display distance (km)</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="photosLabel">
<property name="text">
<string>Display aircraft photos</string>
</property>
</widget>
</item>
<item row="1" column="1">
<item row="2" column="1">
<widget class="QComboBox" name="mapType">
<property name="toolTip">
<string>Type of map to display</string>
<string>Type of map to display (for osm maps)</string>
</property>
<item>
<property name="text">
@ -274,7 +143,200 @@
</item>
</widget>
</item>
<item row="5" column="1">
<item row="4" column="0">
<widget class="QLabel" name="airportSizeLabel">
<property name="text">
<string>Display airports with size</string>
</property>
</widget>
</item>
<item row="11" column="0">
<widget class="QLabel" name="timeoutLabel">
<property name="text">
<string>Aircraft timeout (s)</string>
</property>
</widget>
</item>
<item row="19" column="0">
<widget class="QLabel" name="checkWXAPIKeyLabel">
<property name="text">
<string>CheckWX API key</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="heliportsLabel">
<property name="text">
<string>Display heliports</string>
</property>
</widget>
</item>
<item row="11" column="1">
<widget class="QSpinBox" name="timeout">
<property name="toolTip">
<string>How long in seconds after not receiving any frames will an aircraft be removed from the table and map</string>
</property>
<property name="maximum">
<number>1000000</number>
</property>
</widget>
</item>
<item row="12" column="1">
<widget class="QPushButton" name="font">
<property name="toolTip">
<string>Select a font for the table</string>
</property>
<property name="text">
<string>Select...</string>
</property>
</widget>
</item>
<item row="17" column="0">
<widget class="QLabel" name="verboseModelMatchingLabel">
<property name="text">
<string>Log 3D model matching information</string>
</property>
</widget>
</item>
<item row="15" column="0">
<widget class="QLabel" name="autoResizeTableColumnsLabel">
<property name="text">
<string>Resize columns after adding aircraft</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="units">
<property name="toolTip">
<string>The units to use for altitude, speed and climb rate</string>
</property>
<item>
<property name="text">
<string>ft, kn, ft/min</string>
</property>
</item>
<item>
<property name="text">
<string>m, kph, m/s</string>
</property>
</item>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="airportSize">
<property name="toolTip">
<string>Sets the minimum airport size that will be displayed on the map</string>
</property>
<item>
<property name="text">
<string>Small</string>
</property>
</item>
<item>
<property name="text">
<string>Medium</string>
</property>
</item>
<item>
<property name="text">
<string>Large</string>
</property>
</item>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="mapProvider">
<property name="toolTip">
<string>Mapping service</string>
</property>
<item>
<property name="text">
<string>osm</string>
</property>
</item>
<item>
<property name="text">
<string>mapboxgl</string>
</property>
</item>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="airspaceRangeLabel">
<property name="text">
<string>Airspace display distance (km)</string>
</property>
</widget>
</item>
<item row="18" column="1">
<widget class="QLineEdit" name="aviationstackAPIKey">
<property name="toolTip">
<string>aviationstack.com API key for accessing flight information</string>
</property>
</widget>
</item>
<item row="18" column="0">
<widget class="QLabel" name="aviationstackAPIKeyLabel">
<property name="text">
<string>avaitionstack API key</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="mapProviderLabel">
<property name="text">
<string>Map provider</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="unitsLabel">
<property name="text">
<string>Units</string>
</property>
</widget>
</item>
<item row="16" column="1">
<widget class="QCheckBox" name="displayStats">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Display demodulator statistics</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QSpinBox" name="airportRange">
<property name="toolTip">
<string>Displays airports within the specified distance in kilometres from My Position</string>
</property>
<property name="maximum">
<number>20000</number>
</property>
</widget>
</item>
<item row="12" column="0">
<widget class="QLabel" name="fontLabel">
<property name="text">
<string>Table font</string>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QLabel" name="photosLabel">
<property name="text">
<string>Display aircraft photos</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QListWidget" name="airspaces">
<property name="toolTip">
<string>Airspace categories to display</string>
@ -431,21 +493,14 @@
</item>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="airportSizeLabel">
<property name="text">
<string>Display airports with size</string>
<item row="19" column="1">
<widget class="QLineEdit" name="checkWXAPIKey">
<property name="toolTip">
<string>checkwxapi.com API key for accessing airport weather (METARs)</string>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="timeoutLabel">
<property name="text">
<string>Aircraft timeout (s)</string>
</property>
</widget>
</item>
<item row="3" column="1">
<item row="5" column="1">
<widget class="QCheckBox" name="heliports">
<property name="toolTip">
<string>When checked, heliports are displayed on the map</string>
@ -455,48 +510,31 @@
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="heliportsLabel">
<property name="text">
<string>Display heliports</string>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QSpinBox" name="timeout">
<property name="toolTip">
<string>How long in seconds after not receiving any frames will an aircraft be removed from the table and map</string>
</property>
<property name="maximum">
<number>1000000</number>
</property>
</widget>
</item>
<item row="18" column="0">
<item row="20" column="0">
<widget class="QLabel" name="airfieldElevationLabel">
<property name="text">
<string>Airfield barometric altitude (ft)</string>
</property>
</widget>
</item>
<item row="5" column="0">
<item row="7" column="0">
<widget class="QLabel" name="airspacesLabel">
<property name="text">
<string>Airspaces to display</string>
</property>
</widget>
</item>
<item row="17" column="0">
<widget class="QLabel" name="checkWXAPIKeyLabel">
<item row="3" column="0">
<widget class="QLabel" name="mapBoxAPIKeyLabel">
<property name="text">
<string>CheckWX API key</string>
<string>Mapbox API key</string>
</property>
</widget>
</item>
<item row="17" column="1">
<widget class="QLineEdit" name="checkWXAPIKey">
<item row="3" column="1">
<widget class="QLineEdit" name="mapBoxAPIKey">
<property name="toolTip">
<string>checkwxapi.com API key for accessing airport weather (METARs)</string>
<string>mapbox.com API key for mapboxgl maps</string>
</property>
</widget>
</item>
@ -517,7 +555,9 @@
</widget>
<tabstops>
<tabstop>units</tabstop>
<tabstop>mapProvider</tabstop>
<tabstop>mapType</tabstop>
<tabstop>mapBoxAPIKey</tabstop>
<tabstop>airportSize</tabstop>
<tabstop>heliports</tabstop>
<tabstop>airportRange</tabstop>

Wyświetl plik

@ -3624,20 +3624,27 @@ void ADSBDemodGUI::applyMapSettings()
}
// Create the map using the specified provider
QQmlProperty::write(item, "mapProvider", "osm");
QQmlProperty::write(item, "mapProvider", m_settings.m_mapProvider);
QVariantMap parameters;
// Use our repo, so we can append API key and redefine transmit maps
parameters["osm.mapping.providersrepository.address"] = QString("http://127.0.0.1:%1/").arg(m_osmPort);
// Use ADS-B specific cache, as we use different transmit maps
QString cachePath = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) + "/QtLocation/5.8/tiles/osm/sdrangel_adsb";
parameters["osm.mapping.cache.directory"] = cachePath;
// On Linux, we need to create the directory
QDir dir(cachePath);
if (!dir.exists()) {
dir.mkpath(cachePath);
if (m_settings.m_mapProvider == "osm")
{
// Use our repo, so we can append API key and redefine transmit maps
parameters["osm.mapping.providersrepository.address"] = QString("http://127.0.0.1:%1/").arg(m_osmPort);
// Use ADS-B specific cache, as we use different transmit maps
QString cachePath = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) + "/QtLocation/5.8/tiles/osm/sdrangel_adsb";
parameters["osm.mapping.cache.directory"] = cachePath;
// On Linux, we need to create the directory
QDir dir(cachePath);
if (!dir.exists()) {
dir.mkpath(cachePath);
}
}
else if (m_settings.m_mapProvider == "mapboxgl")
{
parameters["mapboxgl.access_token"] = m_settings.m_mapBoxAPIKey;
}
QString mapType;
QString mapType; // Only for osm maps
switch (m_settings.m_mapType)
{
case ADSBDemodSettings::AVIATION_LIGHT:

Wyświetl plik

@ -92,7 +92,13 @@ void ADSBDemodSettings::resetToDefaults()
m_logEnabled = false;
m_airspaces = QStringList({"A", "D", "TMZ"});
m_airspaceRange = 500.0f;
#if QT_VERSION == QT_VERSION_CHECK(5, 15, 3)
m_mapProvider = "mapboxgl"; // osm maps do not work in Qt 5.15.3 - https://github.com/f4exb/sdrangel/issues/1169
#else
m_mapProvider = "osm";
#endif
m_mapType = AVIATION_LIGHT;
m_mapBoxAPIKey = "";
m_displayNavAids = true;
m_displayPhotos = true;
m_verboseModelMatching = false;
@ -179,6 +185,8 @@ QByteArray ADSBDemodSettings::serialize() const
s.writeBlob(60, m_geometryBytes);
s.writeBool(61, m_hidden);
s.writeString(62, m_checkWXAPIKey);
s.writeString(63, m_mapProvider);
s.writeString(64, m_mapBoxAPIKey);
for (int i = 0; i < ADSBDEMOD_COLUMNS; i++) {
s.writeS32(100 + i, m_columnIndexes[i]);
@ -309,6 +317,12 @@ bool ADSBDemodSettings::deserialize(const QByteArray& data)
d.readBlob(60, &m_geometryBytes);
d.readBool(61, &m_hidden, false);
d.readString(62, &m_checkWXAPIKey, "");
#if QT_VERSION == QT_VERSION_CHECK(5, 15, 3)
d.readString(63, &m_mapProvider, "mapboxgl"); // osm maps do not work in Qt 5.15.3 - https://github.com/f4exb/sdrangel/issues/1169
#else
d.readString(63, &m_mapProvider, "osm");
#endif
d.readString(64, &m_mapBoxAPIKey, "");
for (int i = 0; i < ADSBDEMOD_COLUMNS; i++) {
d.readS32(100 + i, &m_columnIndexes[i], i);

Wyświetl plik

@ -155,12 +155,14 @@ struct ADSBDemodSettings
QStringList m_airspaces; //!< Airspace names to display
float m_airspaceRange; //!< How far away we display airspace (mkm)
QString m_mapProvider;
enum MapType {
AVIATION_LIGHT, //!< White map with no place names
AVIATION_DARK,
STREET,
SATELLITE
} m_mapType;
} m_mapType; //!< For osm maps
QString m_mapBoxAPIKey;
bool m_displayNavAids;
bool m_displayPhotos;
Serializable *m_rollupState;

Wyświetl plik

@ -75,7 +75,9 @@ Clicking this will download the [OpenAIP](https://www.openaip.net/) airspace and
Clicking the Display Settings button will open the Display Settings dialog, which allows you to choose:
* The units for altitude, speed and vertical climb rate. These can be either ft (feet), kn (knots) and ft/min (feet per minute), or m (metres), kph (kilometers per hour) and m/s (metres per second).
* The type of map that will be displayed. This can either be a light or dark aviation map (with no place names to reduce clutter), a street map or satellite imagery.
* The map provider. This can be osm for OpenStreetMaps or mapboxgl for Mabbox. mapboxgl is not supported on Windows. mapboxgl should be used on Linux with Qt 5.15.3, as osm maps will cause SDRangel to hang with this specific version of Qt.
* The type of map that will be displayed, when the map provider is osm. This can either be a light or dark aviation map (with no place names to reduce clutter), a street map or satellite imagery.
* A [Mapbox](https://www.mapbox.com/) API key, as required to use mapboxgl map provider.
* The minimum size airport that will be displayed on the map: small, medium or large. Use small to display GA airfields, medium for regional airports and large for international airports.
* Whether or not to display heliports.
* The distance (in kilometres), from the location set under Preferences > My Position, at which airports will be displayed on the map. Displaying too many airports will slow down drawing of the map.