Ref T664, allow hyphen in ATC station callsign

This commit is contained in:
Klaus Basan
2019-05-18 00:35:31 +02:00
parent a37ce2d258
commit b9366e636c
4 changed files with 17 additions and 9 deletions

View File

@@ -336,6 +336,7 @@ namespace BlackGui
void CAtcStationComponent::testCreateDummyOnlineAtcStations(int number)
{
if (!sGui || !sGui->getIContextNetwork()) { return; }
if (this->canAccessContext())
{
sGui->getIContextNetwork()->testCreateDummyOnlineAtcStations(number);

View File

@@ -20,15 +20,15 @@ namespace BlackMisc
namespace Aviation
{
CCallsign::CCallsign(const QString &callsign, CCallsign::TypeHint hint)
: m_callsignAsSet(callsign.trimmed()), m_callsign(CCallsign::unifyCallsign(callsign)), m_typeHint(hint)
: m_callsignAsSet(callsign.trimmed()), m_callsign(CCallsign::unifyCallsign(callsign, hint)), m_typeHint(hint)
{}
CCallsign::CCallsign(const QString &callsign, const QString &telephonyDesignator, CCallsign::TypeHint hint)
: m_callsignAsSet(callsign.trimmed()), m_callsign(CCallsign::unifyCallsign(callsign)), m_telephonyDesignator(telephonyDesignator.trimmed()), m_typeHint(hint)
: m_callsignAsSet(callsign.trimmed()), m_callsign(CCallsign::unifyCallsign(callsign, hint)), m_telephonyDesignator(telephonyDesignator.trimmed()), m_typeHint(hint)
{}
CCallsign::CCallsign(const char *callsign, CCallsign::TypeHint hint)
: m_callsignAsSet(callsign), m_callsign(CCallsign::unifyCallsign(callsign)), m_typeHint(hint)
: m_callsignAsSet(callsign), m_callsign(CCallsign::unifyCallsign(callsign, hint)), m_typeHint(hint)
{}
void CCallsign::registerMetadata()
@@ -68,8 +68,14 @@ namespace BlackMisc
return std::numeric_limits<int>::max();
}
QString CCallsign::unifyCallsign(const QString &callsign)
QString CCallsign::unifyCallsign(const QString &callsign, TypeHint hint)
{
// Ref T664, allow ATC with hyphen, such as Ml-SNO_CTR
switch (hint)
{
case Atc: return removeChars(callsign.toUpper().trimmed(), [](QChar c) { return !c.isLetterOrNumber() && c != '_' && c != '-'; });
default: break;
}
return removeChars(callsign.toUpper().trimmed(), [](QChar c) { return !c.isLetterOrNumber() && c != '_'; });
}
@@ -282,8 +288,9 @@ namespace BlackMisc
bool CCallsign::isValidAtcCallsign(const QString &callsign)
{
// Ref T664, allow ATC with hyphen, such as Ml-SNO_CTR
if (callsign.length() < 2 || callsign.length() > 10) { return false; }
return !containsChar(callsign, [](QChar c) { return c != '_' && !c.isUpper() && !c.isDigit(); });
return !containsChar(callsign, [](QChar c) { return c != '-' && c != '_' && !c.isUpper() && !c.isDigit(); });
}
bool CCallsign::isValidAtcCallsign(const CCallsign &callsign)

View File

@@ -159,7 +159,7 @@ namespace BlackMisc
static bool isValidAtcCallsign(const CCallsign &callsign);
//! Unify the callsign by removing illegal characters
static QString unifyCallsign(const QString &callsign);
static QString unifyCallsign(const QString &callsign, TypeHint hint = NoHint);
//! List of real ATC suffixes (e.g. TWR);
static const QStringList &atcCallsignSuffixes();

View File

@@ -50,9 +50,9 @@ namespace BlackMisc
// from WGS is slow, so static const (only 1 time init)
// https://dev.vatsim-germany.org/issues/322#note-2
static const CCoordinateGeodetic geoPos = CCoordinateGeodetic::fromWgs84("48° 21 13″ N", "11° 47 09″ E", CAltitude(index, CLengthUnit::ft()));
const QString cs = QStringLiteral("%1_TWR").arg(index);
const QString cs = QStringLiteral("%1MI-SNO_TWR").arg(index);
const QString usr = QStringLiteral("Joe %1").arg(index);
const QString id = QStringLiteral("00000%1").arg(index).right(6);
const QString id = QStringLiteral("00000%1").arg(index).right(6);
const double f = 118.0 + (index % 30) * 0.25;
const QDateTime dtFrom = QDateTime::currentDateTimeUtc();
@@ -78,7 +78,7 @@ namespace BlackMisc
}
else
{
station = CAtcStation(CCallsign(cs), user,
station = CAtcStation(CCallsign(cs, CCallsign::Atc), user,
CFrequency(f, CFrequencyUnit::MHz()),
geoPos, CLength(50, CLengthUnit::km()), false, dtFrom, dtUntil);
station.setRelativeDistance(CLength(index + 1, CLengthUnit::NM()));