mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-26 18:55:38 +08:00
Ref T773, cache ground elevations for "on ground" planes separately
Rational: * Those values represent taxiways and runways * we cache those longer and keep more It is much more likely we need/can use these values
This commit is contained in:
committed by
Mat Sutcliffe
parent
b128d40342
commit
33b1e26460
@@ -7,11 +7,15 @@
|
||||
*/
|
||||
|
||||
#include "coordinategeodeticlist.h"
|
||||
#include "math/mathutils.h"
|
||||
|
||||
#include <QJsonValue>
|
||||
#include <QString>
|
||||
#include <QtGlobal>
|
||||
|
||||
using namespace BlackMisc::Math;
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Geo
|
||||
@@ -22,5 +26,30 @@ namespace BlackMisc
|
||||
CCoordinateGeodeticList::CCoordinateGeodeticList(const CSequence<CCoordinateGeodetic> &other) :
|
||||
CSequence<CCoordinateGeodetic>(other)
|
||||
{ }
|
||||
|
||||
CElevationPlane CCoordinateGeodeticList::averageGeodeticHeight(const CCoordinateGeodetic &reference, const CLength &range, const CLength &maxDeviation, int minValues) const
|
||||
{
|
||||
if (this->size() < minValues) { return CElevationPlane::null(); } // no change to succeed
|
||||
|
||||
QList<double> valuesInFt;
|
||||
int count = 0;
|
||||
for (const CCoordinateGeodetic &coordinate : *this)
|
||||
{
|
||||
if (!coordinate.hasMSLGeodeticHeight()) { continue; }
|
||||
if (!coordinate.isWithinRange(reference, range)) { continue; }
|
||||
const double elvFt = coordinate.geodeticHeight().value(CLengthUnit::ft());
|
||||
valuesInFt.push_back(elvFt);
|
||||
count++;
|
||||
if (count > 5 && valuesInFt.size() > 3 * minValues) { break; }
|
||||
}
|
||||
|
||||
if (count < minValues) { return CElevationPlane::null(); }
|
||||
|
||||
const double MaxDevFt = maxDeviation.value(CLengthUnit::ft());
|
||||
const QPair<double, double> elvStdDevMean = CMathUtils::standardDeviationAndMean(valuesInFt);
|
||||
if (elvStdDevMean.first > MaxDevFt) { return CElevationPlane::null(); }
|
||||
return CElevationPlane(reference, elvStdDevMean.second, CElevationPlane::singlePointRadius());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -11,8 +11,10 @@
|
||||
#ifndef BLACKMISC_GEO_COORDINATEGEODETICLIST_H
|
||||
#define BLACKMISC_GEO_COORDINATEGEODETICLIST_H
|
||||
|
||||
#include "elevationplane.h"
|
||||
#include "coordinategeodetic.h"
|
||||
#include "geoobjectlist.h"
|
||||
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
#include "blackmisc/collection.h"
|
||||
#include "blackmisc/json.h"
|
||||
@@ -43,6 +45,9 @@ namespace BlackMisc
|
||||
|
||||
//! Construct from a base class object.
|
||||
CCoordinateGeodeticList(const CSequence<CCoordinateGeodetic> &other);
|
||||
|
||||
//! Average height within range and having an height
|
||||
CElevationPlane averageGeodeticHeight(const CCoordinateGeodetic &reference, const PhysicalQuantities::CLength &range, const PhysicalQuantities::CLength &maxDeviation = PhysicalQuantities::CLength(1.0, PhysicalQuantities::CLengthUnit::m()), int minValues = 3) const;
|
||||
};
|
||||
} //namespace
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user