diff --git a/src/blackmisc/aviation/aircrafticaocode.cpp b/src/blackmisc/aviation/aircrafticaocode.cpp index fcc149f3b..d46fea161 100644 --- a/src/blackmisc/aviation/aircrafticaocode.cpp +++ b/src/blackmisc/aviation/aircrafticaocode.cpp @@ -703,6 +703,12 @@ namespace BlackMisc return i; } + const CAircraftIcaoCode &CAircraftIcaoCode::unassignedIcao() + { + static const CAircraftIcaoCode z(getUnassignedDesignator()); + return z; + } + const QStringList &CAircraftIcaoCode::getSpecialDesignators() { static const QStringList s({ "ZZZZ", "SHIP", "BALL", "GLID", "ULAC", "GYRO", "UHEL" }); diff --git a/src/blackmisc/aviation/aircrafticaocode.h b/src/blackmisc/aviation/aircrafticaocode.h index e81d2fe0f..bcd9c514b 100644 --- a/src/blackmisc/aviation/aircrafticaocode.h +++ b/src/blackmisc/aviation/aircrafticaocode.h @@ -309,6 +309,9 @@ namespace BlackMisc //! The unassigned designator ("ZZZZ") static const QString &getUnassignedDesignator(); + //! Unassigned ICAO code "ZZZZ" + static const CAircraftIcaoCode &unassignedIcao(); + //! List of the special designators ("ZZZZ", "UHEL", ...) static const QStringList &getSpecialDesignators(); diff --git a/src/blackmisc/aviation/aircraftparts.cpp b/src/blackmisc/aviation/aircraftparts.cpp index 5e75c0903..a87c46a47 100644 --- a/src/blackmisc/aviation/aircraftparts.cpp +++ b/src/blackmisc/aviation/aircraftparts.cpp @@ -66,35 +66,50 @@ namespace BlackMisc CAircraftEngineList engines; parts.setLights(CAircraftLights::guessedLights(situation)); + // set some reasonable defaults const bool onGround = situation.isOnGround(); - if (onGround) + parts.setGearDown(onGround); + engines.initEngines(engineNumber, !onGround || situation.isMoving()); + + if (situation.hasGroundElevation()) { - parts.setGearDown(true); - engines.initEngines(engineNumber, situation.isMoving()); + const double aGroundFt = situation.getHeightAboveGround().value(CLengthUnit::ft()); + if (aGroundFt < 1000) + { + parts.setGearDown(true); + parts.setFlapsPercent(25); + } + else if (aGroundFt < 2000) + { + parts.setGearDown(true); + parts.setFlapsPercent(10); + } + else + { + parts.setGearDown(false); + parts.setFlapsPercent(0); + } } else { - parts.setGearDown(false); - engines.initEngines(engineNumber, true); - if (vtol) + if (!situation.hasInboundGroundInformation()) { - - } - else if (situation.hasGroundElevation()) - { - const double aGroundFt = situation.getHeightAboveGround().value(CLengthUnit::ft()); - if (aGroundFt < 1000) + // the ground flag is not reliable and we have no ground elevation + if (situation.getOnGroundDetails() == CAircraftSituation::OnGroundByGuessing) { - parts.setGearDown(true); - parts.setFlapsPercent(25); + // should be OK } - else if (aGroundFt < 2000) + else { - parts.setGearDown(true); - parts.setFlapsPercent(10); + if (!vtol) + { + const bool gearDown = situation.getGroundSpeed().value(CSpeedUnit::kts()) < 60; + parts.setGearDown(gearDown); + } } } } + parts.setEngines(engines); parts.setPartsDetails(GuessedParts); return parts; diff --git a/src/blackmisc/simulation/aircraftmodel.cpp b/src/blackmisc/simulation/aircraftmodel.cpp index 7dbfba8d3..7605cda81 100644 --- a/src/blackmisc/simulation/aircraftmodel.cpp +++ b/src/blackmisc/simulation/aircraftmodel.cpp @@ -129,7 +129,7 @@ namespace BlackMisc { static const QString html = "Model: %1 changed: %2%3Simulator: %4 Mode: %5 Distributor: %6%7Aircraft ICAO: %8%9Livery: %10"; return html - .arg(this->getModelStringAndDbKey(), this->getFormattedUtcTimestampYmdhms() , separator, + .arg(this->getModelStringAndDbKey(), this->getFormattedUtcTimestampYmdhms(), separator, this->getSimulator().toQString(true), this->getModelModeAsString(), this->getDistributor().getIdAndDescription(), separator, this->getAircraftIcaoCode().asHtmlSummary(), separator) .arg(this->getLivery().asHtmlSummary(" ")).replace(" ", " "); @@ -692,19 +692,30 @@ namespace BlackMisc return !changed; } - QString CAircraftModel::modelTypeToString(CAircraftModel::ModelType type) + const QString &CAircraftModel::modelTypeToString(CAircraftModel::ModelType type) { + static const QString queried("queried"); + static const QString matching("matching"); + static const QString db("database"); + static const QString def("map.default"); + static const QString ownSim("own simulator"); + static const QString set("set"); + static const QString fsinn("FSInn"); + static const QString probe("probe"); + static const QString unknown("unknown"); + switch (type) { - case TypeQueriedFromNetwork: return "queried"; - case TypeModelMatching: return "matching"; - case TypeDatabaseEntry: return "database"; - case TypeModelMatchingDefaultModel: return "map. default"; - case TypeOwnSimulatorModel: return "own simulator"; - case TypeManuallySet: return "set"; - case TypeFSInnData: return "FSInn"; + case TypeQueriedFromNetwork: return queried; + case TypeModelMatching: return matching; + case TypeDatabaseEntry: return db; + case TypeModelMatchingDefaultModel: return def; + case TypeOwnSimulatorModel: return ownSim; + case TypeManuallySet: return set; + case TypeFSInnData: return fsinn; + case TypeTerrainProbe: return probe; case TypeUnknown: - default: return "unknown"; + default: return unknown; } } diff --git a/src/blackmisc/simulation/aircraftmodel.h b/src/blackmisc/simulation/aircraftmodel.h index 5db6b20ad..a80ea2c0b 100644 --- a/src/blackmisc/simulation/aircraftmodel.h +++ b/src/blackmisc/simulation/aircraftmodel.h @@ -65,7 +65,8 @@ namespace BlackMisc TypeDatabaseEntry, //!< used along with mapping definition TypeManuallySet, //!< manually set, e.g. from GUI TypeOwnSimulatorModel, //!< represents own simulator model - TypeVPilotRuleBased //!< based on a vPilot rule + TypeVPilotRuleBased, //!< based on a vPilot rule + TypeTerrainProbe //!< peudo aircraft used for terrain probing (FSX) }; //! Mode, decides if a model is supposed to be used in the model set for model matching @@ -263,7 +264,7 @@ namespace BlackMisc ModelType getModelType() const { return m_modelType; } //! Model type - QString getModelTypeAsString() const { return modelTypeToString(getModelType()); } + const QString &getModelTypeAsString() const { return modelTypeToString(getModelType()); } //! Set type void setModelType(ModelType type) { m_modelType = type; } @@ -404,7 +405,7 @@ namespace BlackMisc // ---------------- end file related functions -------------- //! Model type - static QString modelTypeToString(ModelType type); + static const QString &modelTypeToString(ModelType type); //! File path used for DB static QString normalizeFileNameForDb(const QString &filePath); @@ -430,16 +431,16 @@ namespace BlackMisc Aviation::CCallsign m_callsign; //!< aircraft's callsign if any Aviation::CAircraftIcaoCode m_aircraftIcao; //!< ICAO code if available Aviation::CLivery m_livery; //!< livery information - CSimulatorInfo m_simulator; //!< model for given simulator - CDistributor m_distributor; //!< who designed or distributed the model - QString m_modelString; //!< Simulator model key, unique - QString m_name; //!< Model name - QString m_description; //!< descriptive text - QString m_fileName; //!< file name - QString m_iconPath; //!< a file representing the aircraft as icon - qint64 m_fileTimestamp = -1; //!< file timestamp of originating file (if applicable) - ModelType m_modelType = TypeUnknown; //!< model string is coming representing ...? - ModelMode m_modelMode = Include; //!< model mode (include / exclude) + CSimulatorInfo m_simulator; //!< model for given simulator + CDistributor m_distributor; //!< who designed or distributed the model + QString m_modelString; //!< Simulator model key, unique + QString m_name; //!< Model name + QString m_description; //!< descriptive text + QString m_fileName; //!< file name + QString m_iconPath; //!< a file representing the aircraft as icon + qint64 m_fileTimestamp = -1; //!< file timestamp of originating file (if applicable) + ModelType m_modelType = TypeUnknown; //!< model string is coming representing ...? + ModelMode m_modelMode = Include; //!< model mode (include / exclude) BLACK_METACLASS( CAircraftModel,