Ref T260, changed elevation handling in provider, simulator and FSX common driver

* split functions, added findClosestElevationWithinRangeOrRequest
* obtain elevation ids (separate ids are easier to track)
* also added experimental "physicallyAddAITerrainProbe" (FSX) for the FSX elevation probing
* callback / signal when requested elevation is received (async)
This commit is contained in:
Klaus Basan
2018-04-07 04:41:22 +02:00
committed by Roland Winklmeier
parent dcc348c9d9
commit 6061a61d50
12 changed files with 268 additions and 48 deletions

View File

@@ -91,7 +91,7 @@ namespace BlackMisc
return delta;
}
CElevationPlane ISimulationEnvironmentProvider::findClosestElevationWithinRange(const ICoordinateGeodetic &reference, const PhysicalQuantities::CLength &range, bool autoRequest) const
CElevationPlane ISimulationEnvironmentProvider::findClosestElevationWithinRange(const ICoordinateGeodetic &reference, const PhysicalQuantities::CLength &range) const
{
const CCoordinateGeodetic coordinate = this->getElevationCoordinates().findClosestWithinRange(reference, minRange(range));
const bool found = !coordinate.isNull();
@@ -100,14 +100,24 @@ namespace BlackMisc
if (found)
{
m_elvFound++;
return CElevationPlane(coordinate, reference); // plane with radis = distance to reference
}
else
{
m_elvMissed++;
if (autoRequest) { this->requestElevation(reference); }
return CElevationPlane::null();
}
}
return CElevationPlane(coordinate, reference); // plane with radis = distance to reference
}
CElevationPlane ISimulationEnvironmentProvider::findClosestElevationWithinRangeOrRequest(const ICoordinateGeodetic &reference, const CLength &range, const CCallsign &callsign)
{
const CElevationPlane ep = ISimulationEnvironmentProvider::findClosestElevationWithinRange(reference, range);
if (ep.isNull())
{
this->requestElevation(reference, callsign);
}
return ep;
}
QPair<int, int> ISimulationEnvironmentProvider::getElevationsFoundMissed() const
@@ -196,16 +206,22 @@ namespace BlackMisc
this->clearCGs();
}
CElevationPlane CSimulationEnvironmentAware::findClosestElevationWithinRange(const ICoordinateGeodetic &reference, const PhysicalQuantities::CLength &range, bool autoRequest) const
CElevationPlane CSimulationEnvironmentAware::findClosestElevationWithinRange(const ICoordinateGeodetic &reference, const PhysicalQuantities::CLength &range) const
{
if (!this->hasProvider()) { return CElevationPlane::null(); }
return this->provider()->findClosestElevationWithinRange(reference, range, autoRequest);
return this->provider()->findClosestElevationWithinRange(reference, range);
}
bool CSimulationEnvironmentAware::requestElevation(const ICoordinateGeodetic &reference) const
CElevationPlane CSimulationEnvironmentAware::findClosestElevationWithinRangeOrRequest(const ICoordinateGeodetic &reference, const CLength &range, const CCallsign &callsign)
{
if (!this->hasProvider()) { return CElevationPlane::null(); }
return this->provider()->findClosestElevationWithinRangeOrRequest(reference, range, callsign);
}
bool CSimulationEnvironmentAware::requestElevation(const ICoordinateGeodetic &reference, const CCallsign &callsign)
{
if (!this->hasProvider()) { return false; }
return this->provider()->requestElevation(reference);
return this->provider()->requestElevation(reference, callsign);
}
QPair<int, int> CSimulationEnvironmentAware::getElevationsFoundMissed() const

View File

@@ -38,11 +38,15 @@ namespace BlackMisc
//! Find closest elevation
//! \threadsafe
Geo::CElevationPlane findClosestElevationWithinRange(const Geo::ICoordinateGeodetic &reference, const PhysicalQuantities::CLength &range, bool autoRequest = false) const;
Geo::CElevationPlane findClosestElevationWithinRange(const Geo::ICoordinateGeodetic &reference, const PhysicalQuantities::CLength &range) const;
//! Find closest elevation
//! \threadsafe
Geo::CElevationPlane findClosestElevationWithinRangeOrRequest(const Geo::ICoordinateGeodetic &reference, const PhysicalQuantities::CLength &range, const Aviation::CCallsign &callsign);
//! Request elevation, there is no guaranteed the requested elevation will be available in the provider
//! \threadsafe
virtual bool requestElevation(const Geo::ICoordinateGeodetic &reference) const = 0;
virtual bool requestElevation(const Geo::ICoordinateGeodetic &reference, const Aviation::CCallsign &callsign) = 0;
//! Elevations found/missed statistics
//! \threadsafe
@@ -146,10 +150,13 @@ namespace BlackMisc
void setSimulationEnvironmentProvider(ISimulationEnvironmentProvider *provider) { this->setProvider(provider); }
//! \copydoc ISimulationEnvironmentProvider::findClosestElevationWithinRange
Geo::CElevationPlane findClosestElevationWithinRange(const Geo::ICoordinateGeodetic &reference, const PhysicalQuantities::CLength &range, bool autoRequest = false) const;
Geo::CElevationPlane findClosestElevationWithinRange(const Geo::ICoordinateGeodetic &reference, const PhysicalQuantities::CLength &range) const;
//! \copydoc ISimulationEnvironmentProvider::findClosestElevationWithinRange
bool requestElevation(const Geo::ICoordinateGeodetic &reference) const;
//! \copydoc ISimulationEnvironmentProvider::findClosestElevationWithinRangeOrRequest
Geo::CElevationPlane findClosestElevationWithinRangeOrRequest(const Geo::ICoordinateGeodetic &reference, const PhysicalQuantities::CLength &range, const Aviation::CCallsign &callsign);
//! \copydoc ISimulationEnvironmentProvider::requestElevation
bool requestElevation(const Geo::ICoordinateGeodetic &reference, const Aviation::CCallsign &callsign);
//! \copydoc ISimulationEnvironmentProvider::getElevationsFoundMissed
QPair<int, int> getElevationsFoundMissed() const;