mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 20:15:35 +08:00
Utility functions to improve resolution in auto stash component
This commit is contained in:
@@ -177,6 +177,11 @@ namespace BlackMisc
|
||||
return m_airline.hasValidDesignator();
|
||||
}
|
||||
|
||||
bool CLivery::hasAirlineName() const
|
||||
{
|
||||
return m_airline.hasName();
|
||||
}
|
||||
|
||||
bool CLivery::hasCombinedCode() const
|
||||
{
|
||||
Q_ASSERT_X(!m_combinedCode.startsWith("." + standardLiveryMarker()), Q_FUNC_INFO, "illegal combined code");
|
||||
@@ -412,7 +417,7 @@ namespace BlackMisc
|
||||
// 0..25 based on color distance
|
||||
// 0..10 based on mil.flag
|
||||
// same ICAO at least means 30, max 50
|
||||
score = this->getAirlineIcaoCode().calculateScore(otherLivery.getAirlineIcaoCode(), log) / 2;
|
||||
score = qRound(0.5 * this->getAirlineIcaoCode().calculateScore(otherLivery.getAirlineIcaoCode(), log));
|
||||
score += 25 * colorMultiplier;
|
||||
CMatchingUtils::addLogDetailsToList(log, *this, QString("2 airline liveries, color multiplier %1: %2").arg(colorMultiplier).arg(score));
|
||||
if (this->isMilitary() == otherLivery.isMilitary())
|
||||
|
||||
@@ -155,6 +155,9 @@ namespace BlackMisc
|
||||
//! Airline available?
|
||||
bool hasValidAirlineDesignator() const;
|
||||
|
||||
//! Has airline name?
|
||||
bool hasAirlineName() const;
|
||||
|
||||
//! Livery combined code available?
|
||||
bool hasCombinedCode() const;
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace BlackMisc
|
||||
|
||||
CLivery CLiveryList::findStdLiveryByAirlineIcaoVDesignator(const QString &icao) const
|
||||
{
|
||||
QString icaoDesignator(icao.trimmed().toUpper());
|
||||
const QString icaoDesignator(icao.trimmed().toUpper());
|
||||
if (icaoDesignator.isEmpty()) { return CLivery(); }
|
||||
return this->findFirstByOrDefault([&](const CLivery & livery)
|
||||
{
|
||||
@@ -163,7 +163,7 @@ namespace BlackMisc
|
||||
// by combined code
|
||||
if (liveryPattern.hasCombinedCode())
|
||||
{
|
||||
QString cc(liveryPattern.getCombinedCode());
|
||||
const QString cc(liveryPattern.getCombinedCode());
|
||||
const CLivery l(this->findByCombinedCode(cc));
|
||||
if (l.hasCompleteData()) { return l; }
|
||||
}
|
||||
@@ -174,6 +174,21 @@ namespace BlackMisc
|
||||
const QString icao(liveryPattern.getAirlineIcaoCodeDesignator());
|
||||
const CLivery l(this->findStdLiveryByAirlineIcaoVDesignator(icao));
|
||||
if (l.hasCompleteData()) { return l; }
|
||||
|
||||
// lenient search by assuming that a virtual airline is not annotated by "V"
|
||||
// VHDU not found, but HDU
|
||||
const CLiveryList liveries = this->findByAirlineIcaoDesignator(icao);
|
||||
if (liveries.size() == 1) { return liveries.front(); }
|
||||
if (liveries.size() > 1)
|
||||
{
|
||||
if (liveryPattern.hasAirlineName())
|
||||
{
|
||||
// reduce by name
|
||||
const CLiveryList liveriesByName = liveries.findStdLiveriesBySimplifiedAirlineName(liveryPattern.getAirlineName());
|
||||
if (!liveriesByName.isEmpty()) {return liveriesByName.front(); }
|
||||
}
|
||||
return liveries.front();
|
||||
}
|
||||
}
|
||||
|
||||
// lenient search by name contained (slow)
|
||||
|
||||
@@ -629,7 +629,7 @@ namespace BlackMisc
|
||||
const int icaoScore = this->getAircraftIcaoCode().calculateScore(compareModel.getAircraftIcaoCode(), log);
|
||||
const int liveryScore = this->getLivery().calculateScore(compareModel.getLivery(), preferColorLiveries, log);
|
||||
CMatchingUtils::addLogDetailsToList(log, this->getCallsign(), QString("ICAO score: %1 | livery score: %2").arg(icaoScore).arg(liveryScore));
|
||||
return (icaoScore + liveryScore) / 2;
|
||||
return qRound(0.5 * (icaoScore + liveryScore));
|
||||
}
|
||||
|
||||
CStatusMessageList CAircraftModel::validate(bool withNestedObjects) const
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace BlackMisc
|
||||
TypeModelMatchingDefaultModel, //!< a default model assigned by model matching
|
||||
TypeDatabaseEntry, //!< used along with mapping definition
|
||||
TypeManuallySet, //!< manually set, e.g. from GUI
|
||||
TypeOwnSimulatorModel, //!< represents own simulator model
|
||||
TypeOwnSimulatorModel, //!< represents own simulator model (AI model, model on disk)
|
||||
TypeVPilotRuleBased, //!< based on a vPilot rule
|
||||
TypeTerrainProbe //!< peudo aircraft used for terrain probing (FSX)
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user