mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 21:15:33 +08:00
Ref T236, utility functions to set ground elevation
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
|
||||
#include "blackmisc/aviation/aircraftsituation.h"
|
||||
#include "blackmisc/geo/elevationplane.h"
|
||||
#include "blackmisc/pq/physicalquantity.h"
|
||||
#include "blackmisc/pq/units.h"
|
||||
#include "blackmisc/propertyindex.h"
|
||||
@@ -105,7 +106,7 @@ namespace BlackMisc
|
||||
case IndexLatitude: return this->latitude().propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexLongitude: return this->longitude().propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexAltitude: return this->getAltitude().propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexHeading:return m_heading.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexHeading: return m_heading.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexPitch: return m_pitch.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexBank: return m_bank.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexGroundSpeed: return m_groundSpeed.propertyByIndex(index.copyFrontRemoved());
|
||||
@@ -198,11 +199,21 @@ namespace BlackMisc
|
||||
return !this->getGroundElevation().isNull();
|
||||
}
|
||||
|
||||
void CAircraftSituation::setGroundElevationChecked(const CAltitude &elevation, bool ignoreNullValues, bool overrideExisting)
|
||||
bool CAircraftSituation::setGroundElevationChecked(const CAltitude &elevation, bool ignoreNullValues, bool overrideExisting)
|
||||
{
|
||||
if (ignoreNullValues && elevation.isNull()) { return; }
|
||||
if (!overrideExisting && this->hasGroundElevation()) { return; }
|
||||
if (ignoreNullValues && elevation.isNull()) { return false; }
|
||||
if (!overrideExisting && this->hasGroundElevation()) { return false; }
|
||||
m_groundElevation = elevation;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CAircraftSituation::setGroundElevationChecked(const CElevationPlane &elevationPlane, bool ignoreNullValues, bool overrideExisting)
|
||||
{
|
||||
if (ignoreNullValues && elevationPlane.isNull()) { return false; }
|
||||
if (!overrideExisting && this->hasGroundElevation()) { return false; }
|
||||
if (!elevationPlane.isWithinRange(*this)) { return false; }
|
||||
m_groundElevation = elevationPlane.getAltitude();
|
||||
return true;
|
||||
}
|
||||
|
||||
CLength CAircraftSituation::getHeightAboveGround() const
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Geo { class CElevationPlane; }
|
||||
namespace Aviation
|
||||
{
|
||||
//! Value object encapsulating information of an aircraft's situation
|
||||
@@ -171,7 +172,10 @@ namespace BlackMisc
|
||||
void setGroundElevation(const CAltitude &elevation) { m_groundElevation = elevation; }
|
||||
|
||||
//! Set elevation of the ground directly beneath, but checked
|
||||
void setGroundElevationChecked(const CAltitude &elevation, bool ignoreNullValues = true, bool overrideExisting = true);
|
||||
bool setGroundElevationChecked(const CAltitude &elevation, bool ignoreNullValues = true, bool overrideExisting = true);
|
||||
|
||||
//! Set elevation of the ground directly beneath, but checked
|
||||
bool setGroundElevationChecked(const Geo::CElevationPlane &elevationPlane, bool ignoreNullValues = true, bool overrideExisting = true);
|
||||
|
||||
//! Height above ground.
|
||||
PhysicalQuantities::CLength getHeightAboveGround() const;
|
||||
|
||||
@@ -9,16 +9,17 @@
|
||||
|
||||
#include "blackmisc/aviation/aircraftsituationlist.h"
|
||||
#include "blackmisc/aviation/aircraftsituation.h"
|
||||
#include "blackmisc/geo/elevationplane.h"
|
||||
|
||||
#include <tuple>
|
||||
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
using namespace BlackMisc::Geo;
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Aviation
|
||||
{
|
||||
|
||||
CAircraftSituationList::CAircraftSituationList()
|
||||
{ }
|
||||
|
||||
@@ -30,5 +31,29 @@ namespace BlackMisc
|
||||
CSequence<CAircraftSituation>(il)
|
||||
{ }
|
||||
|
||||
int CAircraftSituationList::setGroundElevationChecked(const CElevationPlane &elevationPlane, bool ignoreNullValues, bool overrideExisting)
|
||||
{
|
||||
if (ignoreNullValues && elevationPlane.isNull()) { return 0; }
|
||||
int c = 0;
|
||||
for (CAircraftSituation &s : *this)
|
||||
{
|
||||
const bool set = s.setGroundElevationChecked(elevationPlane, ignoreNullValues, overrideExisting);
|
||||
if (set) { c++; }
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
int CAircraftSituationList::setGroundElevationChecked(const CElevationPlane &elevationPlane, qint64 newerThan, bool ignoreNullValues, bool overrideExisting)
|
||||
{
|
||||
if (ignoreNullValues && elevationPlane.isNull()) { return 0; }
|
||||
int c = 0;
|
||||
for (CAircraftSituation &s : *this)
|
||||
{
|
||||
if (s.getMSecsSinceEpoch() <= newerThan) { continue; }
|
||||
const bool set = s.setGroundElevationChecked(elevationPlane, ignoreNullValues, overrideExisting);
|
||||
if (set) { c++; }
|
||||
}
|
||||
return c;
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "blackmisc/aviation/aircraftsituation.h"
|
||||
#include "blackmisc/aviation/callsignobjectlist.h"
|
||||
#include "blackmisc/geo/elevationplane.h"
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
#include "blackmisc/collection.h"
|
||||
#include "blackmisc/sequence.h"
|
||||
@@ -24,6 +25,7 @@
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Geo { class CElevationPlane; }
|
||||
namespace Aviation
|
||||
{
|
||||
class CAircraftSituation;
|
||||
@@ -33,8 +35,7 @@ namespace BlackMisc
|
||||
public CSequence<CAircraftSituation>,
|
||||
public ITimestampObjectList<CAircraftSituation, CAircraftSituationList>,
|
||||
public ICallsignObjectList<CAircraftSituation, CAircraftSituationList>,
|
||||
public BlackMisc::Mixin::MetaType<CAircraftSituationList>
|
||||
|
||||
public Mixin::MetaType<CAircraftSituationList>
|
||||
{
|
||||
public:
|
||||
BLACKMISC_DECLARE_USING_MIXIN_METATYPE(CAircraftSituationList)
|
||||
@@ -47,6 +48,12 @@ namespace BlackMisc
|
||||
|
||||
//! Construct from initializer list.
|
||||
CAircraftSituationList(std::initializer_list<CAircraftSituation> il);
|
||||
|
||||
//! Set ground elevation from elevation plane
|
||||
int setGroundElevationChecked(const Geo::CElevationPlane &elevationPlane, bool ignoreNullValues = true, bool overrideExisting = true);
|
||||
|
||||
//! Set ground elevation from elevation plane
|
||||
int setGroundElevationChecked(const Geo::CElevationPlane &elevationPlane, qint64 newerThan, bool ignoreNullValues = true, bool overrideExisting = true);
|
||||
};
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user