mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 09:15:34 +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
@@ -943,13 +943,49 @@ namespace BlackCore
|
||||
|
||||
if (it != m_aliasedStations.end())
|
||||
{
|
||||
CLogMessage(this).debug(u"Aliasing %1Hz [VHF] to %2Hz [HF]") << frequencyHz << it->frequencyHz;
|
||||
roundedFrequencyHz = it->frequencyHz;
|
||||
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;
|
||||
roundedFrequencyHz = it->frequencyHz;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CLogMessage(this).debug(u"Aliasing %1Hz [VHF] to %2Hz [HF]") << frequencyHz << it->frequencyHz;
|
||||
roundedFrequencyHz = it->frequencyHz;
|
||||
}
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
switch (comUnit)
|
||||
|
||||
Reference in New Issue
Block a user