mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-29 12:45:40 +08:00
[AFV] Add fuzzy callsign matching before aliasing a HF station
# Conflicts: # src/blackcore/afv/clients/afvclient.h
This commit is contained in:
committed by
Klaus Basan
parent
cf50d50f4f
commit
1051cc5751
@@ -942,14 +942,50 @@ namespace BlackCore
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (it != m_aliasedStations.end())
|
if (it != m_aliasedStations.end())
|
||||||
|
{
|
||||||
|
if (sApp->getIContextNetwork())
|
||||||
|
{
|
||||||
|
// Get the callsign for this frequency and fuzzy compare with our alias station
|
||||||
|
const CComSystem::ChannelSpacing spacing = CComSystem::ChannelSpacing25KHz;
|
||||||
|
CFrequency f(static_cast<int>(roundedFrequencyHz), CFrequencyUnit::Hz());
|
||||||
|
CAtcStationList matchingAtcStations = sApp->getIContextNetwork()->getOnlineStationsForFrequency(f, spacing);
|
||||||
|
CAtcStation closest = matchingAtcStations.findClosest(1, sApp->getIContextOwnAircraft()->getOwnAircraftSituation().getPosition()).frontOrDefault();
|
||||||
|
|
||||||
|
if (fuzzyMatchCallSign(it->name, closest.getCallsign().asString()))
|
||||||
{
|
{
|
||||||
CLogMessage(this).debug(u"Aliasing %1Hz [VHF] to %2Hz [HF]") << frequencyHz << it->frequencyHz;
|
CLogMessage(this).debug(u"Aliasing %1Hz [VHF] to %2Hz [HF]") << frequencyHz << it->frequencyHz;
|
||||||
roundedFrequencyHz = it->frequencyHz;
|
roundedFrequencyHz = it->frequencyHz;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CLogMessage(this).debug(u"Aliasing %1Hz [VHF] to %2Hz [HF]") << frequencyHz << it->frequencyHz;
|
||||||
|
roundedFrequencyHz = it->frequencyHz;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return roundedFrequencyHz;
|
return roundedFrequencyHz;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CAfvClient::fuzzyMatchCallSign(const QString &callsign, const QString &compareTo) const
|
||||||
|
{
|
||||||
|
QString prefixA;
|
||||||
|
QString suffixA;
|
||||||
|
QString prefixB;
|
||||||
|
QString suffixB;
|
||||||
|
getPrefixSuffix(callsign, prefixA, suffixA);
|
||||||
|
getPrefixSuffix(compareTo, prefixB, suffixB);
|
||||||
|
return (prefixA == prefixB) && (suffixA == suffixB);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CAfvClient::getPrefixSuffix(const QString &callsign, QString &prefix, QString &suffix) const
|
||||||
|
{
|
||||||
|
QRegularExpression separator("[(-|_)]");
|
||||||
|
QStringList parts = callsign.split(separator);
|
||||||
|
prefix = parts.first();
|
||||||
|
suffix = parts.last();
|
||||||
|
}
|
||||||
|
|
||||||
quint16 CAfvClient::comUnitToTransceiverId(CComSystem::ComUnit comUnit)
|
quint16 CAfvClient::comUnitToTransceiverId(CComSystem::ComUnit comUnit)
|
||||||
{
|
{
|
||||||
switch (comUnit)
|
switch (comUnit)
|
||||||
|
|||||||
@@ -292,6 +292,9 @@ namespace BlackCore
|
|||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
quint32 getAliasFrequencyHz(quint32 frequencyHz) const;
|
quint32 getAliasFrequencyHz(quint32 frequencyHz) const;
|
||||||
|
|
||||||
|
bool fuzzyMatchCallSign(const QString &callsign, const QString &compareTo) const;
|
||||||
|
void getPrefixSuffix(const QString &callsign, QString &prefix, QString &suffix) const;
|
||||||
|
|
||||||
static constexpr int PositionUpdatesMs = 20000; //!< position timer
|
static constexpr int PositionUpdatesMs = 20000; //!< position timer
|
||||||
static constexpr int SampleRate = 48000;
|
static constexpr int SampleRate = 48000;
|
||||||
static constexpr int FrameSize = static_cast<int>(SampleRate * 0.02); //!< 20ms
|
static constexpr int FrameSize = static_cast<int>(SampleRate * 0.02); //!< 20ms
|
||||||
|
|||||||
Reference in New Issue
Block a user