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(
const QString &callsign) : m_callsign(callsign) { m_callsign.
setTypeHint(CCallsign::Atc); }
34 : m_callsign(callsign), m_controller(controller), m_frequency(frequency), m_position(pos), m_range(range),
35 m_isOnline(isOnline), m_logoffTimeUtc(logoffTimeUtc), m_atis(atis), m_metar(metar)
58 m_callsign = callsign;
72 m_controller = controller;
83 const QString s = (i18n ? atcI18n : QStringLiteral(
"ATC station")) % u
' ' % m_callsign.
toQString(i18n) % u
' ' %
99 u
' ' % (i18n ? rangeI18n : QStringLiteral(
"range")) % u
' ' % m_range.
toQString(i18n) %
102 u
' ' % ICoordinateWithRelativePosition::convertToQString(i18n);
107 (void)QT_TRANSLATE_NOOP(
"Aviation",
"ATC station");
108 (void)QT_TRANSLATE_NOOP(
"Aviation",
"online");
109 (void)QT_TRANSLATE_NOOP(
"Aviation",
"offline");
110 (void)QT_TRANSLATE_NOOP(
"Aviation",
"from(UTC)");
111 (void)QT_TRANSLATE_NOOP(
"Aviation",
"until(UTC)");
112 (void)QT_TRANSLATE_NOOP(
"Aviation",
"range");
113 (void)QT_TRANSLATE_NOOP(
"Aviation",
"distance");
118 m_frequency = frequency;
119 m_frequency.
setUnit(CFrequencyUnit::MHz());
130 if (online == m_isOnline) {
return false; }
149 case CInformationMessage::ATIS:
return this->
getAtis();
150 case CInformationMessage::METAR:
return this->
getMetar();
160 case CInformationMessage::ATIS: this->
setAtis(message);
return true;
161 case CInformationMessage::METAR: this->
setMetar(message);
return true;
199 return (ICoordinateWithRelativePosition::canHandleIndex(index)) ?
200 ICoordinateWithRelativePosition::propertyByIndex(index) :
219 case IndexIsOnline: this->
setOnline(variant.
value<
bool>());
break;
225 case IndexCallsignString:
226 case IndexCallsignStringCrossCopuled:
234 if (ICoordinateWithRelativePosition::canHandleIndex(index))
236 ICoordinateWithRelativePosition::setPropertyByIndex(index, variant);
253 case IndexCallsignString:
254 case IndexCallsignStringCrossCopuled:
258 case IndexController:
262 case IndexIsOnline:
return Compare::compare(this->
isOnline(), compareValue.
isOnline());
270 case IndexIsInRange:
return Compare::compare(this->
isInRange(), compareValue.
isInRange());
273 case IndexIsAfvCrossCoupled:
276 if (ICoordinateWithRelativePosition::canHandleIndex(index))
278 return ICoordinateWithRelativePosition::comparePropertyByIndex(index, compareValue);
282 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.
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.
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.
std::array< double, 3 > normalVectorDouble() const
Normal vector with double precision.
CAtcStation()=default
Default constructor.
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?
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?
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.
const aviation::CAltitude & geodeticHeight() const
Height, ellipsoidal or geodetic height (used in GPS)
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
CLatitude latitude() const
Latitude.
std::array< double, 3 > normalVectorDouble() const
Normal vector with double precision.
QVector3D normalVector() const
Normal vector.
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
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.
QString translate(const char *context, const char *sourceText, const char *disambiguation, int n)
bool isNull() const const
bool startsWith(QChar c, Qt::CaseSensitivity cs) const const
QVariant fromValue(T &&value)
QString toString() const const
#define SWIFT_DEFINE_VALUEOBJECT_MIXINS(Namespace, Class)
Explicit template definition of mixins for a CValueObject subclass.