mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-15 01:05:35 +08:00
refs #23, anticipating aircraft ICAO code from VATSIM data file
* helper methods * renamed methods
This commit is contained in:
@@ -26,6 +26,14 @@ namespace BlackCore
|
||||
{
|
||||
// update
|
||||
CIndexVariantMap vm(CAircraft::IndexIcao, icaoData.toQVariant());
|
||||
if (!icaoData.hasAircraftDesignator())
|
||||
{
|
||||
// empty so far, try to fetch from data file
|
||||
qDebug() << "Empty ICAO info for " << callsign << icaoData;
|
||||
CAircraftIcao icaoDataDataFile = this->m_vatsimDataFileReader->getIcaoInfo(callsign);
|
||||
if (!icaoDataDataFile.hasAircraftDesignator()) return; // give up!
|
||||
vm = CIndexVariantMap(CAircraft::IndexIcao, icaoData.toQVariant());
|
||||
}
|
||||
this->m_aircraftsInRange.applyIf(BlackMisc::Predicates::MemberEqual<CAircraft>(&CAircraft::getCallsign, callsign), vm);
|
||||
emit this->changedAircraftsInRange();
|
||||
}
|
||||
|
||||
@@ -70,6 +70,7 @@ namespace BlackCore
|
||||
foreach(CAircraft aircraft, this->m_aircraftsInRange)
|
||||
{
|
||||
this->m_network->sendFrequencyQuery(aircraft.getCallsign());
|
||||
this->m_network->sendIcaoCodesQuery(aircraft.getCallsign());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
#include "blackmisc/nwserver.h"
|
||||
#include "vatsimdatafilereader.h"
|
||||
|
||||
#include <QRegularExpression>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Aviation;
|
||||
using namespace BlackMisc::Network;
|
||||
@@ -62,6 +64,12 @@ namespace BlackCore
|
||||
return this->getPilotsForCallsigns(callsigns);
|
||||
}
|
||||
|
||||
CAircraftIcao CVatsimDataFileReader::getIcaoInfo(const CCallsign &callsign)
|
||||
{
|
||||
CAircraft aircraft = this->m_aircrafts.findFirstByCallsign(callsign);
|
||||
return aircraft.getIcaoInfo();
|
||||
}
|
||||
|
||||
CUserList CVatsimDataFileReader::getControllersForCallsign(const CCallsign &callsign)
|
||||
{
|
||||
CCallsignList callsigns;
|
||||
@@ -176,6 +184,25 @@ namespace BlackCore
|
||||
CAircraftSituation situation(position, altitude);
|
||||
situation.setGroundspeed(CSpeed(groundspeed, CSpeedUnit::kts()));
|
||||
CAircraft aircraft(user.getCallsign().getStringAsSet(), user, situation);
|
||||
|
||||
QString icaoCode = clientPartsMap["planned_aircraft"];
|
||||
if (!icaoCode.isEmpty())
|
||||
{
|
||||
// http://uk.flightaware.com/about/faq_aircraft_flight_plan_suffix.rvt
|
||||
// we expect something like H/B772/F B773 B773/F
|
||||
static const QRegularExpression reg("/.");
|
||||
icaoCode = icaoCode.replace(reg, "").trimmed().toUpper();
|
||||
if (CAircraftIcao::isValidDesignator(icaoCode))
|
||||
{
|
||||
aircraft.setIcaoInfo(CAircraftIcao(icaoCode));
|
||||
}
|
||||
else
|
||||
{
|
||||
const QString w = QString("Illegal ICAO code in VATSIM data file: %1").arg(icaoCode);
|
||||
qWarning(w.toLatin1());
|
||||
}
|
||||
}
|
||||
|
||||
this->m_aircrafts.push_back(aircraft);
|
||||
}
|
||||
else if (clientType.startsWith('a'))
|
||||
|
||||
@@ -71,6 +71,9 @@ namespace BlackCore
|
||||
//! Users for callsign
|
||||
BlackMisc::Network::CUserList getPilotsForCallsign(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
|
||||
//! ICAO info for callsign
|
||||
BlackMisc::Aviation::CAircraftIcao getIcaoInfo(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
|
||||
private slots:
|
||||
//! Data have been read
|
||||
void loadFinished(QNetworkReply *nwReply);
|
||||
|
||||
Reference in New Issue
Block a user