6 #include <QCoreApplication>
7 #include <QStringBuilder>
20 using namespace swift::misc::physical_quantities;
21 using namespace swift::misc::geo;
22 using namespace swift::misc::network;
26 namespace swift::misc::aviation
28 CAtcStation::CAtcStation() {}
30 CAtcStation::CAtcStation(
const QString &callsign) : m_callsign(callsign) { m_callsign.
setTypeHint(CCallsign::Atc); }
36 : m_callsign(callsign), m_controller(controller), m_frequency(frequency), m_position(pos), m_range(range),
37 m_isOnline(isOnline), m_logoffTimeUtc(logoffTimeUtc), m_atis(atis), m_metar(metar)
60 m_callsign = callsign;
74 m_controller = controller;
80 static const QString atcI18n(QCoreApplication::translate(
"Aviation",
"ATC station"));
81 static const QString rangeI18n(QCoreApplication::translate(
"Aviation",
"range"));
82 static const QString fromUtcI18n(QCoreApplication::translate(
"Aviation",
"from(UTC)"));
83 static const QString untilUtcI18n(QCoreApplication::translate(
"Aviation",
"until(UTC)"));
85 const QString s = (i18n ? atcI18n : QStringLiteral(
"ATC station")) % u
' ' % m_callsign.
toQString(i18n) % u
' ' %
89 (m_controller.
isNull() ? QString() : u
' ' % m_controller.
toQString(i18n)) %
101 u
' ' % (i18n ? rangeI18n : QStringLiteral(
"range")) % u
' ' % m_range.
toQString(i18n) %
104 u
' ' % ICoordinateWithRelativePosition::convertToQString(i18n);
109 (void)QT_TRANSLATE_NOOP(
"Aviation",
"ATC station");
110 (void)QT_TRANSLATE_NOOP(
"Aviation",
"online");
111 (void)QT_TRANSLATE_NOOP(
"Aviation",
"offline");
112 (void)QT_TRANSLATE_NOOP(
"Aviation",
"from(UTC)");
113 (void)QT_TRANSLATE_NOOP(
"Aviation",
"until(UTC)");
114 (void)QT_TRANSLATE_NOOP(
"Aviation",
"range");
115 (void)QT_TRANSLATE_NOOP(
"Aviation",
"distance");
120 m_frequency = frequency;
121 m_frequency.
setUnit(CFrequencyUnit::MHz());
132 if (online == m_isOnline) {
return false; }
151 case CInformationMessage::ATIS:
return this->
getAtis();
152 case CInformationMessage::METAR:
return this->
getMetar();
162 case CInformationMessage::ATIS: this->
setAtis(message);
return true;
163 case CInformationMessage::METAR: this->
setMetar(message);
return true;
181 if (index.
isMyself()) {
return QVariant::fromValue(*
this); }
185 case IndexLogoffTime:
return QVariant::fromValue(m_logoffTimeUtc);
191 case IndexIsOnline:
return QVariant::fromValue(m_isOnline);
196 case IndexIsInRange:
return QVariant::fromValue(
isInRange());
199 case IndexIsAfvCrossCoupled:
return QVariant::fromValue(m_isAfvCrossCoupled);
201 return (ICoordinateWithRelativePosition::canHandleIndex(index)) ?
202 ICoordinateWithRelativePosition::propertyByIndex(index) :
217 case IndexLogoffTime: this->
setLogoffTimeUtc(variant.value<QDateTime>());
break;
221 case IndexIsOnline: this->
setOnline(variant.value<
bool>());
break;
227 case IndexCallsignString:
228 case IndexCallsignStringCrossCopuled:
230 const QString cs = variant.toString();
236 if (ICoordinateWithRelativePosition::canHandleIndex(index))
238 ICoordinateWithRelativePosition::setPropertyByIndex(index, variant);
255 case IndexCallsignString:
256 case IndexCallsignStringCrossCopuled:
260 case IndexController:
264 case IndexIsOnline:
return Compare::compare(this->
isOnline(), compareValue.
isOnline());
272 case IndexIsInRange:
return Compare::compare(this->
isInRange(), compareValue.
isInRange());
275 case IndexIsAfvCrossCoupled:
278 if (ICoordinateWithRelativePosition::canHandleIndex(index))
280 return ICoordinateWithRelativePosition::comparePropertyByIndex(index, compareValue);
284 Q_ASSERT_X(
false, Q_FUNC_INFO,
"Compare failed");
Non-owning reference to a CPropertyIndex with a subset of its features.
Q_REQUIRED_RESULT CPropertyIndexRef copyFrontRemoved() const
Copy with first element removed.
static CPropertyIndexRef empty()
an empty property index
CastType frontCasted() const
First element casted to given type, usually the PropertIndex enum.
bool isMyself() const
Myself index, used with nesting.
Altitude as used in aviation, can be AGL or MSL altitude.
Value object encapsulating information about an ATC station.
void setController(const network::CUser &controller)
Set controller.
virtual geo::CLatitude latitude() const
Latitude.
void setFrequency(const swift::misc::physical_quantities::CFrequency &frequency)
Set frequency.
void setAfvCrossCoupled(bool coupled)
Set AFV cross coupled.
ColumnIndex
Properties by index.
bool isOnline() const
Is station online?
const CCallsign & getCallsign() const
Get callsign.
void setMetar(const CInformationMessage &metar)
Set METAR.
virtual geo::CLongitude longitude() const
Longitude.
bool hasAtis() const
Has ATIS?
QString getCallsignSuffix() const
Callsign suffix (e.g. TWR)
void setCallsign(const CCallsign &callsign)
Set callsign.
const aviation::CAltitude & geodeticHeight() const
Height, ellipsoidal or geodetic height (used in GPS)
const geo::CCoordinateGeodetic & getPosition() const
Get the position of the center of the controller's area of visibility.
const CInformationMessage & getMetar() const
Get METAR.
QString getCallsignAsString() const
Get callsign as string.
bool isComUnitTunedToFrequency(const aviation::CComSystem &comUnit) const
Is Com unit tuned to this stations frequency.
const CInformationMessage & getInformationMessage(CInformationMessage::InformationType type) const
Message per type.
QString getCallsignAsStringCrossCoupled() const
Get callsign.
QString getCallsignAndControllerRealName() const
Callsign and controller's name if available.
virtual std::array< double, 3 > normalVectorDouble() const
Normal vector with double precision.
bool setOnline(bool online)
Set online.
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
bool isAtcStationFrequency(const physical_quantities::CFrequency &frequency) const
Is passed frequency the frequency of this station.
QString getControllerRealName() const
Get controller name.
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
const CInformationMessage & getAtis() const
Get ATIS.
bool setMessage(const CInformationMessage &message)
Set given message.
int getSuffixSortOrder() const
Callsign suffix sort order.
const physical_quantities::CFrequency & getFrequency() const
Get frequency.
bool isAfvCrossCoupled() const
Is AFV cross coupled?
CAtcStation()
Default constructor.
const swift::misc::network::CUser & getController() const
Get controller.
const QDateTime & getLogoffTimeUtc() const
Return the expected logoff time (UTC). This data comes from the controller through its ATIS line.
bool hasMetar() const
Has METAR?
virtual QVector3D normalVector() const
Normal vector.
const physical_quantities::CLength & getRange() const
Get the radius of the controller's area of visibility.
bool isInRange() const
In range? If range and distance to own aircraft are not available false.
bool hasLogoffTimeUtc() const
Has expected logoff time?
void setAtis(const CInformationMessage &atis)
Set ATIS.
QString convertToQString(bool i18n=false) const
Cast as QString.
int comparePropertyByIndex(CPropertyIndexRef index, const CAtcStation &compareValue) const
Compare for index.
void setLogoffTimeUtc(const QDateTime &logoffTimeUtc)
Set expected logoff time (UTC)
Value object encapsulating information of a callsign.
int getSuffixSortOrder() const
Sort order by suffix.
int comparePropertyByIndex(CPropertyIndexRef index, const CCallsign &compareValue) const
Compare for index.
const QString & asString() const
Get callsign (normalized)
QString getSuffix() const
Get the callsign suffix ("TWR", "ATIS" ...) if any ("_" is removed)
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
bool isEmpty() const
Is empty?
void setTypeHint(TypeHint hint)
Type hint.
const QString & getStringAsSet() const
Get callsign.
static bool isSameFrequency(const physical_quantities::CFrequency &freq1, const physical_quantities::CFrequency &freq2)
Compare frequencies under consideration that on VATSIM frequencies .x20/.x25 and ....
bool isActiveFrequencySameFrequency(const physical_quantities::CFrequency &comFrequency) const
Is active frequency the same frequency.
int comparePropertyByIndex(CPropertyIndexRef index, const CCoordinateGeodetic &compareValue) const
Set property by index.
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
virtual CLatitude latitude() const
Latitude.
virtual std::array< double, 3 > normalVectorDouble() const
Normal vector with double precision.
virtual const aviation::CAltitude & geodeticHeight() const
Height, ellipsoidal or geodetic height (used in GPS)
virtual QVector3D normalVector() const
Normal vector.
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
virtual CLongitude longitude() const
Longitude.
const physical_quantities::CLength & getRelativeDistance() const
Get the distance.
bool hasValidRelativeDistance() const
Valid distance?
int comparePropertyByIndex(CPropertyIndexRef index, const Derived &compareValue) const
Compare for index.
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
QString toQString(bool i18n=false) const
Cast as QString.
Value object encapsulating information of a user.
bool hasRealName() const
Valid real name?
int comparePropertyByIndex(CPropertyIndexRef index, const CUser &compareValue) const
Compare for index.
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
bool setCallsign(const aviation::CCallsign &callsign)
Set associated callsign.
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
bool hasCallsign() const
Has associated callsign?
Physical unit length (length)
bool isNull() const
Is quantity null?
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
int comparePropertyByIndex(CPropertyIndexRef index, const PQ &pq) const
Compare for index.
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
void setUnit(const MU &unit)
Simply set unit, do no calclulate conversion.
QString valueRoundedWithUnit(const MU &unit, int digits=-1, bool withGroupSeparator=false, bool i18n=false) const
Value to QString with the given unit, e.g. "5.00m".
Free functions in swift::misc.
SWIFT_MISC_EXPORT const QString & boolToYesNo(bool v)
Bool to yes/no.
#define SWIFT_DEFINE_VALUEOBJECT_MIXINS(Namespace, Class)
Explicit template definition of mixins for a CValueObject subclass.