mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-13 07:35:41 +08:00
Some convenience functions ATC station
This commit is contained in:
@@ -57,6 +57,31 @@ namespace BlackMisc
|
||||
this->m_controller.setCallsign(callsign);
|
||||
}
|
||||
|
||||
/*
|
||||
* METAR
|
||||
*/
|
||||
bool CAtcStation::hasMetar() const
|
||||
{
|
||||
return this->m_metar.hasMessage();
|
||||
}
|
||||
|
||||
/*
|
||||
* Suffix
|
||||
*/
|
||||
QString CAtcStation::getCallsignSuffix() const
|
||||
{
|
||||
return m_callsign.getSuffix();
|
||||
}
|
||||
|
||||
/*
|
||||
* Callsign
|
||||
*/
|
||||
void CAtcStation::setCallsign(const CCallsign &callsign)
|
||||
{
|
||||
this->m_callsign = callsign;
|
||||
this->m_controller.setCallsign(callsign);
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert to string
|
||||
*/
|
||||
|
||||
@@ -83,10 +83,7 @@ namespace BlackMisc
|
||||
}
|
||||
|
||||
//! Has METAR?
|
||||
bool hasMetar() const
|
||||
{
|
||||
return this->m_metar.hasMessage();
|
||||
}
|
||||
bool hasMetar() const;
|
||||
|
||||
//! Get callsign.
|
||||
const CCallsign &getCallsign() const { return m_callsign; }
|
||||
@@ -94,8 +91,11 @@ namespace BlackMisc
|
||||
//! Get callsign as string.
|
||||
QString getCallsignAsString() const { return m_callsign.asString(); }
|
||||
|
||||
//! Callsign suffix (e.g. TWR)
|
||||
QString getCallsignSuffix() const;
|
||||
|
||||
//! Set callsign
|
||||
void setCallsign(const CCallsign &callsign) { this->m_callsign = callsign; this->m_controller.setCallsign(callsign);}
|
||||
void setCallsign(const CCallsign &callsign);
|
||||
|
||||
//! Get controller
|
||||
const BlackMisc::Network::CUser &getController() const { return m_controller; }
|
||||
|
||||
@@ -85,6 +85,17 @@ namespace BlackMisc
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* Find by suffix
|
||||
*/
|
||||
CAtcStationList CAtcStationList::findBySuffix(const QString &suffix) const
|
||||
{
|
||||
CAtcStationList r;
|
||||
if (suffix.isEmpty()) { return r; }
|
||||
r = this->findBy(&CAtcStation::getCallsignSuffix, suffix);
|
||||
return r;
|
||||
}
|
||||
|
||||
/*
|
||||
* Distances to own plane
|
||||
*/
|
||||
@@ -104,6 +115,28 @@ namespace BlackMisc
|
||||
return this->findBy(Predicates::MemberValid(&CAtcStation::getController)).transform(Predicates::MemberTransform(&CAtcStation::getController));
|
||||
}
|
||||
|
||||
/*
|
||||
* Suffixes with count
|
||||
*/
|
||||
QMap<QString, int> CAtcStationList::getSuffixes() const
|
||||
{
|
||||
QMap<QString, int> r;
|
||||
for (const CAtcStation &station : (*this))
|
||||
{
|
||||
const QString s = station.getCallsignSuffix();
|
||||
if (s.isEmpty()) { continue; }
|
||||
if (r.contains(s))
|
||||
{
|
||||
r[s] = r[s] + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
r.insert(s, 1);
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
/*
|
||||
* Merge with booking, both (online/booking will be updated)
|
||||
*/
|
||||
|
||||
@@ -48,9 +48,15 @@ namespace BlackMisc
|
||||
//! Find 0..n stations tune in frequency of COM unit (with 25kHt channel spacing
|
||||
CAtcStationList findIfComUnitTunedIn25KHz(const BlackMisc::Aviation::CComSystem &comUnit) const;
|
||||
|
||||
//! Find 0..n stations matching the suffix (e.g. TWR)
|
||||
CAtcStationList findBySuffix(const QString &suffix) const;
|
||||
|
||||
//! All controllers (with valid data)
|
||||
BlackMisc::Network::CUserList getControllers() const;
|
||||
|
||||
//! Get all (different suffixes)
|
||||
QMap<QString, int> getSuffixes() const;
|
||||
|
||||
//! Update distances to coordinate, usually own aircraft's position
|
||||
void calculateDistancesToPlane(const BlackMisc::Geo::CCoordinateGeodetic &position);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user