refs #577, better data consolidation/auto find by also using IATA/family

also refs #586, refs #580, refs #576
This commit is contained in:
Klaus Basan
2016-01-30 02:32:38 +01:00
parent c715e93c58
commit ca21c03ef4
3 changed files with 36 additions and 24 deletions

View File

@@ -135,29 +135,40 @@ namespace BlackMisc
if (c.hasCompleteData()) { return c; }
}
CAircraftIcaoCodeList codes(*this); // copy and reduce
CAircraftIcaoCodeList codes;
if (icaoPattern.hasKnownDesignator())
{
const QString d(icaoPattern.getDesignator());
codes = codes.findByDesignator(d);
codes = this->findByDesignator(d);
// we have an exact match
// we have one exact match
if (codes.size() == 1) { return codes.front(); }
if (codes.isEmpty())
{
// now we search if the ICAO designator is
// actually an IATA code
codes = codes.findByIataCode(d);
codes = this->findByIataCode(d);
// we have one exact match
if (codes.size() == 1) { return codes.front(); }
if (codes.isEmpty())
{
// still empty, bye
return icaoPattern;
// still empty, try to find by family
codes = this->findByFamily(d);
// we have one exact match
if (codes.size() == 1) { return codes.front(); }
// still empty, hopeless
if (codes.isEmpty()) { return icaoPattern; }
// continue here, we have more than one code and
// will try to further reduce
}
}
codes.sortByRank();
// intentionally continue here
}
// further reduce by manufacturer
@@ -166,7 +177,6 @@ namespace BlackMisc
const QString m(icaoPattern.getManufacturer());
codes = codes.findByManufacturer(m);
if (codes.size() == 1) { return codes.front(); }
if (codes.isEmpty()) { return icaoPattern; }
// intentionally continue here
}

View File

@@ -62,7 +62,7 @@ namespace BlackMisc
//! Find by designator, then best match by rank
CAircraftIcaoCode findFirstByDesignatorAndRank(const QString &designator) const;
//! Best selection by given pattern
//! Best selection by given pattern, also searches IATA and family information
CAircraftIcaoCode smartAircraftIcaoSelector(const CAircraftIcaoCode &icaoPattern) const;
//! Sort by rank