mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-21 04:45:31 +08:00
refs #801, suppport for missing parts in airports/list
This commit is contained in:
@@ -38,6 +38,13 @@ namespace BlackMisc
|
|||||||
m_icao(icao), m_descriptiveName(descriptiveName), m_position(position)
|
m_icao(icao), m_descriptiveName(descriptiveName), m_position(position)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
void CAirport::updateMissingParts(const CAirport &airport)
|
||||||
|
{
|
||||||
|
if (!this->m_country.hasIsoCode() && airport.getCountry().hasIsoCode()) { this->m_country = airport.getCountry(); }
|
||||||
|
if (this->m_descriptiveName.isEmpty()) { this->m_descriptiveName = airport.getDescriptiveName(); }
|
||||||
|
if (this->m_descriptiveName.isEmpty()) { this->m_descriptiveName = airport.getDescriptiveName(); }
|
||||||
|
}
|
||||||
|
|
||||||
QString CAirport::convertToQString(bool i18n) const
|
QString CAirport::convertToQString(bool i18n) const
|
||||||
{
|
{
|
||||||
QString s = i18n ? QCoreApplication::translate("Aviation", "Airport") : "Airport";
|
QString s = i18n ? QCoreApplication::translate("Aviation", "Airport") : "Airport";
|
||||||
|
|||||||
@@ -105,6 +105,9 @@ namespace BlackMisc
|
|||||||
//! Sets the value of \sa isOperating().
|
//! Sets the value of \sa isOperating().
|
||||||
void setOperating(bool operating) { m_operating = operating; }
|
void setOperating(bool operating) { m_operating = operating; }
|
||||||
|
|
||||||
|
//! Update the missing parts in airport
|
||||||
|
void updateMissingParts(const CAirport &airport);
|
||||||
|
|
||||||
//! \copydoc Geo::ICoordinateGeodetic::geodeticHeight
|
//! \copydoc Geo::ICoordinateGeodetic::geodeticHeight
|
||||||
//! \remarks this should be used for elevation as depicted here: http://en.wikipedia.org/wiki/Altitude#mediaviewer/File:Vertical_distances.svg
|
//! \remarks this should be used for elevation as depicted here: http://en.wikipedia.org/wiki/Altitude#mediaviewer/File:Vertical_distances.svg
|
||||||
const BlackMisc::PhysicalQuantities::CLength &geodeticHeight() const override { return this->m_position.geodeticHeight(); }
|
const BlackMisc::PhysicalQuantities::CLength &geodeticHeight() const override { return this->m_position.geodeticHeight(); }
|
||||||
|
|||||||
@@ -32,12 +32,31 @@ namespace BlackMisc
|
|||||||
return this->findBy(&CAirport::getIcao, icao);
|
return this->findBy(&CAirport::getIcao, icao);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CAirportList::containsAirportWithIcaoCode(const CAirportIcaoCode &icao) const
|
||||||
|
{
|
||||||
|
if (icao.isEmpty()) { return false; }
|
||||||
|
return this->contains(&CAirport::getIcao, icao);
|
||||||
|
}
|
||||||
|
|
||||||
void CAirportList::replaceOrAddByIcao(const CAirport &addedOrReplacedAirport)
|
void CAirportList::replaceOrAddByIcao(const CAirport &addedOrReplacedAirport)
|
||||||
{
|
{
|
||||||
if (!addedOrReplacedAirport.hasValidIcaoCode()) return; // ignore invalid airport
|
if (!addedOrReplacedAirport.hasValidIcaoCode()) return; // ignore invalid airport
|
||||||
this->replaceOrAdd(&CAirport::getIcao, addedOrReplacedAirport.getIcao(), addedOrReplacedAirport);
|
this->replaceOrAdd(&CAirport::getIcao, addedOrReplacedAirport.getIcao(), addedOrReplacedAirport);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CAirportList::updateMissingParts(const CAirportList &updateFromList)
|
||||||
|
{
|
||||||
|
if (updateFromList.isEmpty()) { return; }
|
||||||
|
for (CAirport &airport : *this)
|
||||||
|
{
|
||||||
|
const CAirport fromAirport = updateFromList.findFirstByIcao(airport.getIcao());
|
||||||
|
if (fromAirport.hasValidIcaoCode())
|
||||||
|
{
|
||||||
|
airport.updateMissingParts(fromAirport);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CAirport CAirportList::findFirstByIcao(const CAirportIcaoCode &icao, const CAirport &ifNotFound) const
|
CAirport CAirportList::findFirstByIcao(const CAirportIcaoCode &icao, const CAirport &ifNotFound) const
|
||||||
{
|
{
|
||||||
return this->findFirstByOrDefault(&CAirport::getIcao, icao, ifNotFound);
|
return this->findFirstByOrDefault(&CAirport::getIcao, icao, ifNotFound);
|
||||||
|
|||||||
@@ -46,9 +46,15 @@ namespace BlackMisc
|
|||||||
//! Find 0..n airports by ICAO code
|
//! Find 0..n airports by ICAO code
|
||||||
CAirportList findByIcao(const CAirportIcaoCode &icao) const;
|
CAirportList findByIcao(const CAirportIcaoCode &icao) const;
|
||||||
|
|
||||||
|
//! Containing an airport with given ICAO code?
|
||||||
|
bool containsAirportWithIcaoCode(const CAirportIcaoCode &icao) const;
|
||||||
|
|
||||||
//! Replace or add based on same ICAO code
|
//! Replace or add based on same ICAO code
|
||||||
void replaceOrAddByIcao(const CAirport &addedOrReplacedAirport);
|
void replaceOrAddByIcao(const CAirport &addedOrReplacedAirport);
|
||||||
|
|
||||||
|
//! Update this list from the other list
|
||||||
|
void updateMissingParts(const CAirportList &updateFromList);
|
||||||
|
|
||||||
//! Find first station by callsign, if not return given value / default
|
//! Find first station by callsign, if not return given value / default
|
||||||
CAirport findFirstByIcao(const CAirportIcaoCode &icao, const CAirport &ifNotFound = CAirport()) const;
|
CAirport findFirstByIcao(const CAirportIcaoCode &icao, const CAirport &ifNotFound = CAirport()) const;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user