mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-26 02:35:38 +08:00
Ref T773, use correct transfer, avoid continously transferring because of wrong coordinates
* do not use own situation as reference for ground plane, but original coordinates of ground elv. position * some functions renamed
This commit is contained in:
committed by
Mat Sutcliffe
parent
08186e6559
commit
acd5ee5a3c
@@ -1387,9 +1387,10 @@ namespace BlackCore
|
|||||||
|
|
||||||
if (!canLikelySkipNearGround)
|
if (!canLikelySkipNearGround)
|
||||||
{
|
{
|
||||||
|
const CLength dpt = correctedSituation.getDistancePerTime(100, CElevationPlane::singlePointRadius());
|
||||||
const CAircraftSituationList situationsBeforeStoring = this->remoteAircraftSituations(callsign);
|
const CAircraftSituationList situationsBeforeStoring = this->remoteAircraftSituations(callsign);
|
||||||
const CAircraftSituation situationWithElvBeforeStoring = situationsBeforeStoring.findClosestElevationWithinRange(correctedSituation, correctedSituation.getDistancePerTime(100, CElevationPlane::singlePointRadius()));
|
const CAircraftSituation situationWithElvBeforeStoring = situationsBeforeStoring.findClosestElevationWithinRange(correctedSituation, dpt);
|
||||||
if (!situationWithElvBeforeStoring.getGroundElevation().isNull())
|
if (situationWithElvBeforeStoring.transferGroundElevationFromMe(correctedSituation, dpt))
|
||||||
{
|
{
|
||||||
// from nearby situations of own aircraft, data was transferred above
|
// from nearby situations of own aircraft, data was transferred above
|
||||||
// we use transfer first as it is slightly faster as cache
|
// we use transfer first as it is slightly faster as cache
|
||||||
@@ -1433,7 +1434,8 @@ namespace BlackCore
|
|||||||
if (!averagePlane.isNull())
|
if (!averagePlane.isNull())
|
||||||
{
|
{
|
||||||
correctedSituation.setGroundElevation(averagePlane, CAircraftSituation::Average);
|
correctedSituation.setGroundElevation(averagePlane, CAircraftSituation::Average);
|
||||||
if (fromNonMoving) { m_foundInNonMovingAircraft++; } else { m_foundInElevationsOnGnd++; }
|
if (fromNonMoving) { m_foundInNonMovingAircraft++; }
|
||||||
|
else { m_foundInElevationsOnGnd++; }
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -219,7 +219,7 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
// same positions, we can use existing elevation
|
// same positions, we can use existing elevation
|
||||||
// means we were not moving between old an new
|
// means we were not moving between old an new
|
||||||
situationToPreset.transferGroundElevation(oldSituation);
|
situationToPreset.transferGroundElevationToMe(oldSituation, true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -230,7 +230,7 @@ namespace BlackMisc
|
|||||||
if (oldSituation.hasGroundElevation())
|
if (oldSituation.hasGroundElevation())
|
||||||
{
|
{
|
||||||
// almost same positions, we can use existing elevation
|
// almost same positions, we can use existing elevation
|
||||||
situationToPreset.transferGroundElevation(oldSituation);
|
situationToPreset.transferGroundElevationToMe(oldSituation, true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -297,23 +297,23 @@ namespace BlackMisc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CAircraftSituation::extrapolateElevation(CAircraftSituation &newSituation, const CAircraftSituation &oldSituation, const CAircraftSituation &olderSituation, const CAircraftSituationChange &oldChange)
|
bool CAircraftSituation::extrapolateElevation(CAircraftSituation &situationToBeUpdated, const CAircraftSituation &oldSituation, const CAircraftSituation &olderSituation, const CAircraftSituationChange &oldChange)
|
||||||
{
|
{
|
||||||
if (newSituation.hasGroundElevation()) { return false; }
|
if (situationToBeUpdated.hasGroundElevation()) { return false; }
|
||||||
|
|
||||||
// if acceptable transfer
|
// if acceptable transfer
|
||||||
if (oldSituation.transferGroundElevationFromThis(newSituation)) { return true; }
|
if (oldSituation.transferGroundElevationFromMe(situationToBeUpdated)) { return true; }
|
||||||
if (oldSituation.isNull() || olderSituation.isNull()) { return false; }
|
if (oldSituation.isNull() || olderSituation.isNull()) { return false; }
|
||||||
|
|
||||||
if (oldChange.isNull()) { return false; }
|
if (oldChange.isNull()) { return false; }
|
||||||
if (oldChange.isConstOnGround() && oldChange.hasAltitudeDevWithinAllowedRange() && oldChange.hasElevationDevWithinAllowedRange())
|
if (oldChange.isConstOnGround() && oldChange.hasAltitudeDevWithinAllowedRange() && oldChange.hasElevationDevWithinAllowedRange())
|
||||||
{
|
{
|
||||||
// we have almost const altitudes and elevations
|
// we have almost const altitudes and elevations
|
||||||
const double deltaAltFt = qAbs(newSituation.getAltitude().value(CLengthUnit::ft()) - olderSituation.getAltitude().value(CLengthUnit::ft()));
|
const double deltaAltFt = qAbs(situationToBeUpdated.getAltitude().value(CLengthUnit::ft()) - olderSituation.getAltitude().value(CLengthUnit::ft()));
|
||||||
if (deltaAltFt <= CAircraftSituationChange::allowedAltitudeDeviation().value(CLengthUnit::ft()))
|
if (deltaAltFt <= CAircraftSituationChange::allowedAltitudeDeviation().value(CLengthUnit::ft()))
|
||||||
{
|
{
|
||||||
// the current alt is also not much different
|
// the current alt is also not much different
|
||||||
newSituation.setGroundElevation(oldSituation.getGroundElevation(), Extrapolated);
|
situationToBeUpdated.setGroundElevation(oldSituation.getGroundElevation(), Extrapolated);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -712,6 +712,12 @@ namespace BlackMisc
|
|||||||
return this->onGroundAsString() % u' ' % this->getOnGroundDetailsAsString();
|
return this->onGroundAsString() % u' ' % this->getOnGroundDetailsAsString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CLength CAircraftSituation::getGroundElevationDistance() const
|
||||||
|
{
|
||||||
|
// returns NULL if elevation is N/A
|
||||||
|
return this->getGroundElevationPlane().calculateGreatCircleDistance(*this);
|
||||||
|
}
|
||||||
|
|
||||||
CAircraftSituation::GndElevationInfo CAircraftSituation::getGroundElevationInfo() const
|
CAircraftSituation::GndElevationInfo CAircraftSituation::getGroundElevationInfo() const
|
||||||
{
|
{
|
||||||
if (!this->hasGroundElevation()) { return NoElevationInfo; }
|
if (!this->hasGroundElevation()) { return NoElevationInfo; }
|
||||||
@@ -749,17 +755,20 @@ namespace BlackMisc
|
|||||||
return transferable;
|
return transferable;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CAircraftSituation::transferGroundElevationFromThis(CAircraftSituation &transferToSituation, const CLength &radius) const
|
bool CAircraftSituation::transferGroundElevationFromMe(CAircraftSituation &transferToSituation, const CLength &radius) const
|
||||||
{
|
{
|
||||||
if (!this->canTransferGroundElevation(transferToSituation, radius)) { return false; }
|
return transferToSituation.transferGroundElevationToMe(*this, radius, true);
|
||||||
transferToSituation.transferGroundElevation(*this);
|
|
||||||
Q_ASSERT_X(!transferToSituation.getGroundElevationRadius().isNull(), Q_FUNC_INFO, "null radius");
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAircraftSituation::transferGroundElevation(const CAircraftSituation &fromSituation)
|
bool CAircraftSituation::transferGroundElevationToMe(const CAircraftSituation &fromSituation, const CLength &radius, bool transferred)
|
||||||
{
|
{
|
||||||
this->setGroundElevation(fromSituation.getGroundElevation(), fromSituation.getGroundElevationInfo(), true);
|
if (!fromSituation.canTransferGroundElevation(*this, radius)) { return false; }
|
||||||
|
return this->setGroundElevation(fromSituation.getGroundElevationPlane(), fromSituation.getGroundElevationInfo(), transferred);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CAircraftSituation::transferGroundElevationToMe(const CAircraftSituation &fromSituation, bool transferred)
|
||||||
|
{
|
||||||
|
return this->setGroundElevation(fromSituation.getGroundElevationPlane(), fromSituation.getGroundElevationInfo(), transferred);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CAircraftSituation::presetGroundElevation(const CAircraftSituation &oldSituation, const CAircraftSituation &newSituation, const CAircraftSituationChange &change)
|
bool CAircraftSituation::presetGroundElevation(const CAircraftSituation &oldSituation, const CAircraftSituation &newSituation, const CAircraftSituationChange &change)
|
||||||
@@ -811,8 +820,9 @@ namespace BlackMisc
|
|||||||
return this->getOnGroundDetails() == CAircraftSituation::InFromParts || this->getOnGroundDetails() == CAircraftSituation::InFromNetwork;
|
return this->getOnGroundDetails() == CAircraftSituation::InFromParts || this->getOnGroundDetails() == CAircraftSituation::InFromNetwork;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAircraftSituation::setGroundElevation(const CAltitude &altitude, GndElevationInfo info, bool transferred)
|
bool CAircraftSituation::setGroundElevation(const CAltitude &altitude, GndElevationInfo info, bool transferred)
|
||||||
{
|
{
|
||||||
|
bool set = false;
|
||||||
if (altitude.isNull())
|
if (altitude.isNull())
|
||||||
{
|
{
|
||||||
m_groundElevationPlane = CElevationPlane::null();
|
m_groundElevationPlane = CElevationPlane::null();
|
||||||
@@ -826,11 +836,14 @@ namespace BlackMisc
|
|||||||
m_isElvInfoTransferred = transferred;
|
m_isElvInfoTransferred = transferred;
|
||||||
m_groundElevationPlane.setGeodeticHeight(altitude.switchedUnit(this->getAltitudeUnit()));
|
m_groundElevationPlane.setGeodeticHeight(altitude.switchedUnit(this->getAltitudeUnit()));
|
||||||
this->setGroundElevationInfo(info);
|
this->setGroundElevationInfo(info);
|
||||||
|
set = true;
|
||||||
}
|
}
|
||||||
|
return set;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAircraftSituation::setGroundElevation(const CElevationPlane &elevationPlane, GndElevationInfo info, bool transferred)
|
bool CAircraftSituation::setGroundElevation(const CElevationPlane &elevationPlane, GndElevationInfo info, bool transferred)
|
||||||
{
|
{
|
||||||
|
bool set = false;
|
||||||
if (elevationPlane.isNull())
|
if (elevationPlane.isNull())
|
||||||
{
|
{
|
||||||
m_groundElevationPlane = CElevationPlane::null();
|
m_groundElevationPlane = CElevationPlane::null();
|
||||||
@@ -845,7 +858,9 @@ namespace BlackMisc
|
|||||||
this->setGroundElevationInfo(info);
|
this->setGroundElevationInfo(info);
|
||||||
Q_ASSERT_X(!m_groundElevationPlane.getRadius().isNull(), Q_FUNC_INFO, "Null radius");
|
Q_ASSERT_X(!m_groundElevationPlane.getRadius().isNull(), Q_FUNC_INFO, "Null radius");
|
||||||
m_groundElevationPlane.switchUnit(this->getAltitudeOrDefaultUnit()); // we use ft as internal unit, no "must" but simplification
|
m_groundElevationPlane.switchUnit(this->getAltitudeOrDefaultUnit()); // we use ft as internal unit, no "must" but simplification
|
||||||
|
set = true;
|
||||||
}
|
}
|
||||||
|
return set;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CAircraftSituation::setGroundElevationChecked(const CElevationPlane &elevationPlane, GndElevationInfo info, bool transferred)
|
bool CAircraftSituation::setGroundElevationChecked(const CElevationPlane &elevationPlane, GndElevationInfo info, bool transferred)
|
||||||
|
|||||||
@@ -280,6 +280,9 @@ namespace BlackMisc
|
|||||||
//! Elevation of the ground directly beneath
|
//! Elevation of the ground directly beneath
|
||||||
const Geo::CElevationPlane &getGroundElevationPlane() const { return m_groundElevationPlane; }
|
const Geo::CElevationPlane &getGroundElevationPlane() const { return m_groundElevationPlane; }
|
||||||
|
|
||||||
|
//! Distance of coordinates of situation to coordinates of elevation plane
|
||||||
|
PhysicalQuantities::CLength getGroundElevationDistance() const;
|
||||||
|
|
||||||
//! How did we get gnd.elevation?
|
//! How did we get gnd.elevation?
|
||||||
GndElevationInfo getGroundElevationInfo() const;
|
GndElevationInfo getGroundElevationInfo() const;
|
||||||
|
|
||||||
@@ -302,10 +305,13 @@ namespace BlackMisc
|
|||||||
//! \remark "transfer" can be used, if the positions are known, "preset" if they are still unknown
|
//! \remark "transfer" can be used, if the positions are known, "preset" if they are still unknown
|
||||||
//! \sa CAircraftSituation::interpolateGroundElevation
|
//! \sa CAircraftSituation::interpolateGroundElevation
|
||||||
//! \sa CAircraftSituation::interpolateElevation
|
//! \sa CAircraftSituation::interpolateElevation
|
||||||
bool transferGroundElevationFromThis(CAircraftSituation &transferToSituation, const PhysicalQuantities::CLength &radius = Geo::CElevationPlane::singlePointRadius()) const;
|
bool transferGroundElevationFromMe(CAircraftSituation &transferToSituation, const PhysicalQuantities::CLength &radius = Geo::CElevationPlane::singlePointRadius()) const;
|
||||||
|
|
||||||
//! Transfer ground elevation from given situation
|
//! Transfer ground elevation from given situation (to me)
|
||||||
void transferGroundElevation(const CAircraftSituation &fromSituation);
|
bool transferGroundElevationToMe(const CAircraftSituation &fromSituation, const PhysicalQuantities::CLength &radius, bool transferred);
|
||||||
|
|
||||||
|
//! Transfer ground elevation from given situation (to me)
|
||||||
|
bool transferGroundElevationToMe(const CAircraftSituation &fromSituation, bool transferred);
|
||||||
|
|
||||||
//! Preset "this" elevation from the two adjacent positions
|
//! Preset "this" elevation from the two adjacent positions
|
||||||
//! \remark it is not required that the position of "this" is already known
|
//! \remark it is not required that the position of "this" is already known
|
||||||
@@ -314,8 +320,8 @@ namespace BlackMisc
|
|||||||
//! \sa CAircraftSituation::interpolateElevation
|
//! \sa CAircraftSituation::interpolateElevation
|
||||||
bool presetGroundElevation(const Aviation::CAircraftSituation &oldSituation, const Aviation::CAircraftSituation &newSituation, const CAircraftSituationChange &change);
|
bool presetGroundElevation(const Aviation::CAircraftSituation &oldSituation, const Aviation::CAircraftSituation &newSituation, const CAircraftSituationChange &change);
|
||||||
|
|
||||||
//! Set "this" elevation from older situations.
|
//! Set "my" elevation from older situations.
|
||||||
//! \remark this is a future value
|
//! \remark this object normally is a future value
|
||||||
//! \sa CAircraftSituation::transferGroundElevation
|
//! \sa CAircraftSituation::transferGroundElevation
|
||||||
//! \sa CAircraftSituation::interpolateElevation
|
//! \sa CAircraftSituation::interpolateElevation
|
||||||
bool extrapolateElevation(const Aviation::CAircraftSituation &oldSituation, const Aviation::CAircraftSituation &olderSituation, const CAircraftSituationChange &change);
|
bool extrapolateElevation(const Aviation::CAircraftSituation &oldSituation, const Aviation::CAircraftSituation &olderSituation, const CAircraftSituationChange &change);
|
||||||
@@ -339,10 +345,10 @@ namespace BlackMisc
|
|||||||
bool hasInboundGroundDetails() const;
|
bool hasInboundGroundDetails() const;
|
||||||
|
|
||||||
//! Elevation of the ground directly beneath at the given situation
|
//! Elevation of the ground directly beneath at the given situation
|
||||||
void setGroundElevation(const Aviation::CAltitude &altitude, GndElevationInfo info, bool transferred = false);
|
bool setGroundElevation(const Aviation::CAltitude &altitude, GndElevationInfo info, bool transferred = false);
|
||||||
|
|
||||||
//! Elevation of the ground directly beneath
|
//! Elevation of the ground directly beneath
|
||||||
void setGroundElevation(const Geo::CElevationPlane &elevationPlane, GndElevationInfo info, bool transferred = false);
|
bool setGroundElevation(const Geo::CElevationPlane &elevationPlane, GndElevationInfo info, bool transferred = false);
|
||||||
|
|
||||||
//! Set elevation of the ground directly beneath, but checked
|
//! Set elevation of the ground directly beneath, but checked
|
||||||
//! \remark override if better
|
//! \remark override if better
|
||||||
@@ -542,7 +548,7 @@ namespace BlackMisc
|
|||||||
}
|
}
|
||||||
//! @}
|
//! @}
|
||||||
|
|
||||||
//! Preset the ground elevation based on info we already have
|
//! Preset the ground elevation based on info we already have, either by transfer or elevation
|
||||||
//! \remark either sets a gnd. elevation or sets it to null
|
//! \remark either sets a gnd. elevation or sets it to null
|
||||||
//! \remark situationToPreset position is unknown
|
//! \remark situationToPreset position is unknown
|
||||||
//! \remark situationToPreset needs to be between oldSituation and newSituation
|
//! \remark situationToPreset needs to be between oldSituation and newSituation
|
||||||
@@ -550,9 +556,9 @@ namespace BlackMisc
|
|||||||
static bool presetGroundElevation(CAircraftSituation &situationToPreset, const CAircraftSituation &oldSituation, const CAircraftSituation &newSituation, const CAircraftSituationChange &change);
|
static bool presetGroundElevation(CAircraftSituation &situationToPreset, const CAircraftSituation &oldSituation, const CAircraftSituation &newSituation, const CAircraftSituationChange &change);
|
||||||
|
|
||||||
//! Extrapolated between the 2 situations for situation
|
//! Extrapolated between the 2 situations for situation
|
||||||
//! \remark situation is not between oldSituation and olderSituation
|
//! \remark normally used if situationToBeUpdated is not between oldSituation and olderSituation (that would be interpolation)
|
||||||
//! \remark NULL if there are no two elevations
|
//! \return false if there are no two elevations, there is already an elevation, or no extrapolation is possible (too much deviation)
|
||||||
static bool extrapolateElevation(CAircraftSituation &newSituation, const CAircraftSituation &oldSituation, const CAircraftSituation &olderSituation, const CAircraftSituationChange &oldChange);
|
static bool extrapolateElevation(CAircraftSituation &situationToBeUpdated, const CAircraftSituation &oldSituation, const CAircraftSituation &olderSituation, const CAircraftSituationChange &oldChange);
|
||||||
|
|
||||||
//! Interpolate between the 2 situations for situation
|
//! Interpolate between the 2 situations for situation
|
||||||
//! \remark NULL if there are no two elevations or threshold MaxDeltaElevationFt is exceeded
|
//! \remark NULL if there are no two elevations or threshold MaxDeltaElevationFt is exceeded
|
||||||
|
|||||||
@@ -400,14 +400,19 @@ namespace BlackMisc
|
|||||||
|
|
||||||
CAircraftSituation CAircraftSituationList::findClosestElevationWithinRange(const ICoordinateGeodetic &coordinate, const CLength &range) const
|
CAircraftSituation CAircraftSituationList::findClosestElevationWithinRange(const ICoordinateGeodetic &coordinate, const CLength &range) const
|
||||||
{
|
{
|
||||||
CLength r = range.isNull() || range < CElevationPlane::singlePointRadius() ? CElevationPlane::singlePointRadius() : range;
|
const CLength r = range.isNull() || range < CElevationPlane::singlePointRadius() ? CElevationPlane::singlePointRadius() : range;
|
||||||
CAircraftSituation situationWithElevation = CAircraftSituation::null();
|
CAircraftSituation situationWithElevation = CAircraftSituation::null();
|
||||||
|
|
||||||
CLength bestDistance = CLength::null();
|
CLength bestDistance = CLength::null();
|
||||||
for (const CAircraftSituation &s : *this)
|
for (const CAircraftSituation &s : *this)
|
||||||
{
|
{
|
||||||
if (!s.hasGroundElevation()) { continue; }
|
if (!s.hasGroundElevation()) { continue; }
|
||||||
const CLength distance = s.calculateGreatCircleDistance(coordinate);
|
|
||||||
|
// we need to calculate distance to coordinates of the plane
|
||||||
|
// not the situation using the coordinate
|
||||||
|
// const CLength distance = s.calculateGreatCircleDistance(coordinate);
|
||||||
|
const CLength distance = s.getGroundElevationPlane().calculateGreatCircleDistance(coordinate);
|
||||||
|
|
||||||
if (distance > r) { continue; }
|
if (distance > r) { continue; }
|
||||||
if (bestDistance.isNull() || bestDistance > distance)
|
if (bestDistance.isNull() || bestDistance > distance)
|
||||||
{
|
{
|
||||||
@@ -601,7 +606,7 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
const CAircraftSituation &oldSituation = (*this)[i];
|
const CAircraftSituation &oldSituation = (*this)[i];
|
||||||
CAircraftSituation &newSituation = (*this)[i - 1];
|
CAircraftSituation &newSituation = (*this)[i - 1];
|
||||||
if (oldSituation.transferGroundElevationFromThis(newSituation, radius)) { c++; }
|
if (oldSituation.transferGroundElevationFromMe(newSituation, radius)) { c++; }
|
||||||
}
|
}
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -233,7 +233,7 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
// we still have no elevation
|
// we still have no elevation
|
||||||
const CLength radius = currentSituation.getDistancePerTime250ms(CElevationPlane::singlePointRadius());
|
const CLength radius = currentSituation.getDistancePerTime250ms(CElevationPlane::singlePointRadius());
|
||||||
if (!m_lastSituation.transferGroundElevationFromThis(currentSituation, radius))
|
if (!m_lastSituation.transferGroundElevationFromMe(currentSituation, radius))
|
||||||
{
|
{
|
||||||
if (currentSituation.canLikelySkipNearGroundInterpolation())
|
if (currentSituation.canLikelySkipNearGroundInterpolation())
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user