mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-03 16:25:54 +08:00
[FG] Fetching elevation from sim
This commit is contained in:
committed by
Mat Sutcliffe
parent
22a70e083e
commit
469a057a86
@@ -105,5 +105,26 @@ namespace BlackSimPlugin
|
|||||||
};
|
};
|
||||||
m_dbusInterface->callDBusAsync(QLatin1String("getRemoteAircraftData"), callback, callsigns);
|
m_dbusInterface->callDBusAsync(QLatin1String("getRemoteAircraftData"), callback, callsigns);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CFGSwiftBusTrafficProxy::getElevationAtPosition(const CCallsign &callsign, double latitudeDeg, double longitudeDeg, double altitudeMeters,
|
||||||
|
const ElevationCallback &setter) const
|
||||||
|
{
|
||||||
|
std::function<void(QDBusPendingCallWatcher *)> callback = [ = ](QDBusPendingCallWatcher * watcher)
|
||||||
|
{
|
||||||
|
QDBusPendingReply<QString, double> reply = *watcher;
|
||||||
|
if (!reply.isError())
|
||||||
|
{
|
||||||
|
const CCallsign cs(reply.argumentAt<0>());
|
||||||
|
const double elevationMeters = reply.argumentAt<1>();
|
||||||
|
const CAltitude elevationAlt = std::isnan(elevationMeters) ? CAltitude::null() : CAltitude(elevationMeters, CLengthUnit::m(), CLengthUnit::ft());
|
||||||
|
const CElevationPlane elevation(CLatitude(latitudeDeg, CAngleUnit::deg()),
|
||||||
|
CLongitude(longitudeDeg, CAngleUnit::deg()),
|
||||||
|
elevationAlt, CElevationPlane::singlePointRadius());
|
||||||
|
setter(elevation, cs);
|
||||||
|
}
|
||||||
|
watcher->deleteLater();
|
||||||
|
};
|
||||||
|
m_dbusInterface->callDBusAsync(QLatin1String("getElevationAtPosition"), callback, callsign.asString(), latitudeDeg, longitudeDeg, altitudeMeters);
|
||||||
|
}
|
||||||
} // ns
|
} // ns
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
@@ -216,6 +216,10 @@ namespace BlackSimPlugin
|
|||||||
//! Get remote aircrafts data (lat, lon, elevation and CG)
|
//! Get remote aircrafts data (lat, lon, elevation and CG)
|
||||||
void getRemoteAircraftData(const QStringList &callsigns, const RemoteAircraftDataCallback &setter) const;
|
void getRemoteAircraftData(const QStringList &callsigns, const RemoteAircraftDataCallback &setter) const;
|
||||||
|
|
||||||
|
//! \copydoc XSwiftBus::CTraffic::getElevationAtPosition
|
||||||
|
void getElevationAtPosition(const BlackMisc::Aviation::CCallsign &callsign, double latitudeDeg, double longitudeDeg, double altitudeMeters,
|
||||||
|
const ElevationCallback &setter) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BlackMisc::CGenericDBusInterface *m_dbusInterface = nullptr;
|
BlackMisc::CGenericDBusInterface *m_dbusInterface = nullptr;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -824,6 +824,35 @@ namespace BlackSimPlugin
|
|||||||
emit this->aircraftRenderingChanged(addedRemoteAircraft);
|
emit this->aircraftRenderingChanged(addedRemoteAircraft);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CSimulatorFlightgear::requestElevation(const BlackMisc::Geo::ICoordinateGeodetic &reference, const BlackMisc::Aviation::CCallsign &callsign)
|
||||||
|
{
|
||||||
|
if (this->isShuttingDownOrDisconnected()) { return false; }
|
||||||
|
if(reference.isNull()) { return false; }
|
||||||
|
|
||||||
|
CCoordinateGeodetic pos(reference);
|
||||||
|
if(!pos.hasMSLGeodeticHeight()){
|
||||||
|
// testing showed: height has an influence on the returned result
|
||||||
|
// - the most accurate value seems to be returned if the height is close to the elevation
|
||||||
|
// - in normal scenarios there is no much difference of the results if 0 is used
|
||||||
|
// - in Lukla (9200ft MSL) the difference between 0 and 9200 is around 1ft
|
||||||
|
// - in the LOWW scenario using 50000ft MSL results in around 3ft too low elevation
|
||||||
|
static const CAltitude alt(0, CAltitude::MeanSeaLevel, CLengthUnit::ft());
|
||||||
|
pos.setGeodeticHeight(alt);
|
||||||
|
}
|
||||||
|
|
||||||
|
using namespace std::placeholders;
|
||||||
|
auto callback = std::bind(&CSimulatorFlightgear::callbackReceivedRequestedElevation, this, _1, _2);
|
||||||
|
|
||||||
|
// Request
|
||||||
|
m_trafficProxy->getElevationAtPosition(callsign,
|
||||||
|
pos.latitude().value(CAngleUnit::deg()),
|
||||||
|
pos.longitude().value(CAngleUnit::deg()),
|
||||||
|
pos.geodeticHeight().value(CLengthUnit::m()),
|
||||||
|
callback);
|
||||||
|
emit this->requestedElevation(callsign);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void CSimulatorFlightgear::onRemoteAircraftAddingFailed(const QString &callsign)
|
void CSimulatorFlightgear::onRemoteAircraftAddingFailed(const QString &callsign)
|
||||||
{
|
{
|
||||||
BLACK_VERIFY_X(!callsign.isEmpty(), Q_FUNC_INFO, "Need callsign");
|
BLACK_VERIFY_X(!callsign.isEmpty(), Q_FUNC_INFO, "Need callsign");
|
||||||
|
|||||||
@@ -137,6 +137,7 @@ namespace BlackSimPlugin
|
|||||||
virtual void resetAircraftStatistics() override;
|
virtual void resetAircraftStatistics() override;
|
||||||
virtual BlackMisc::CStatusMessageList getInterpolationMessages(const BlackMisc::Aviation::CCallsign &callsign) const override;
|
virtual BlackMisc::CStatusMessageList getInterpolationMessages(const BlackMisc::Aviation::CCallsign &callsign) const override;
|
||||||
virtual bool testSendSituationAndParts(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Aviation::CAircraftSituation &situation, const BlackMisc::Aviation::CAircraftParts &parts) override;
|
virtual bool testSendSituationAndParts(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Aviation::CAircraftSituation &situation, const BlackMisc::Aviation::CAircraftParts &parts) override;
|
||||||
|
virtual bool requestElevation(const BlackMisc::Geo::ICoordinateGeodetic &reference, const BlackMisc::Aviation::CCallsign &callsign) override;
|
||||||
//! @}
|
//! @}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
Reference in New Issue
Block a user