mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 09:15:34 +08:00
Category matcher using full model set and also reduced models
* Based on FS report here: https://swift-project.slack.com/archives/G96QTUBEG/p1559071176005100 * Return reduced models and not full set if no category matching applies
This commit is contained in:
committed by
Mat Sutcliffe
parent
50412aa0d1
commit
c33dfce481
@@ -1008,7 +1008,7 @@ namespace BlackCore
|
|||||||
|
|
||||||
if (setup.useCategoryMatching())
|
if (setup.useCategoryMatching())
|
||||||
{
|
{
|
||||||
matchedModels = categoryMatcher.reduceByCategories(modelSet, setup, remoteAircraft, reduced, whatToLog, log);
|
matchedModels = categoryMatcher.reduceByCategories(matchedModels, modelSet, setup, remoteAircraft, reduced, whatToLog, log);
|
||||||
// ?? break here ??
|
// ?? break here ??
|
||||||
}
|
}
|
||||||
else if (reduceLog)
|
else if (reduceLog)
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ namespace BlackMisc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CAircraftModelList CCategoryMatcher::reduceByCategories(const CAircraftModelList &modelSet, const CAircraftMatcherSetup &setup, const CSimulatedAircraft &remoteAircraft, bool &reduced, bool shortLog, CStatusMessageList *log) const
|
CAircraftModelList CCategoryMatcher::reduceByCategories(const CAircraftModelList &alreadyMatchedModels, const CAircraftModelList &modelSet, const CAircraftMatcherSetup &setup, const CSimulatedAircraft &remoteAircraft, bool &reduced, bool shortLog, CStatusMessageList *log) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(shortLog);
|
Q_UNUSED(shortLog);
|
||||||
|
|
||||||
@@ -67,23 +67,25 @@ namespace BlackMisc
|
|||||||
if (!setup.useCategoryMatching())
|
if (!setup.useCategoryMatching())
|
||||||
{
|
{
|
||||||
if (log) { CMatchingUtils::addLogDetailsToList(log, remoteAircraft, QStringLiteral("Disabled category matching"), getLogCategories()); }
|
if (log) { CMatchingUtils::addLogDetailsToList(log, remoteAircraft, QStringLiteral("Disabled category matching"), getLogCategories()); }
|
||||||
return modelSet;
|
return alreadyMatchedModels;
|
||||||
}
|
}
|
||||||
if (m_all.isEmpty())
|
if (m_all.isEmpty())
|
||||||
{
|
{
|
||||||
|
// no categories?
|
||||||
CMatchingUtils::addLogDetailsToList(log, remoteAircraft, QStringLiteral("Disabled category matching"), getLogCategories());
|
CMatchingUtils::addLogDetailsToList(log, remoteAircraft, QStringLiteral("Disabled category matching"), getLogCategories());
|
||||||
return modelSet;
|
return alreadyMatchedModels;
|
||||||
}
|
}
|
||||||
if (!remoteAircraft.getAircraftIcaoCode().hasCategory())
|
if (!remoteAircraft.getAircraftIcaoCode().hasCategory())
|
||||||
{
|
{
|
||||||
CMatchingUtils::addLogDetailsToList(log, remoteAircraft, QStringLiteral("No category in remote aircraft"), getLogCategories());
|
CMatchingUtils::addLogDetailsToList(log, remoteAircraft, QStringLiteral("No category in remote aircraft"), getLogCategories());
|
||||||
return modelSet;
|
return alreadyMatchedModels;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (log) { CMatchingUtils::addLogDetailsToList(log, remoteAircraft, QStringLiteral("Remote aircraft has category '%1'").arg(remoteAircraft.getAircraftIcaoCode().getCategory().getNameDbKey()), getLogCategories()); }
|
if (log) { CMatchingUtils::addLogDetailsToList(log, remoteAircraft, QStringLiteral("Remote aircraft has category '%1'").arg(remoteAircraft.getAircraftIcaoCode().getCategory().getNameDbKey()), getLogCategories()); }
|
||||||
if (!m_gliders.isEmpty() && setup.getMatchingMode().testFlag(CAircraftMatcherSetup::ByCategoryGlider) && this->isGlider(remoteAircraft.getAircraftIcaoCode()))
|
if (!m_gliders.isEmpty() && setup.getMatchingMode().testFlag(CAircraftMatcherSetup::ByCategoryGlider) && this->isGlider(remoteAircraft.getAircraftIcaoCode()))
|
||||||
{
|
{
|
||||||
// we have a glider
|
// we have a glider
|
||||||
|
// and we search in the whole set: this is a special case
|
||||||
const int firstLevel = this->gliderFirstLevel();
|
const int firstLevel = this->gliderFirstLevel();
|
||||||
const CAircraftModelList gliders = modelSet.findByCategoryFirstLevel(firstLevel); // all gliders from model set
|
const CAircraftModelList gliders = modelSet.findByCategoryFirstLevel(firstLevel); // all gliders from model set
|
||||||
if (!gliders.isEmpty())
|
if (!gliders.isEmpty())
|
||||||
@@ -131,10 +133,10 @@ namespace BlackMisc
|
|||||||
static const QStringList substituteIcaos({ "UHEL", "GLID", "ULAC" }); // maybe also GYRO
|
static const QStringList substituteIcaos({ "UHEL", "GLID", "ULAC" }); // maybe also GYRO
|
||||||
static const QString substituteIcaosStr = substituteIcaos.join(", ");
|
static const QString substituteIcaosStr = substituteIcaos.join(", ");
|
||||||
|
|
||||||
CAircraftModelList substitutes = modelSet.findByDesignatorsOrFamilyWithColorLivery(substituteIcaos);
|
CAircraftModelList substitutes = alreadyMatchedModels.findByDesignatorsOrFamilyWithColorLivery(substituteIcaos);
|
||||||
if (substitutes.isEmpty())
|
if (substitutes.isEmpty())
|
||||||
{
|
{
|
||||||
substitutes = modelSet.findByCombinedType(QStringLiteral("L1P"));
|
substitutes = alreadyMatchedModels.findByCombinedType(QStringLiteral("L1P"));
|
||||||
if (!substitutes.isEmpty())
|
if (!substitutes.isEmpty())
|
||||||
{
|
{
|
||||||
reduced = true;
|
reduced = true;
|
||||||
@@ -151,7 +153,7 @@ namespace BlackMisc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return modelSet;
|
return alreadyMatchedModels;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CCategoryMatcher::isGlider(const CAircraftIcaoCode &icao) const
|
bool CCategoryMatcher::isGlider(const CAircraftIcaoCode &icao) const
|
||||||
|
|||||||
@@ -44,7 +44,9 @@ namespace BlackMisc
|
|||||||
//! @}
|
//! @}
|
||||||
|
|
||||||
//! Reduce by categories
|
//! Reduce by categories
|
||||||
CAircraftModelList reduceByCategories(const CAircraftModelList &modelSet, const CAircraftMatcherSetup &setup, const CSimulatedAircraft &remoteAircraft, bool &reduced, bool shortLog, CStatusMessageList *log = nullptr) const;
|
CAircraftModelList reduceByCategories(
|
||||||
|
const CAircraftModelList &alreadyMatchedModels, const CAircraftModelList &modelSet,
|
||||||
|
const CAircraftMatcherSetup &setup, const CSimulatedAircraft &remoteAircraft, bool &reduced, bool shortLog, CStatusMessageList *log = nullptr) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//! Glider?
|
//! Glider?
|
||||||
|
|||||||
Reference in New Issue
Block a user