diff --git a/src/blackmisc/avatcstation.cpp b/src/blackmisc/avatcstation.cpp index efa9becfe..aa190db2d 100644 --- a/src/blackmisc/avatcstation.cpp +++ b/src/blackmisc/avatcstation.cpp @@ -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 */ diff --git a/src/blackmisc/avatcstation.h b/src/blackmisc/avatcstation.h index 01f48a89b..180e018bb 100644 --- a/src/blackmisc/avatcstation.h +++ b/src/blackmisc/avatcstation.h @@ -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; } diff --git a/src/blackmisc/avatcstationlist.cpp b/src/blackmisc/avatcstationlist.cpp index b0943cd5e..9d6b09032 100644 --- a/src/blackmisc/avatcstationlist.cpp +++ b/src/blackmisc/avatcstationlist.cpp @@ -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 CAtcStationList::getSuffixes() const + { + QMap 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) */ diff --git a/src/blackmisc/avatcstationlist.h b/src/blackmisc/avatcstationlist.h index a74d13738..9e7ae0ee1 100644 --- a/src/blackmisc/avatcstationlist.h +++ b/src/blackmisc/avatcstationlist.h @@ -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 getSuffixes() const; + //! Update distances to coordinate, usually own aircraft's position void calculateDistancesToPlane(const BlackMisc::Geo::CCoordinateGeodetic &position);