mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 21:15:33 +08:00
Ref T298, matcher setup improvements (score only)
This commit is contained in:
@@ -16,7 +16,7 @@ namespace BlackMisc
|
||||
{
|
||||
CAircraftMatcherSetup::CAircraftMatcherSetup()
|
||||
{
|
||||
this->reset(MatchingScoreBased);
|
||||
this->reset(MatchingStepwiseReducePlusScoreBased);
|
||||
}
|
||||
|
||||
CAircraftMatcherSetup::CAircraftMatcherSetup(CAircraftMatcherSetup::MatchingAlgorithm algorithm)
|
||||
@@ -50,7 +50,7 @@ namespace BlackMisc
|
||||
Q_UNUSED(i18n);
|
||||
return QStringLiteral("algorithm: '") % this->getMatchingAlgorithmAsString() %
|
||||
QStringLiteral("' mode: '") % this->getMatchingModeAsString() %
|
||||
QStringLiteral("' strategy: ") % this->getPickStrategyAsString() %
|
||||
QStringLiteral("' strategy: '") % this->getPickStrategyAsString() %
|
||||
QStringLiteral("'");
|
||||
}
|
||||
|
||||
@@ -92,9 +92,12 @@ namespace BlackMisc
|
||||
mode = ModeDefaultReduce;
|
||||
break;
|
||||
case MatchingScoreBased:
|
||||
default:
|
||||
mode = ModeDefaultScore;
|
||||
break;
|
||||
case MatchingStepwiseReducePlusScoreBased:
|
||||
default:
|
||||
mode = ModeDefaultReducePlusScore;
|
||||
break;
|
||||
}
|
||||
this->setMatchingMode(mode);
|
||||
this->setPickStrategy(PickByOrder);
|
||||
@@ -102,15 +105,17 @@ namespace BlackMisc
|
||||
|
||||
const QString &CAircraftMatcherSetup::algorithmToString(CAircraftMatcherSetup::MatchingAlgorithm algorithm)
|
||||
{
|
||||
static const QString rs("reduce + score based");
|
||||
static const QString s("score based");
|
||||
static const QString r("stepwise reduce");
|
||||
switch (algorithm)
|
||||
{
|
||||
case MatchingStepwiseReduce: return r;
|
||||
case MatchingScoreBased:
|
||||
case MatchingScoreBased: return s;
|
||||
case MatchingStepwiseReducePlusScoreBased:
|
||||
default: break;
|
||||
}
|
||||
return s;
|
||||
return rs;
|
||||
}
|
||||
|
||||
const QString &CAircraftMatcherSetup::modeFlagToString(MatchingModeFlag modeFlag)
|
||||
@@ -121,20 +126,20 @@ namespace BlackMisc
|
||||
static const QString icaoAirline("by ICAO, airline first");
|
||||
static const QString family("by family");
|
||||
static const QString livery("by livery");
|
||||
static const QString combined("by combined combined");
|
||||
static const QString combined("by combined code");
|
||||
static const QString noZeros("scoring, ignore zero scores");
|
||||
static const QString preferColorLiveries("scoring, prefer color liveries");
|
||||
|
||||
switch (modeFlag)
|
||||
{
|
||||
case ByModelString: return ms;
|
||||
case ByIcaoData: return icao;
|
||||
case ByFamily: return family;
|
||||
case ByLivery: return livery;
|
||||
case ByCombinedType: return combined;
|
||||
case ByModelString: return ms;
|
||||
case ByIcaoData: return icao;
|
||||
case ByFamily: return family;
|
||||
case ByLivery: return livery;
|
||||
case ByCombinedType: return combined;
|
||||
case ByIcaoOrderAircraftFirst: return icaoAircraft;
|
||||
case ByIcaoOrderAirlineFirst: return icaoAirline;
|
||||
case ScoreIgnoreZeros: return noZeros;
|
||||
case ByIcaoOrderAirlineFirst: return icaoAirline;
|
||||
case ScoreIgnoreZeros: return noZeros;
|
||||
case ScorePreferColorLiveries: return preferColorLiveries;
|
||||
default: break;
|
||||
}
|
||||
@@ -146,8 +151,8 @@ namespace BlackMisc
|
||||
QString CAircraftMatcherSetup::modeToString(MatchingMode mode)
|
||||
{
|
||||
QStringList modes;
|
||||
if (mode.testFlag(ByModelString)) { modes << modeFlagToString(ByModelString); }
|
||||
if (mode.testFlag(ByIcaoData)) { modes << modeFlagToString(ByIcaoData); }
|
||||
if (mode.testFlag(ByModelString)) { modes << modeFlagToString(ByModelString); }
|
||||
if (mode.testFlag(ByIcaoData)) { modes << modeFlagToString(ByIcaoData); }
|
||||
if (mode.testFlag(ByIcaoOrderAircraftFirst)) { modes << modeFlagToString(ByIcaoOrderAircraftFirst); }
|
||||
if (mode.testFlag(ByIcaoOrderAirlineFirst)) { modes << modeFlagToString(ByIcaoOrderAirlineFirst); }
|
||||
if (mode.testFlag(ByFamily)) { modes << modeFlagToString(ByFamily); }
|
||||
@@ -166,9 +171,9 @@ namespace BlackMisc
|
||||
|
||||
switch (strategy)
|
||||
{
|
||||
case PickFirst: return f;
|
||||
case PickByOrder: return o;
|
||||
case PickRandom: return r;
|
||||
case PickFirst: return f;
|
||||
case PickByOrder: return o;
|
||||
case PickRandom: return r;
|
||||
default: break;
|
||||
}
|
||||
|
||||
@@ -178,15 +183,18 @@ namespace BlackMisc
|
||||
|
||||
CAircraftMatcherSetup::MatchingMode CAircraftMatcherSetup::matchingMode(
|
||||
bool byModelString, bool byIcaoDataAircraft1st, bool byIcaoDataAirline1st, bool byFamily, bool byLivery, bool byCombinedType,
|
||||
bool byMilitary, bool byVtol,
|
||||
bool scoreIgnoreZeros, bool scorePreferColorLiveries)
|
||||
{
|
||||
MatchingMode mode = byModelString ? ByModelString : ModeNone;
|
||||
if (byIcaoDataAircraft1st) { mode |= ByIcaoOrderAircraftFirst; }
|
||||
if (byIcaoDataAirline1st) { mode |= ByIcaoOrderAirlineFirst; }
|
||||
if (byFamily) { mode |= ByFamily; }
|
||||
if (byLivery) { mode |= ByLivery; }
|
||||
if (byCombinedType) { mode |= ByCombinedType; }
|
||||
if (scoreIgnoreZeros) { mode |= ScoreIgnoreZeros; }
|
||||
if (byIcaoDataAircraft1st) { mode |= ByIcaoOrderAircraftFirst; }
|
||||
if (byIcaoDataAirline1st) { mode |= ByIcaoOrderAirlineFirst; }
|
||||
if (byFamily) { mode |= ByFamily; }
|
||||
if (byLivery) { mode |= ByLivery; }
|
||||
if (byCombinedType) { mode |= ByCombinedType; }
|
||||
if (byMilitary) { mode |= ByMilitary; }
|
||||
if (byVtol) { mode |= ByVtol; }
|
||||
if (scoreIgnoreZeros) { mode |= ScoreIgnoreZeros; }
|
||||
if (scorePreferColorLiveries) { mode |= ScorePreferColorLiveries; }
|
||||
return mode;
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ namespace BlackMisc
|
||||
enum MatchingAlgorithm
|
||||
{
|
||||
MatchingScoreBased,
|
||||
MatchingStepwiseReducePlusScoreBased,
|
||||
MatchingStepwiseReduce
|
||||
};
|
||||
|
||||
@@ -39,16 +40,20 @@ namespace BlackMisc
|
||||
ByFamily = 1 << 2,
|
||||
ByLivery = 1 << 3,
|
||||
ByCombinedType = 1 << 4,
|
||||
ByIcaoOrderAircraftFirst = (1 << 5) | ByIcaoData,
|
||||
ByIcaoOrderAirlineFirst = (1 << 6) | ByIcaoData,
|
||||
ByManufacturer = 1 << 5,
|
||||
ByMilitary = 1 << 6,
|
||||
ByVtol = 1 << 7,
|
||||
ByIcaoOrderAircraftFirst = (1 << 8) | ByIcaoData,
|
||||
ByIcaoOrderAirlineFirst = (1 << 9) | ByIcaoData,
|
||||
// --- score based matching ---
|
||||
ScoreIgnoreZeros = 1 << 7, //!< zero scores are ignored
|
||||
ScorePreferColorLiveries = 1 << 8, //!< prefer color liveries
|
||||
ScoreIgnoreZeros = 1 << 10, //!< zero scores are ignored
|
||||
ScorePreferColorLiveries = 1 << 11, //!< prefer color liveries
|
||||
// --- others ---
|
||||
ModeNone = 0,
|
||||
ModeScoreDefault = ScoreIgnoreZeros | ScorePreferColorLiveries,
|
||||
ModeDefaultScore = ByIcaoOrderAircraftFirst | ByModelString | ByCombinedType | ModeScoreDefault,
|
||||
ModeDefaultReduce = ByModelString | ByFamily | ByLivery | ByCombinedType | ByIcaoOrderAircraftFirst
|
||||
ModeByFLags = ByMilitary | ByVtol,
|
||||
ModeDefaultScore = ScoreIgnoreZeros | ScorePreferColorLiveries,
|
||||
ModeDefaultReduce = ModeByFLags | ByModelString | ByFamily | ByManufacturer | ByCombinedType | ByIcaoOrderAircraftFirst | ByLivery,
|
||||
ModeDefaultReducePlusScore = ModeByFLags | ByModelString | ByFamily | ByManufacturer | ByCombinedType | ByIcaoOrderAircraftFirst | ModeDefaultScore,
|
||||
};
|
||||
Q_DECLARE_FLAGS(MatchingMode, MatchingModeFlag)
|
||||
|
||||
@@ -129,13 +134,13 @@ namespace BlackMisc
|
||||
static const QString &strategyToString(PickSimilarStrategy strategy);
|
||||
|
||||
//! Mode by flags
|
||||
static MatchingMode matchingMode(
|
||||
bool byModelString, bool byIcaoDataAircraft1st, bool byIcaoDataAirline1st, bool byFamily, bool byLivery, bool byCombinedType,
|
||||
bool scoreIgnoreZeros, bool scorePreferColorLiveries);
|
||||
static MatchingMode matchingMode(bool byModelString, bool byIcaoDataAircraft1st, bool byIcaoDataAirline1st,
|
||||
bool byFamily, bool byLivery, bool byCombinedType, bool byMilitary, bool byVtol,
|
||||
bool scoreIgnoreZeros, bool scorePreferColorLiveries);
|
||||
|
||||
private:
|
||||
int m_algorithm = static_cast<int>(MatchingScoreBased);
|
||||
int m_mode = static_cast<int>(ModeDefaultScore);
|
||||
int m_algorithm = static_cast<int>(MatchingStepwiseReducePlusScoreBased);
|
||||
int m_mode = static_cast<int>(ModeDefaultReducePlusScore);
|
||||
int m_strategy = static_cast<int>(PickByOrder);
|
||||
|
||||
BLACK_METACLASS(
|
||||
|
||||
Reference in New Issue
Block a user