Some convenience functions ATC station

This commit is contained in:
Klaus Basan
2015-01-22 11:06:50 +01:00
parent 49a8dee67c
commit 9d14f8f42d
4 changed files with 69 additions and 5 deletions

View File

@@ -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
*/

View File

@@ -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; }

View File

@@ -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)
*/

View File

@@ -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);