mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-20 12:35:43 +08:00
Ref T129, created CFlightPlanRemarks as value object and removed flight plan utils
* CFlightPlanRemarks supports the functionality of utils, but is also a valid value object * deleted CFlightPlanUtils .h/.cpp * CFlightPlan uses CFlightPlanRemarks * changed classes like VATSIM data reader to use CFlightPlanRemarks (instead of utils)
This commit is contained in:
committed by
Mathew Sutcliffe
parent
27281e438d
commit
3c24d5c7f9
@@ -22,7 +22,6 @@
|
|||||||
#include "blackmisc/aviation/comsystem.h"
|
#include "blackmisc/aviation/comsystem.h"
|
||||||
#include "blackmisc/aviation/modulator.h"
|
#include "blackmisc/aviation/modulator.h"
|
||||||
#include "blackmisc/aviation/transponder.h"
|
#include "blackmisc/aviation/transponder.h"
|
||||||
#include "blackmisc/aviation/flightplanutils.h"
|
|
||||||
#include "blackmisc/geo/elevationplane.h"
|
#include "blackmisc/geo/elevationplane.h"
|
||||||
#include "blackmisc/network/user.h"
|
#include "blackmisc/network/user.h"
|
||||||
#include "blackmisc/network/voicecapabilities.h"
|
#include "blackmisc/network/voicecapabilities.h"
|
||||||
@@ -923,17 +922,17 @@ namespace BlackCore
|
|||||||
CAirlineIcaoCode airlineIcao(airlineIcaoString);
|
CAirlineIcaoCode airlineIcao(airlineIcaoString);
|
||||||
if (!fpRemarks.isEmpty())
|
if (!fpRemarks.isEmpty())
|
||||||
{
|
{
|
||||||
const CFlightPlanUtils::FlightPlanRemarks ar = CFlightPlanUtils::parseFlightPlanRemarks(fpRemarks);
|
const CFlightPlanRemarks ar(fpRemarks);
|
||||||
if (ar.hasAirlineRemarks())
|
if (ar.hasParsedAirlineRemarks())
|
||||||
{
|
{
|
||||||
const QString airlineName = CAircraftMatcher::reverseLookupAirlineName(ar.flightOperator, callsign, log);
|
const QString airlineName = CAircraftMatcher::reverseLookupAirlineName(ar.getFlightOperator(), callsign, log);
|
||||||
if (!airlineName.isEmpty())
|
if (!airlineName.isEmpty())
|
||||||
{
|
{
|
||||||
airlineIcao.setName(airlineName);
|
airlineIcao.setName(airlineName);
|
||||||
this->addReverseLookupMessage(callsign, QString("Setting airline name '%1'").arg(airlineName));
|
this->addReverseLookupMessage(callsign, QString("Setting airline name '%1'").arg(airlineName));
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString telephony = CAircraftMatcher::reverseLookupTelephonyDesignator(ar.radioTelephony, callsign, log);
|
const QString telephony = CAircraftMatcher::reverseLookupTelephonyDesignator(ar.getRadioTelephony(), callsign, log);
|
||||||
if (!telephony.isEmpty())
|
if (!telephony.isEmpty())
|
||||||
{
|
{
|
||||||
airlineIcao.setTelephonyDesignator(telephony);
|
airlineIcao.setTelephonyDesignator(telephony);
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
#include "blackmisc/aviation/aircraftsituation.h"
|
#include "blackmisc/aviation/aircraftsituation.h"
|
||||||
#include "blackmisc/aviation/altitude.h"
|
#include "blackmisc/aviation/altitude.h"
|
||||||
#include "blackmisc/aviation/atcstation.h"
|
#include "blackmisc/aviation/atcstation.h"
|
||||||
#include "blackmisc/aviation/flightplanutils.h"
|
|
||||||
#include "blackmisc/geo/coordinategeodetic.h"
|
#include "blackmisc/geo/coordinategeodetic.h"
|
||||||
#include "blackmisc/network/entityflags.h"
|
#include "blackmisc/network/entityflags.h"
|
||||||
#include "blackmisc/network/server.h"
|
#include "blackmisc/network/server.h"
|
||||||
@@ -135,12 +134,12 @@ namespace BlackCore
|
|||||||
return m_flightPlanRemarks.value(callsign);
|
return m_flightPlanRemarks.value(callsign);
|
||||||
}
|
}
|
||||||
|
|
||||||
CFlightPlanUtils::FlightPlanRemarks CVatsimDataFileReader::getParsedFlightPlanRemarksForCallsign(const CCallsign &callsign) const
|
CFlightPlanRemarks CVatsimDataFileReader::getParsedFlightPlanRemarksForCallsign(const CCallsign &callsign) const
|
||||||
{
|
{
|
||||||
if (callsign.isEmpty()) return CFlightPlanUtils::parseFlightPlanRemarks("");
|
if (callsign.isEmpty()) { return CFlightPlanRemarks(); }
|
||||||
const QString remarks = this->getFlightPlanRemarksForCallsign(callsign);
|
const QString remarks = this->getFlightPlanRemarksForCallsign(callsign);
|
||||||
const CVoiceCapabilities vc = this->getVoiceCapabilityForCallsign(callsign);
|
const CVoiceCapabilities vc = this->getVoiceCapabilityForCallsign(callsign);
|
||||||
return CFlightPlanUtils::parseFlightPlanRemarks(remarks, vc);
|
return CFlightPlanRemarks(remarks, vc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CVatsimDataFileReader::updateWithVatsimDataFileData(CSimulatedAircraft &aircraftToBeUdpated) const
|
void CVatsimDataFileReader::updateWithVatsimDataFileData(CSimulatedAircraft &aircraftToBeUdpated) const
|
||||||
@@ -318,7 +317,7 @@ namespace BlackCore
|
|||||||
const QString equipmentCodeAndAircraft = clientPartsMap["planned_aircraft"].trimmed();
|
const QString equipmentCodeAndAircraft = clientPartsMap["planned_aircraft"].trimmed();
|
||||||
if (!equipmentCodeAndAircraft.isEmpty())
|
if (!equipmentCodeAndAircraft.isEmpty())
|
||||||
{
|
{
|
||||||
const QString aircraftIcaoCode = CFlightPlanUtils::aircraftIcaoCodeFromEquipmentCode(equipmentCodeAndAircraft);
|
const QString aircraftIcaoCode = CFlightPlanRemarks::aircraftIcaoCodeFromEquipmentCode(equipmentCodeAndAircraft);
|
||||||
if (CAircraftIcaoCode::isValidDesignator(aircraftIcaoCode))
|
if (CAircraftIcaoCode::isValidDesignator(aircraftIcaoCode))
|
||||||
{
|
{
|
||||||
currentAircraft.setAircraftIcaoDesignator(aircraftIcaoCode);
|
currentAircraft.setAircraftIcaoDesignator(aircraftIcaoCode);
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
#include "blackmisc/aviation/airlineicaocode.h"
|
#include "blackmisc/aviation/airlineicaocode.h"
|
||||||
#include "blackmisc/aviation/atcstationlist.h"
|
#include "blackmisc/aviation/atcstationlist.h"
|
||||||
#include "blackmisc/aviation/callsignset.h"
|
#include "blackmisc/aviation/callsignset.h"
|
||||||
#include "blackmisc/aviation/flightplanutils.h"
|
#include "blackmisc/aviation/flightplan.h"
|
||||||
#include "blackmisc/network/entityflags.h"
|
#include "blackmisc/network/entityflags.h"
|
||||||
#include "blackmisc/network/serverlist.h"
|
#include "blackmisc/network/serverlist.h"
|
||||||
#include "blackmisc/network/userlist.h"
|
#include "blackmisc/network/userlist.h"
|
||||||
@@ -115,7 +115,7 @@ namespace BlackCore
|
|||||||
|
|
||||||
//! Parsed flight plan remarks for callsign
|
//! Parsed flight plan remarks for callsign
|
||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
BlackMisc::Aviation::CFlightPlanUtils::FlightPlanRemarks getParsedFlightPlanRemarksForCallsign(const BlackMisc::Aviation::CCallsign &callsign) const;
|
BlackMisc::Aviation::CFlightPlanRemarks getParsedFlightPlanRemarksForCallsign(const BlackMisc::Aviation::CCallsign &callsign) const;
|
||||||
|
|
||||||
//! Update aircraft with VATSIM aircraft data from data file
|
//! Update aircraft with VATSIM aircraft data from data file
|
||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
|
|||||||
@@ -8,15 +8,108 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "flightplan.h"
|
#include "flightplan.h"
|
||||||
#include "flightplanutils.h"
|
#include "airlineicaocode.h"
|
||||||
|
#include "flightplan.h"
|
||||||
|
#include "selcal.h"
|
||||||
#include "blackmisc/iconlist.h"
|
#include "blackmisc/iconlist.h"
|
||||||
#include "blackmisc/icons.h"
|
#include "blackmisc/icons.h"
|
||||||
#include <QStringBuilder>
|
#include <QStringBuilder>
|
||||||
|
#include <QRegularExpression>
|
||||||
|
|
||||||
|
using namespace BlackMisc::Network;
|
||||||
|
|
||||||
namespace BlackMisc
|
namespace BlackMisc
|
||||||
{
|
{
|
||||||
namespace Aviation
|
namespace Aviation
|
||||||
{
|
{
|
||||||
|
CFlightPlanRemarks::CFlightPlanRemarks()
|
||||||
|
{ }
|
||||||
|
|
||||||
|
CFlightPlanRemarks::CFlightPlanRemarks(const QString &remarks, bool parse) : m_remarks(remarks)
|
||||||
|
{
|
||||||
|
if (parse) { this->parseFlightPlanRemarks(); }
|
||||||
|
m_isNull = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
CFlightPlanRemarks::CFlightPlanRemarks(const QString &remarks, CVoiceCapabilities voiceCapabilities, bool parse) :
|
||||||
|
m_remarks(remarks), m_voiceCapabilities(voiceCapabilities)
|
||||||
|
{
|
||||||
|
if (parse) { this->parseFlightPlanRemarks(); }
|
||||||
|
m_isNull = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CFlightPlanRemarks::hasAnyParsedRemarks() const
|
||||||
|
{
|
||||||
|
return this->hasParsedAirlineRemarks() || !m_selcalCode.isEmpty() || !m_voiceCapabilities.isUnknown();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CFlightPlanRemarks::hasParsedAirlineRemarks() const
|
||||||
|
{
|
||||||
|
return !m_radioTelephony.isEmpty() || !m_flightOperator.isEmpty() || !m_airlineIcao.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString CFlightPlanRemarks::convertToQString(bool i18n) const
|
||||||
|
{
|
||||||
|
const QString s = m_callsign.toQString(i18n)
|
||||||
|
% QLatin1Char(' ') % m_airlineIcao
|
||||||
|
% QLatin1Char(' ') % m_radioTelephony
|
||||||
|
% QLatin1Char(' ') % m_flightOperator
|
||||||
|
% QLatin1Char(' ') % m_selcalCode
|
||||||
|
% QLatin1Char(' ') % m_voiceCapabilities.toQString(i18n);
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CFlightPlanRemarks::parseFlightPlanRemarks()
|
||||||
|
{
|
||||||
|
// examples: VFPS = VATSIM Flightplan Prefile System
|
||||||
|
// 1) RT/KESTREL OPR/MYTRAVEL REG/G-DAJC SEL/FP-ES PER/C NAV/RNP10
|
||||||
|
// 2) OPR/UAL CALLSIGN/UNITED
|
||||||
|
// 3) /v/FPL-VIR9-IS-A346/DEP/S-EGLL/ARR/KJFK/REG/G-VGAS/TCAS RVR/200 OPR/VIRGI
|
||||||
|
|
||||||
|
if (m_isParsed) { return; }
|
||||||
|
m_isParsed = true;
|
||||||
|
if (m_remarks.isEmpty()) { return; }
|
||||||
|
const QString remarks = m_remarks.toUpper();
|
||||||
|
const QString callsign = CCallsign::unifyCallsign(this->cut(remarks, "REG/")); // registration is a callsign
|
||||||
|
if (CCallsign::isValidAircraftCallsign(callsign)) { m_registration = CCallsign(callsign, CCallsign::Aircraft); }
|
||||||
|
m_voiceCapabilities = m_voiceCapabilities.isUnknown() ? CVoiceCapabilities(m_remarks) : m_voiceCapabilities;
|
||||||
|
m_flightOperator = this->cut(r, "OPR/"); // operator, e.g. British airways, sometimes people use ICAO code here
|
||||||
|
const QString selcal = this->cut(r, "SEL/"); // SELCAL
|
||||||
|
if (CSelcal::isValidCode(selcal)) m_selcalCode = selcal;
|
||||||
|
m_radioTelephony = cut(r, "CALLSIGN/"); // used similar to radio telephony
|
||||||
|
if (m_radioTelephony.isEmpty()) { m_radioTelephony = cut(r, "RT/"); }
|
||||||
|
if (!m_flightOperator.isEmpty() && CAirlineIcaoCode::isValidAirlineDesignator(m_flightOperator))
|
||||||
|
{
|
||||||
|
// if people use ICAO as flight operator move to airline ICAO
|
||||||
|
qSwap(m_flightOperator, m_airlineIcao);
|
||||||
|
}
|
||||||
|
m_isNull = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString CFlightPlanRemarks::aircraftIcaoCodeFromEquipmentCode(const QString &equipmentCodeAndAircraft)
|
||||||
|
{
|
||||||
|
// http://uk.flightaware.com/about/faq_aircraft_flight_plan_suffix.rvt
|
||||||
|
// we expect something like H/B772/F B773 B773/F
|
||||||
|
thread_local const QRegularExpression reg("/.");
|
||||||
|
QString aircraftIcaoCode(equipmentCodeAndAircraft);
|
||||||
|
aircraftIcaoCode = aircraftIcaoCode.replace(reg, "").trimmed().toUpper();
|
||||||
|
return aircraftIcaoCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString CFlightPlanRemarks::cut(const QString &remarks, const QString &marker)
|
||||||
|
{
|
||||||
|
const int maxIndex = remarks.size() - 1;
|
||||||
|
int f = remarks.indexOf(marker);
|
||||||
|
if (f < 0) { return ""; }
|
||||||
|
f += marker.length();
|
||||||
|
if (maxIndex <= f) { return ""; }
|
||||||
|
int to = remarks.indexOf(' ', f + 1);
|
||||||
|
if (to < 0) { to = maxIndex; } // no more spaces
|
||||||
|
const QString cut = remarks.mid(f, to - f).replace('/', ' '); // variations like /OPR/EASYJET/
|
||||||
|
// problem is that this cuts something like "Uzbekistan Airways"
|
||||||
|
return cut;
|
||||||
|
}
|
||||||
|
|
||||||
CFlightPlan::CFlightPlan() { }
|
CFlightPlan::CFlightPlan() { }
|
||||||
|
|
||||||
CFlightPlan::CFlightPlan(const CCallsign &callsign, const QString &equipmentIcao, const CAirportIcaoCode &originAirportIcao, const CAirportIcaoCode &destinationAirportIcao,
|
CFlightPlan::CFlightPlan(const CCallsign &callsign, const QString &equipmentIcao, const CAirportIcaoCode &originAirportIcao, const CAirportIcaoCode &destinationAirportIcao,
|
||||||
@@ -43,13 +136,13 @@ namespace BlackMisc
|
|||||||
void CFlightPlan::setEquipmentIcao(const QString &equipmentIcao)
|
void CFlightPlan::setEquipmentIcao(const QString &equipmentIcao)
|
||||||
{
|
{
|
||||||
m_equipmentIcao = equipmentIcao;
|
m_equipmentIcao = equipmentIcao;
|
||||||
const QString aircraftIcao = CFlightPlanUtils::aircraftIcaoCodeFromEquipmentCode(equipmentIcao);
|
const QString aircraftIcao = CFlightPlanRemarks::aircraftIcaoCodeFromEquipmentCode(equipmentIcao);
|
||||||
m_aircraftIcao = CAircraftIcaoCode::isValidDesignator(aircraftIcao) ? aircraftIcao : "";
|
m_aircraftIcao = CAircraftIcaoCode::isValidDesignator(aircraftIcao) ? aircraftIcao : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
CFlightPlanUtils::FlightPlanRemarks CFlightPlan::getParsedRemarks() const
|
void CFlightPlan::setRemarks(const QString &remarks)
|
||||||
{
|
{
|
||||||
return CFlightPlanUtils::parseFlightPlanRemarks(this->getRemarks());
|
m_remarks = CFlightPlanRemarks(remarks, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
CVariant CFlightPlan::propertyByIndex(const CPropertyIndex &index) const
|
CVariant CFlightPlan::propertyByIndex(const CPropertyIndex &index) const
|
||||||
@@ -104,7 +197,7 @@ namespace BlackMisc
|
|||||||
% QLatin1Char(' ') % m_cruiseAltitude.toQString(i18n)
|
% QLatin1Char(' ') % m_cruiseAltitude.toQString(i18n)
|
||||||
% QLatin1Char(' ') % m_cruiseTrueAirspeed.toQString(i18n)
|
% QLatin1Char(' ') % m_cruiseTrueAirspeed.toQString(i18n)
|
||||||
% QLatin1Char(' ') % m_route
|
% QLatin1Char(' ') % m_route
|
||||||
% QLatin1Char(' ') % m_remarks;
|
% QLatin1Char(' ') % this->getRemarks();
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
#include "aircrafticaocode.h"
|
#include "aircrafticaocode.h"
|
||||||
#include "altitude.h"
|
#include "altitude.h"
|
||||||
#include "callsign.h"
|
#include "callsign.h"
|
||||||
#include "flightplanutils.h"
|
#include "blackmisc/network/voicecapabilities.h"
|
||||||
#include "blackmisc/pq/speed.h"
|
#include "blackmisc/pq/speed.h"
|
||||||
#include "blackmisc/pq/time.h"
|
#include "blackmisc/pq/time.h"
|
||||||
#include "blackmisc/pq/units.h"
|
#include "blackmisc/pq/units.h"
|
||||||
@@ -36,6 +36,88 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
namespace Aviation
|
namespace Aviation
|
||||||
{
|
{
|
||||||
|
//! Flight plan remarks, parsed values
|
||||||
|
class BLACKMISC_EXPORT CFlightPlanRemarks : public CValueObject<CFlightPlanRemarks>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
//! Ctor
|
||||||
|
CFlightPlanRemarks();
|
||||||
|
|
||||||
|
//! Ctor
|
||||||
|
CFlightPlanRemarks(const QString &remarks, bool parse = true);
|
||||||
|
|
||||||
|
//! Ctor
|
||||||
|
CFlightPlanRemarks(const QString &remarks, Network::CVoiceCapabilities voiceCapabilities, bool parse = true);
|
||||||
|
|
||||||
|
//! The unparsed remarks
|
||||||
|
const QString &getRemarks() const { return m_remarks; }
|
||||||
|
|
||||||
|
//! Radio telephony designator
|
||||||
|
const QString &getRadioTelephony() const { return m_radioTelephony; }
|
||||||
|
|
||||||
|
//! Operator, i.e. normally the airline name
|
||||||
|
const QString &getFlightOperator() const { return m_flightOperator; }
|
||||||
|
|
||||||
|
//! Airline ICAO if provided in flight plan
|
||||||
|
const QString &getAirlineIcao() const { return m_airlineIcao; }
|
||||||
|
|
||||||
|
//! SELCAL code
|
||||||
|
const QString &getSelcalCode() const { return m_selcalCode; }
|
||||||
|
|
||||||
|
//! Get SELCAL
|
||||||
|
const CCallsign &getCallsign() const { return m_callsign; }
|
||||||
|
|
||||||
|
//! Voice capabilities
|
||||||
|
const Network::CVoiceCapabilities &getVoiceCapabilities() const { return m_voiceCapabilities; }
|
||||||
|
|
||||||
|
//! Any remarks available?
|
||||||
|
bool hasAnyParsedRemarks() const;
|
||||||
|
|
||||||
|
//! Airline remarks
|
||||||
|
bool hasParsedAirlineRemarks() const;
|
||||||
|
|
||||||
|
//! Parse remarks from a flight plan
|
||||||
|
void parseFlightPlanRemarks();
|
||||||
|
|
||||||
|
//! Valid airline ICAO?
|
||||||
|
//! \remark valid here means valid syntax, no guarantee it really exists
|
||||||
|
bool hasValidAirlineIcao() const { return !m_airlineIcao.isEmpty(); }
|
||||||
|
|
||||||
|
//! Not initialized
|
||||||
|
bool isNull() const { return m_isNull; }
|
||||||
|
|
||||||
|
//! \copydoc BlackMisc::Mixin::String::toQString()
|
||||||
|
QString convertToQString(bool i18n = false) const;
|
||||||
|
|
||||||
|
//! Get aircraft ICAO code from equipment code like
|
||||||
|
//! \remark we expect something like H/B772/F B773 B773/F
|
||||||
|
static QString aircraftIcaoCodeFromEquipmentCode(const QString &equipmentCodeAndAircraft);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString m_remarks; //!< the unparsed string
|
||||||
|
QString m_radioTelephony; //!< radio telephony designator
|
||||||
|
QString m_flightOperator; //!< operator, i.e. normally the airline name
|
||||||
|
QString m_airlineIcao; //!< airline ICAO if provided in flight plan
|
||||||
|
QString m_selcalCode; //!< SELCAL code
|
||||||
|
CCallsign m_callsign; //!< callsign of other pilot
|
||||||
|
bool m_isNull = true; //!< marked as NULL
|
||||||
|
Network::CVoiceCapabilities m_voiceCapabilities; //!< voice capabilities
|
||||||
|
|
||||||
|
BLACK_METACLASS(
|
||||||
|
CFlightPlanRemarks,
|
||||||
|
BLACK_METAMEMBER(radioTelephony),
|
||||||
|
BLACK_METAMEMBER(flightOperator),
|
||||||
|
BLACK_METAMEMBER(airlineIcao),
|
||||||
|
BLACK_METAMEMBER(selcalCode),
|
||||||
|
BLACK_METAMEMBER(callsign),
|
||||||
|
BLACK_METAMEMBER(isNull),
|
||||||
|
BLACK_METAMEMBER(voiceCapabilities)
|
||||||
|
);
|
||||||
|
|
||||||
|
//! Cut the remarks part
|
||||||
|
static QString cut(const QString &remarks, const QString &marker);
|
||||||
|
};
|
||||||
|
|
||||||
//! Value object for a flight plan
|
//! Value object for a flight plan
|
||||||
class BLACKMISC_EXPORT CFlightPlan :
|
class BLACKMISC_EXPORT CFlightPlan :
|
||||||
public CValueObject<CFlightPlan>,
|
public CValueObject<CFlightPlan>,
|
||||||
@@ -131,7 +213,7 @@ namespace BlackMisc
|
|||||||
void setRoute(const QString &route) { m_route = route.trimmed().left(MaxRouteLength).toUpper(); }
|
void setRoute(const QString &route) { m_route = route.trimmed().left(MaxRouteLength).toUpper(); }
|
||||||
|
|
||||||
//! Set remarks string (max 100 characters)
|
//! Set remarks string (max 100 characters)
|
||||||
void setRemarks(const QString &remarks) { m_remarks = remarks.trimmed().left(MaxRemarksLength).toUpper(); }
|
void setRemarks(const QString &remarks);
|
||||||
|
|
||||||
//! When last sent
|
//! When last sent
|
||||||
void setWhenLastSentOrLoaded(const QDateTime &dateTime) { this->setUtcTimestamp(dateTime); }
|
void setWhenLastSentOrLoaded(const QDateTime &dateTime) { this->setUtcTimestamp(dateTime); }
|
||||||
@@ -200,11 +282,10 @@ namespace BlackMisc
|
|||||||
qint64 timeDiffSentOrLoadedMs() const { return this->msecsToNow(); }
|
qint64 timeDiffSentOrLoadedMs() const { return this->msecsToNow(); }
|
||||||
|
|
||||||
//! Get remarks string
|
//! Get remarks string
|
||||||
const QString &getRemarks() const { return m_remarks; }
|
const QString &getRemarks() const { return m_remarks.getRemarks(); }
|
||||||
|
|
||||||
//! Get the parsed remarks
|
//! Get the parsable remarks
|
||||||
//! \remark parsing when calling the function, so avoid unnecessary calls
|
const CFlightPlanRemarks &getFlightPlanRemarks() const { return m_remarks; }
|
||||||
CFlightPlanUtils::FlightPlanRemarks getParsedRemarks() const;
|
|
||||||
|
|
||||||
//! Get aircraft ICAO, derived from equipment ICAO as in getEquipmentIcao()
|
//! Get aircraft ICAO, derived from equipment ICAO as in getEquipmentIcao()
|
||||||
const CAircraftIcaoCode &getAircraftIcao() const { return m_aircraftIcao; }
|
const CAircraftIcaoCode &getAircraftIcao() const { return m_aircraftIcao; }
|
||||||
@@ -229,6 +310,7 @@ namespace BlackMisc
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
CCallsign m_callsign;
|
CCallsign m_callsign;
|
||||||
|
CFlightPlanRemarks m_remarks;
|
||||||
QString m_equipmentIcao; //!< e.g. "T/A320/F"
|
QString m_equipmentIcao; //!< e.g. "T/A320/F"
|
||||||
CAircraftIcaoCode m_aircraftIcao; //!< Aircraft ICAO code derived from equipment ICAO
|
CAircraftIcaoCode m_aircraftIcao; //!< Aircraft ICAO code derived from equipment ICAO
|
||||||
CAirportIcaoCode m_originAirportIcao;
|
CAirportIcaoCode m_originAirportIcao;
|
||||||
@@ -242,7 +324,6 @@ namespace BlackMisc
|
|||||||
PhysicalQuantities::CSpeed m_cruiseTrueAirspeed;
|
PhysicalQuantities::CSpeed m_cruiseTrueAirspeed;
|
||||||
FlightRules m_flightRules;
|
FlightRules m_flightRules;
|
||||||
QString m_route;
|
QString m_route;
|
||||||
QString m_remarks;
|
|
||||||
|
|
||||||
BLACK_METACLASS(
|
BLACK_METACLASS(
|
||||||
CFlightPlan,
|
CFlightPlan,
|
||||||
@@ -265,6 +346,7 @@ namespace BlackMisc
|
|||||||
} // namespace
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(BlackMisc::Aviation::CFlightPlanRemarks)
|
||||||
Q_DECLARE_METATYPE(BlackMisc::Aviation::CFlightPlan)
|
Q_DECLARE_METATYPE(BlackMisc::Aviation::CFlightPlan)
|
||||||
|
|
||||||
#endif // guard
|
#endif // guard
|
||||||
|
|||||||
@@ -1,86 +0,0 @@
|
|||||||
/* Copyright (C) 2017
|
|
||||||
* swift project Community / Contributors
|
|
||||||
*
|
|
||||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
|
||||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
|
||||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
|
||||||
* contained in the LICENSE file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "flightplanutils.h"
|
|
||||||
#include "airlineicaocode.h"
|
|
||||||
#include <QStringBuilder>
|
|
||||||
#include <QRegularExpression>
|
|
||||||
|
|
||||||
using namespace BlackMisc::Network;
|
|
||||||
|
|
||||||
namespace BlackMisc
|
|
||||||
{
|
|
||||||
namespace Aviation
|
|
||||||
{
|
|
||||||
CFlightPlanUtils::FlightPlanRemarks CFlightPlanUtils::parseFlightPlanRemarks(const QString &remarks, const CVoiceCapabilities voiceCapabilities)
|
|
||||||
{
|
|
||||||
// examples: VFPS = VATSIM Flightplan Prefile System
|
|
||||||
// 1) RT/KESTREL OPR/MYTRAVEL REG/G-DAJC SEL/FP-ES PER/C NAV/RNP10
|
|
||||||
// 2) OPR/UAL CALLSIGN/UNITED
|
|
||||||
// 3) /v/FPL-VIR9-IS-A346/DEP/S-EGLL/ARR/KJFK/REG/G-VGAS/TCAS RVR/200 OPR/VIRGI
|
|
||||||
|
|
||||||
FlightPlanRemarks ar; // marked as NULL so far
|
|
||||||
if (remarks.isEmpty()) { return ar; }
|
|
||||||
const QString r = remarks.toUpper();
|
|
||||||
const QString cs = cut(r, "/REG"); // registration is what we call callsign
|
|
||||||
if (!cs.isEmpty()) { ar.callsign = CCallsign(cs, CCallsign::Aircraft); }
|
|
||||||
ar.voiceCapabilities = voiceCapabilities.isUnknown() ? CVoiceCapabilities(remarks) : voiceCapabilities;
|
|
||||||
ar.flightOperator = cut(r, "/OPR"); // operator, e.g. British airways, sometimes people use ICAO code here
|
|
||||||
ar.selcal = cut(r, "/SEL"); // SELCAL
|
|
||||||
ar.radioTelephony = cut(r, "/CALLSIGN"); // used similar to radio telephony
|
|
||||||
if (ar.radioTelephony.isEmpty()) { ar.radioTelephony = cut(r, "/RT"); }
|
|
||||||
if (!ar.flightOperator.isEmpty() && CAirlineIcaoCode::isValidAirlineDesignator(ar.flightOperator))
|
|
||||||
{
|
|
||||||
// move to airline ICAO
|
|
||||||
qSwap(ar.flightOperator, ar.airlineIcao);
|
|
||||||
}
|
|
||||||
ar.isNull = false;
|
|
||||||
return ar;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString CFlightPlanUtils::cut(const QString &remarks, const QString &marker)
|
|
||||||
{
|
|
||||||
const int maxIndex = remarks.size() - 1;
|
|
||||||
int f = remarks.indexOf(marker);
|
|
||||||
if (f < 0) { return ""; }
|
|
||||||
f += marker.length();
|
|
||||||
if (maxIndex <= f) { return ""; }
|
|
||||||
int to = remarks.indexOf(' ', f + 1);
|
|
||||||
if (to < 0) { to = maxIndex; } // no more spaces
|
|
||||||
const QString cut = remarks.mid(f, to - f).replace('/', ' '); // variations like /OPR/EASYJET/
|
|
||||||
// problem is that this cuts something like "Uzbekistan Airways"
|
|
||||||
return cut;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString CFlightPlanUtils::aircraftIcaoCodeFromEquipmentCode(const QString &equipmentCodeAndAircraft)
|
|
||||||
{
|
|
||||||
// http://uk.flightaware.com/about/faq_aircraft_flight_plan_suffix.rvt
|
|
||||||
// we expect something like H/B772/F B773 B773/F
|
|
||||||
thread_local const QRegularExpression reg("/.");
|
|
||||||
QString aircraftIcaoCode(equipmentCodeAndAircraft);
|
|
||||||
aircraftIcaoCode = aircraftIcaoCode.replace(reg, "").trimmed().toUpper();
|
|
||||||
return aircraftIcaoCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CFlightPlanUtils::FlightPlanRemarks::hasAnyRemarks() const
|
|
||||||
{
|
|
||||||
return this->hasAirlineRemarks() || !selcal.isEmpty() || !voiceCapabilities.isUnknown();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CFlightPlanUtils::FlightPlanRemarks::hasAirlineRemarks() const
|
|
||||||
{
|
|
||||||
return !radioTelephony.isEmpty() || !flightOperator.isEmpty() || !airlineIcao.isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CFlightPlanUtils::FlightPlanRemarks::hasValidAirlineIcao() const
|
|
||||||
{
|
|
||||||
return !airlineIcao.isEmpty(); // member only set if valid
|
|
||||||
}
|
|
||||||
} // namespace
|
|
||||||
} // namespace
|
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
/* Copyright (C) 2017
|
|
||||||
* swift project Community / Contributors
|
|
||||||
*
|
|
||||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
|
||||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
|
||||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
|
||||||
* contained in the LICENSE file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
//! \file
|
|
||||||
|
|
||||||
#ifndef BLACKMISC_AVIATION_FLIGHTPLANUTILS_H
|
|
||||||
#define BLACKMISC_AVIATION_FLIGHTPLANUTILS_H
|
|
||||||
|
|
||||||
#include "blackmisc/blackmiscexport.h"
|
|
||||||
#include "blackmisc/network/voicecapabilities.h"
|
|
||||||
#include "callsign.h"
|
|
||||||
#include <QString>
|
|
||||||
|
|
||||||
namespace BlackMisc
|
|
||||||
{
|
|
||||||
namespace Aviation
|
|
||||||
{
|
|
||||||
//! Flight plan utils
|
|
||||||
class BLACKMISC_EXPORT CFlightPlanUtils
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
//! Useful values in flight plan remarks
|
|
||||||
struct BLACKMISC_EXPORT FlightPlanRemarks
|
|
||||||
{
|
|
||||||
QString radioTelephony; //!< radio telephony designator
|
|
||||||
QString flightOperator; //!< operator, i.e. normally the airline name
|
|
||||||
QString airlineIcao; //!< airline ICAO as provided in flightplan
|
|
||||||
QString selcal; //!< SELCAL
|
|
||||||
CCallsign callsign; //!< callsign of other pilot
|
|
||||||
bool isNull = true; //!< marked as NULL
|
|
||||||
Network::CVoiceCapabilities voiceCapabilities; //!< voice capabilities
|
|
||||||
|
|
||||||
//! Any remarks available?
|
|
||||||
bool hasAnyRemarks() const;
|
|
||||||
|
|
||||||
//! Airline remarks
|
|
||||||
bool hasAirlineRemarks() const;
|
|
||||||
|
|
||||||
//! Valid airline ICAO?
|
|
||||||
//! \remark valid here means valid syntax, no guarantee it really exists
|
|
||||||
bool hasValidAirlineIcao() const;
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Constructor
|
|
||||||
CFlightPlanUtils() = delete;
|
|
||||||
|
|
||||||
//! Parse remarks from a flight plan
|
|
||||||
static FlightPlanRemarks parseFlightPlanRemarks(const QString &remarks, const Network::CVoiceCapabilities voiceCapabilities = {});
|
|
||||||
|
|
||||||
//! Get aircraft ICAO code from equipment code like
|
|
||||||
//! \remark we expect something like H/B772/F B773 B773/F
|
|
||||||
static QString aircraftIcaoCodeFromEquipmentCode(const QString &equipmentCodeAndAircraft);
|
|
||||||
|
|
||||||
private:
|
|
||||||
//! Cut the remarks part
|
|
||||||
static QString cut(const QString &remarks, const QString &marker);
|
|
||||||
};
|
|
||||||
} // namespace
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
#endif // guard
|
|
||||||
@@ -41,6 +41,7 @@ namespace BlackMisc
|
|||||||
CComSystem::registerMetadata();
|
CComSystem::registerMetadata();
|
||||||
CFlightPlan::registerMetadata();
|
CFlightPlan::registerMetadata();
|
||||||
CFlightPlanList::registerMetadata();
|
CFlightPlanList::registerMetadata();
|
||||||
|
CFlightPlanRemarks::registerMetadata();
|
||||||
CHeading::registerMetadata();
|
CHeading::registerMetadata();
|
||||||
CInformationMessage::registerMetadata();
|
CInformationMessage::registerMetadata();
|
||||||
CLivery::registerMetadata();
|
CLivery::registerMetadata();
|
||||||
|
|||||||
Reference in New Issue
Block a user