refs #484 Revise XBus airports-in-range code using CNavDataReferenceList.

This commit is contained in:
Mathew Sutcliffe
2015-10-19 23:31:25 +01:00
parent ca18f98c43
commit 777a371569
3 changed files with 7 additions and 21 deletions

View File

@@ -332,11 +332,8 @@ namespace BlackSimPlugin
BlackMisc::Aviation::CAirportList CSimulatorXPlane::getAirportsInRange() const
{
auto copy = m_airportsInRange;
//! \todo XP driver: Check if units match, xPlaneData has now hints what the values are
copy.sortByRange(CCoordinateGeodetic(m_xplaneData.latitude, m_xplaneData.longitude, 0), true);
copy.truncate(20);
return copy;
return m_airportsInRange;
}
bool CSimulatorXPlane::setTimeSynchronization(bool enable, const BlackMisc::PhysicalQuantities::CTime &offset)

View File

@@ -112,22 +112,10 @@ namespace XBus
if (icao[0] != 0)
{
using namespace BlackMisc::Math;
m_airports.insert(CMathUtils::deg2rad(lat), CMathUtils::deg2rad(lon), i);
m_airports.push_back(BlackMisc::Simulation::XPlane::CNavDataReference(i, lat, lon));
}
}
}
int total = 0, count = 0, max = 0;
for (auto key : m_airports.keys())
{
qDebug() << "<><><><>" << QString("%1").arg(key, 6, 16, QChar('0')) << m_airports.count(key);
total += m_airports.count(key);
count++;
if (m_airports.count(key) > max) { max = m_airports.count(key); }
}
qDebug() << "<><><><> total" << total;
qDebug() << "<><><><> max" << max;
qDebug() << "<><><><> mean" << (total / count);
}
void CService::updateAirportsInRange()
@@ -137,13 +125,14 @@ namespace XBus
readAirportsDatabase();
}
using namespace BlackMisc::Math;
using namespace BlackMisc::Geo;
QStringList icaos, names;
QDoubleList lats, lons, alts;
for (auto navref : m_airports.inAdjacentTiles(CMathUtils::deg2rad(getLatitude()), CMathUtils::deg2rad(getLongitude())))
for (const auto &navref : m_airports.findClosest(20, CCoordinateGeodetic(getLatitude(), getLongitude(), 0)))
{
float lat, lon, alt;
char icao[32], name[256];
XPLMGetNavAidInfo(navref, nullptr, &lat, &lon, &alt, nullptr, nullptr, icao, name, nullptr);
XPLMGetNavAidInfo(navref.id(), nullptr, &lat, &lon, &alt, nullptr, nullptr, icao, name, nullptr);
icaos.push_back(icao);
names.push_back(name);
lats.push_back(lat);

View File

@@ -13,7 +13,7 @@
#endif
#include "datarefs.h"
#include "messages.h"
#include "blackmisc/geo/geodesicgrid.h"
#include "blackmisc/simulation/xplane/navdatareference.h"
#include <XPLM/XPLMNavigation.h>
#include <QStringList>
#include <QObject>
@@ -222,7 +222,7 @@ namespace XBus
private:
CMessageBoxControl m_messages;
BlackMisc::Geo::CGeodesicGrid<128, XPLMNavRef> m_airports;
BlackMisc::Simulation::XPlane::CNavDataReferenceList m_airports;
QTimer *m_airportUpdater = nullptr;
void readAirportsDatabase();