mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-04 17:30:12 +08:00
Ref T778, added/improved removeElevationValues, cleanElevationValues
This commit is contained in:
committed by
Mat Sutcliffe
parent
919b6e9515
commit
1821b6e6c5
@@ -515,54 +515,52 @@ namespace BlackMisc
|
|||||||
m_elvFound = m_elvMissed = 0;
|
m_elvFound = m_elvMissed = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ISimulationEnvironmentProvider::cleanElevationValues(const CAircraftSituation &reference, const CLength &range, bool forced)
|
int ISimulationEnvironmentProvider::removeElevationValues(const CAircraftSituation &reference, const CLength &removeRange)
|
||||||
{
|
{
|
||||||
if (reference.isNull() || range.isNull()) { return false; }
|
QWriteLocker l(&m_lockElvCoordinates);
|
||||||
const CLength r = minRange(range);
|
const int r = m_elvCoordinatesGnd.removeInsideRange(reference, removeRange);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
CCoordinateGeodeticList elvs;
|
bool ISimulationEnvironmentProvider::cleanElevationValues(const CAircraftSituation &reference, const CLength &keptRange, bool forced)
|
||||||
CCoordinateGeodeticList cleanedElvs;
|
{
|
||||||
|
if (reference.isNull() || keptRange.isNull()) { return false; }
|
||||||
|
const CLength r = minRange(keptRange);
|
||||||
|
|
||||||
|
CCoordinateGeodeticList cleanedKeptElvs;
|
||||||
bool maxReached = false;
|
bool maxReached = false;
|
||||||
bool cleaned = false;
|
bool cleaned = false;
|
||||||
|
|
||||||
{
|
{
|
||||||
QReadLocker l(&m_lockElvCoordinates);
|
QReadLocker l(&m_lockElvCoordinates);
|
||||||
elvs = m_elvCoordinates;
|
cleanedKeptElvs = m_elvCoordinates;
|
||||||
maxReached = m_elvCoordinates.size() >= m_maxElevations;
|
maxReached = m_elvCoordinates.size() >= m_maxElevations;
|
||||||
}
|
}
|
||||||
if (!elvs.isEmpty() && (forced || maxReached))
|
if (!cleanedKeptElvs.isEmpty() && (forced || maxReached))
|
||||||
{
|
{
|
||||||
for (const CAircraftSituation &s : elvs)
|
const int removed = cleanedKeptElvs.removeOutsideRange(reference, r);
|
||||||
{
|
if (removed > 0)
|
||||||
if (s.isWithinRange(reference, r)) { cleanedElvs.push_back(s); }
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cleanedElvs.size() < elvs.size())
|
|
||||||
{
|
{
|
||||||
cleaned = true;
|
cleaned = true;
|
||||||
QWriteLocker l(&m_lockElvCoordinates);
|
QWriteLocker l(&m_lockElvCoordinates);
|
||||||
m_elvCoordinates = cleanedElvs;
|
m_elvCoordinates = cleanedKeptElvs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanedElvs.clear();
|
cleanedKeptElvs.clear();
|
||||||
{
|
{
|
||||||
QReadLocker l(&m_lockElvCoordinates);
|
QReadLocker l(&m_lockElvCoordinates);
|
||||||
elvs = m_elvCoordinatesGnd;
|
cleanedKeptElvs = m_elvCoordinatesGnd;
|
||||||
maxReached = m_elvCoordinatesGnd.size() >= m_maxElevationsGnd;
|
maxReached = m_elvCoordinatesGnd.size() >= m_maxElevationsGnd;
|
||||||
}
|
}
|
||||||
if (!elvs.isEmpty() && (forced || maxReached))
|
if (!cleanedKeptElvs.isEmpty() && (forced || maxReached))
|
||||||
{
|
{
|
||||||
for (const CAircraftSituation &s : elvs)
|
const int removed = cleanedKeptElvs.removeOutsideRange(reference, r);
|
||||||
{
|
if (removed > 0)
|
||||||
if (s.isWithinRange(reference, r)) { cleanedElvs.push_back(s); }
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cleanedElvs.size() < elvs.size())
|
|
||||||
{
|
{
|
||||||
cleaned = true;
|
cleaned = true;
|
||||||
QWriteLocker l(&m_lockElvCoordinates);
|
QWriteLocker l(&m_lockElvCoordinates);
|
||||||
m_elvCoordinatesGnd = cleanedElvs;
|
m_elvCoordinatesGnd = cleanedKeptElvs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -146,9 +146,15 @@ namespace BlackMisc
|
|||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
void resetSimulationEnvironmentStatistics();
|
void resetSimulationEnvironmentStatistics();
|
||||||
|
|
||||||
//! Average elevation of "on ground" cached values
|
//! Remove cached elevations outside range,
|
||||||
|
//! "forced" cleans always, otherwise only if max.values are reached
|
||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
bool cleanElevationValues(const Aviation::CAircraftSituation &reference, const PhysicalQuantities::CLength &range, bool forced = false);
|
bool cleanElevationValues(const Aviation::CAircraftSituation &reference, const PhysicalQuantities::CLength &keptRange, bool forced = false);
|
||||||
|
|
||||||
|
//! Remove cached elevations inside range,
|
||||||
|
//! \remark this removes inside range, cleanElevationValues outside the range
|
||||||
|
//! \threadsafe
|
||||||
|
int removeElevationValues(const Aviation::CAircraftSituation &reference, const PhysicalQuantities::CLength &removeRange);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//! Ctor
|
//! Ctor
|
||||||
|
|||||||
Reference in New Issue
Block a user