mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 20:15:35 +08:00
Ref T275, defined the pairs we are using
This commit is contained in:
@@ -88,6 +88,18 @@ namespace BlackMisc
|
||||
return !m_guessedSceneryDeviation.isNull();
|
||||
}
|
||||
|
||||
bool CAircraftSituationChange::hasElevationDevWithinAllowedRange() const
|
||||
{
|
||||
if (m_elvStdDev.isNull()) { return false; }
|
||||
return m_elvStdDev < allowedAltitudeDeviation();
|
||||
}
|
||||
|
||||
bool CAircraftSituationChange::hasAltitudeDevWithinAllowedRange() const
|
||||
{
|
||||
if (m_altStdDev.isNull()) { return false; }
|
||||
return m_altStdDev < allowedAltitudeDeviation();
|
||||
}
|
||||
|
||||
QString CAircraftSituationChange::convertToQString(bool i18n) const
|
||||
{
|
||||
Q_UNUSED(i18n);
|
||||
@@ -270,6 +282,12 @@ namespace BlackMisc
|
||||
return noInfo;
|
||||
}
|
||||
|
||||
const CLength &CAircraftSituationChange::allowedAltitudeDeviation()
|
||||
{
|
||||
static const CLength allowedStdDev(3, CLengthUnit::ft());
|
||||
return allowedStdDev;
|
||||
}
|
||||
|
||||
void CAircraftSituationChange::setSceneryDeviation(const CLength &deviation, const CLength &cg, CAircraftSituationChange::GuessedSceneryDeviation hint)
|
||||
{
|
||||
m_guessedSceneryDeviation = deviation;
|
||||
|
||||
@@ -16,13 +16,13 @@
|
||||
#include "altitude.h"
|
||||
#include "blackmisc/pq/angle.h"
|
||||
#include "blackmisc/pq/speed.h"
|
||||
#include "blackmisc/pair.h"
|
||||
#include "blackmisc/metaclass.h"
|
||||
#include "blackmisc/timestampbased.h"
|
||||
#include "blackmisc/valueobject.h"
|
||||
#include "blackmisc/variant.h"
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
#include "blackmisc/propertyindex.h"
|
||||
#include <QPair>
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
@@ -119,22 +119,22 @@ namespace BlackMisc
|
||||
|
||||
//! Ground distance (AGL) if it can be calculated, otherwise NULL
|
||||
//! \note distance is without CG, so on ground it can also be used to calculate
|
||||
QPair<PhysicalQuantities::CLength, PhysicalQuantities::CLength> getGroundDistanceStdDevAndMean() const { return QPair<PhysicalQuantities::CLength, PhysicalQuantities::CLength>(m_gndDistStdDev, m_gndDistMean); }
|
||||
PhysicalQuantities::CLengthPair getGroundDistanceStdDevAndMean() const { return PhysicalQuantities::CLengthPair(m_gndDistStdDev, m_gndDistMean); }
|
||||
|
||||
//! \copydoc BlackMisc::Aviation::CAircraftSituationList::altitudeStandardDeviationAndMean
|
||||
QPair<CAltitude, CAltitude> getAltitudeStdDevAndMean() const { return QPair<CAltitude, CAltitude>(m_altStdDev, m_altMean); }
|
||||
CAltitudePair getAltitudeStdDevAndMean() const { return CAltitudePair(m_altStdDev, m_altMean); }
|
||||
|
||||
//! \copydoc BlackMisc::Aviation::CAircraftSituationList::elevationStandardDeviationAndMean
|
||||
QPair<CAltitude, CAltitude> getElevationStdDevAndMean() const { return QPair<CAltitude, CAltitude>(m_elvStdDev, m_elvMean); }
|
||||
CAltitudePair getElevationStdDevAndMean() const { return CAltitudePair(m_elvStdDev, m_elvMean); }
|
||||
|
||||
//! \copydoc BlackMisc::Aviation::CAircraftSituationList::groundSpeedStandardDeviationAndMean
|
||||
QPair<PhysicalQuantities::CSpeed, PhysicalQuantities::CSpeed> getGroundSpeedStdDevAndMean() const { return QPair<PhysicalQuantities::CSpeed, PhysicalQuantities::CSpeed>(m_gsStdDev, m_gsMean); }
|
||||
PhysicalQuantities::CSpeedPair getGroundSpeedStdDevAndMean() const { return PhysicalQuantities::CSpeedPair(m_gsStdDev, m_gsMean); }
|
||||
|
||||
//! \copydoc BlackMisc::Aviation::CAircraftSituationList::pitchStandardDeviationAndMean
|
||||
QPair<PhysicalQuantities::CAngle, PhysicalQuantities::CAngle> getPitchStdDevAndMean() const { return QPair<PhysicalQuantities::CAngle, PhysicalQuantities::CAngle>(m_pitchStdDev, m_pitchMean); }
|
||||
PhysicalQuantities::CAnglePair getPitchStdDevAndMean() const { return PhysicalQuantities::CAnglePair(m_pitchStdDev, m_pitchMean); }
|
||||
|
||||
//! \copydoc BlackMisc::Aviation::CAircraftSituationList::minMaxGroundDistance
|
||||
QPair<PhysicalQuantities::CLength, PhysicalQuantities::CLength> getMinMaxGroundDistance() const { return QPair<PhysicalQuantities::CLength, PhysicalQuantities::CLength>(m_minGroundDistance, m_maxGroundDistance); }
|
||||
PhysicalQuantities::CLengthPair getMinMaxGroundDistance() const { return PhysicalQuantities::CLengthPair(m_minGroundDistance, m_maxGroundDistance); }
|
||||
|
||||
//! Scnenery deviation (if it can be calculated, otherwise PhysicalQuantities::CLength::null)
|
||||
//! This is without CG, so substract CG to get deviation
|
||||
@@ -152,6 +152,12 @@ namespace BlackMisc
|
||||
//! Scenery deviation available?
|
||||
bool hasSceneryDeviation() const;
|
||||
|
||||
//! Elevation within CAircraftSituation::allowedAltitudeDeviation range
|
||||
bool hasElevationDevWithinAllowedRange() const;
|
||||
|
||||
//! Altitude within CAircraftSituation::allowedAltitudeDeviation range
|
||||
bool hasAltitudeDevWithinAllowedRange() const;
|
||||
|
||||
//! \copydoc Mixin::String::toQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
@@ -173,6 +179,9 @@ namespace BlackMisc
|
||||
//! The enum as string
|
||||
static const QString &guessedSceneryDeviationToString(GuessedSceneryDeviation hint);
|
||||
|
||||
//! Within this range deviation is so small we consider values "almost constant"
|
||||
static const PhysicalQuantities::CLength &allowedAltitudeDeviation();
|
||||
|
||||
private:
|
||||
//! Scenery deviation hint
|
||||
void setSceneryDeviationHint(GuessedSceneryDeviation hint) { m_guessedSceneryDeviationHint = static_cast<int>(hint); }
|
||||
|
||||
@@ -452,36 +452,36 @@ namespace BlackMisc
|
||||
return values;
|
||||
}
|
||||
|
||||
QPair<CSpeed, CSpeed> CAircraftSituationList::groundSpeedStandardDeviationAndMean() const
|
||||
CSpeedPair CAircraftSituationList::groundSpeedStandardDeviationAndMean() const
|
||||
{
|
||||
const QList<double> gsValues = this->groundSpeedValues(CSpeedUnit::kts());
|
||||
if (gsValues.size() != this->size()) { return QPair<CSpeed, CSpeed>(CSpeed::null(), CSpeed::null()); }
|
||||
const QPair<double, double> gsKts = CMathUtils::standardDeviationAndMean(gsValues);
|
||||
return QPair<CSpeed, CSpeed>(CSpeed(gsKts.first, CSpeedUnit::kts()), CSpeed(gsKts.second, CSpeedUnit::kts()));
|
||||
return CSpeedPair(CSpeed(gsKts.first, CSpeedUnit::kts()), CSpeed(gsKts.second, CSpeedUnit::kts()));
|
||||
}
|
||||
|
||||
QPair<CAngle, CAngle> CAircraftSituationList::pitchStandardDeviationAndMean() const
|
||||
CAnglePair CAircraftSituationList::pitchStandardDeviationAndMean() const
|
||||
{
|
||||
const QList<double> pitchValues = this->pitchValues(CAngleUnit::deg());
|
||||
if (pitchValues.size() != this->size()) { return QPair<CAngle, CAngle>(CAngle::null(), CAngle::null()); }
|
||||
const QPair<double, double> pitchDeg = CMathUtils::standardDeviationAndMean(pitchValues);
|
||||
return QPair<CAngle, CAngle>(CAngle(pitchDeg.first, CAngleUnit::deg()), CAngle(pitchDeg.second, CAngleUnit::deg()));
|
||||
return CAnglePair(CAngle(pitchDeg.first, CAngleUnit::deg()), CAngle(pitchDeg.second, CAngleUnit::deg()));
|
||||
}
|
||||
|
||||
QPair<CAltitude, CAltitude> CAircraftSituationList::elevationStandardDeviationAndMean() const
|
||||
CAltitudePair CAircraftSituationList::elevationStandardDeviationAndMean() const
|
||||
{
|
||||
const QList<double> elvValues = this->elevationValues(CAltitude::defaultUnit());
|
||||
if (elvValues.size() != this->size()) { return QPair<CAltitude, CAltitude>(CAltitude::null(), CAltitude::null()); }
|
||||
if (elvValues.size() != this->size()) { return CAltitudePair(CAltitude::null(), CAltitude::null()); }
|
||||
const QPair<double, double> elvFt = CMathUtils::standardDeviationAndMean(elvValues);
|
||||
return QPair<CAltitude, CAltitude>(CAltitude(elvFt.first, CAltitude::MeanSeaLevel, CAltitude::defaultUnit()), CAltitude(elvFt.second, CAltitude::MeanSeaLevel, CAltitude::defaultUnit()));
|
||||
return CAltitudePair(CAltitude(elvFt.first, CAltitude::MeanSeaLevel, CAltitude::defaultUnit()), CAltitude(elvFt.second, CAltitude::MeanSeaLevel, CAltitude::defaultUnit()));
|
||||
}
|
||||
|
||||
QPair<CAltitude, CAltitude> CAircraftSituationList::altitudeStandardDeviationAndMean() const
|
||||
CAltitudePair CAircraftSituationList::altitudeStandardDeviationAndMean() const
|
||||
{
|
||||
const QList<double> altValues = this->altitudeValues(CAltitude::defaultUnit());
|
||||
if (altValues.size() != this->size()) { return QPair<CAltitude, CAltitude>(CAltitude::null(), CAltitude::null()); }
|
||||
if (altValues.size() != this->size()) { return CAltitudePair(CAltitude::null(), CAltitude::null()); }
|
||||
const QPair<double, double> altFt = CMathUtils::standardDeviationAndMean(altValues);
|
||||
return QPair<CAltitude, CAltitude>(CAltitude(altFt.first, CAltitude::MeanSeaLevel, CAltitude::defaultUnit()), CAltitude(altFt.second, CAltitude::MeanSeaLevel, CAltitude::defaultUnit()));
|
||||
return CAltitudePair(CAltitude(altFt.first, CAltitude::MeanSeaLevel, CAltitude::defaultUnit()), CAltitude(altFt.second, CAltitude::MeanSeaLevel, CAltitude::defaultUnit()));
|
||||
}
|
||||
|
||||
QPair<CLength, CLength> CAircraftSituationList::minMaxGroundDistance(const CLength &cg) const
|
||||
@@ -494,13 +494,13 @@ namespace BlackMisc
|
||||
return QPair<CLength, CLength>(CLength(gndDistMin, CAltitude::defaultUnit()), CLength(gndDistMax, CAltitude::defaultUnit()));
|
||||
}
|
||||
|
||||
QPair<CAltitude, CAltitude> CAircraftSituationList::altitudeAglStandardDeviationAndMean() const
|
||||
CAltitudePair CAircraftSituationList::altitudeAglStandardDeviationAndMean() const
|
||||
{
|
||||
const QList<double> altValues = this->altitudeValues(CLengthUnit::ft());
|
||||
if (altValues.size() != this->size()) { return QPair<CAltitude, CAltitude>(CAltitude::null(), CAltitude::null()); }
|
||||
if (altValues.size() != this->size()) { return CAltitudePair(CAltitude::null(), CAltitude::null()); }
|
||||
|
||||
const QList<double> elvValues = this->elevationValues(CLengthUnit::ft());
|
||||
if (elvValues.size() != this->size()) { return QPair<CAltitude, CAltitude>(CAltitude::null(), CAltitude::null()); }
|
||||
if (elvValues.size() != this->size()) { return CAltitudePair(CAltitude::null(), CAltitude::null()); }
|
||||
|
||||
QList<double> altElvDeltas;
|
||||
for (int i = 0; i < altValues.size(); i++)
|
||||
@@ -509,7 +509,8 @@ namespace BlackMisc
|
||||
altElvDeltas.push_back(delta);
|
||||
}
|
||||
const QPair<double, double> deltaFt = CMathUtils::standardDeviationAndMean(altElvDeltas);
|
||||
return QPair<CAltitude, CAltitude>(CAltitude(deltaFt.first, CAltitude::MeanSeaLevel, CAltitude::defaultUnit()), CAltitude(deltaFt.second, CAltitude::MeanSeaLevel, CAltitude::defaultUnit()));
|
||||
return CAltitudePair(CAltitude(deltaFt.first, CAltitude::MeanSeaLevel, CAltitude::defaultUnit()), CAltitude(deltaFt.second, CAltitude::MeanSeaLevel, CAltitude::defaultUnit()));
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "blackmisc/collection.h"
|
||||
#include "blackmisc/sequence.h"
|
||||
#include "blackmisc/timestampobjectlist.h"
|
||||
#include "blackmisc/pair.h"
|
||||
#include "blackmisc/variant.h"
|
||||
|
||||
#include <QMetaType>
|
||||
@@ -164,23 +165,23 @@ namespace BlackMisc
|
||||
QList<double> groundDistanceValues(const PhysicalQuantities::CLengthUnit &unit, const PhysicalQuantities::CLength &cg) const;
|
||||
|
||||
//! Pitch angles standard deviation and mean
|
||||
QPair<PhysicalQuantities::CAngle, PhysicalQuantities::CAngle> pitchStandardDeviationAndMean() const;
|
||||
PhysicalQuantities::CAnglePair pitchStandardDeviationAndMean() const;
|
||||
|
||||
//! Ground speed standard deviation and mean
|
||||
QPair<PhysicalQuantities::CSpeed, PhysicalQuantities::CSpeed> groundSpeedStandardDeviationAndMean() const;
|
||||
PhysicalQuantities::CSpeedPair groundSpeedStandardDeviationAndMean() const;
|
||||
|
||||
//! Elevation standard deviation and mean
|
||||
QPair<CAltitude, CAltitude> elevationStandardDeviationAndMean() const;
|
||||
CAltitudePair elevationStandardDeviationAndMean() const;
|
||||
|
||||
//! Elevation standard deviation and mean
|
||||
QPair<CAltitude, CAltitude> altitudeStandardDeviationAndMean() const;
|
||||
|
||||
//! Min. and max. ground distance
|
||||
QPair<PhysicalQuantities::CLength, PhysicalQuantities::CLength> minMaxGroundDistance(const PhysicalQuantities::CLength &cg) const;
|
||||
CAltitudePair altitudeStandardDeviationAndMean() const;
|
||||
|
||||
//! Elevation standard deviation and mean
|
||||
//! \note distance is without CG, so on ground it can also be used to calculate
|
||||
QPair<CAltitude, CAltitude> altitudeAglStandardDeviationAndMean() const;
|
||||
CAltitudePair altitudeAglStandardDeviationAndMean() const;
|
||||
|
||||
//! Min. and max. ground distance
|
||||
PhysicalQuantities::CLengthPair minMaxGroundDistance(const PhysicalQuantities::CLength &cg) const;
|
||||
};
|
||||
|
||||
//! Situation per callsign
|
||||
|
||||
43
src/blackmisc/pair.h
Normal file
43
src/blackmisc/pair.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/* Copyright (C) 2018
|
||||
* Swift Project Community / Contributors
|
||||
*
|
||||
* This file is part of Swift Project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKMISC_PAIR_H
|
||||
#define BLACKMISC_PAIR_H
|
||||
|
||||
#include "blackmisc/aviation/altitude.h"
|
||||
#include "blackmisc/pq/angle.h"
|
||||
#include "blackmisc/pq/length.h"
|
||||
#include "blackmisc/pq/speed.h"
|
||||
#include "blackmisc/variant.h"
|
||||
|
||||
#include <QPair>
|
||||
#include <QDBusMetaType>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace PhysicalQuantities
|
||||
{
|
||||
using CAnglePair = QPair<CAngle, CAngle>; //!< Pair of angle
|
||||
using CLengthPair = QPair<CLength, CLength>; //!< Pair of length
|
||||
using CSpeedPair = QPair<CSpeed, CSpeed>; //!< Pair of speed
|
||||
}
|
||||
namespace Aviation
|
||||
{
|
||||
using CAltitudePair = QPair<CAltitude, CAltitude>; //!< Pair of altitude
|
||||
}
|
||||
} // namespace
|
||||
|
||||
Q_DECLARE_METATYPE(BlackMisc::PhysicalQuantities::CAnglePair)
|
||||
Q_DECLARE_METATYPE(BlackMisc::PhysicalQuantities::CLengthPair)
|
||||
Q_DECLARE_METATYPE(BlackMisc::PhysicalQuantities::CSpeedPair)
|
||||
Q_DECLARE_METATYPE(BlackMisc::Aviation::CAltitudePair)
|
||||
|
||||
#endif // guard
|
||||
Reference in New Issue
Block a user