mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-11-29 07:24:13 +01:00
LP-572 Fix Home position on map when OPMap config is updated
This commit is contained in:
parent
121aaa08b7
commit
f51e7d3688
@ -67,8 +67,12 @@ void OPMapGadget::loadConfiguration(IUAVGadgetConfiguration *config)
|
||||
m_widget->SetUavPic(m_config->uavSymbol());
|
||||
m_widget->setZoom(m_config->zoom());
|
||||
m_widget->setPosition(QPointF(m_config->longitude(), m_config->latitude()));
|
||||
m_widget->setHomePosition(QPointF(m_config->longitude(), m_config->latitude()));
|
||||
m_widget->setOverlayOpacity(m_config->opacity());
|
||||
m_widget->setDefaultWaypointAltitude(m_config->defaultWaypointAltitude());
|
||||
m_widget->setDefaultWaypointVelocity(m_config->defaultWaypointVelocity());
|
||||
|
||||
if (!m_widget->applyHomeLocationOnMap()) {
|
||||
// Set default HomeLocation in center of map
|
||||
m_widget->setHomePosition(QPointF(m_config->longitude(), m_config->latitude()));
|
||||
}
|
||||
}
|
||||
|
@ -916,24 +916,7 @@ void OPMapGadgetWidget::onTelemetryConnect()
|
||||
if (!obum) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool set;
|
||||
double LLA[3];
|
||||
|
||||
// ***********************
|
||||
// fetch the home location
|
||||
|
||||
if (obum->getHomeLocation(set, LLA) < 0) {
|
||||
return; // error
|
||||
}
|
||||
setHome(internals::PointLatLng(LLA[0], LLA[1]), LLA[2]);
|
||||
|
||||
if (m_map) {
|
||||
if (m_map->UAV->GetMapFollowType() != UAVMapFollowType::None) {
|
||||
m_map->SetCurrentPosition(m_home_position.coord); // set the map position
|
||||
}
|
||||
}
|
||||
// ***********************
|
||||
applyHomeLocationOnMap();
|
||||
}
|
||||
|
||||
void OPMapGadgetWidget::onTelemetryDisconnect()
|
||||
@ -1164,6 +1147,10 @@ void OPMapGadgetWidget::setHomePosition(QPointF pos)
|
||||
}
|
||||
|
||||
m_map->Home->SetCoord(internals::PointLatLng(latitude, longitude));
|
||||
|
||||
if (!m_telemetry_connected) {
|
||||
m_home_position.coord = internals::PointLatLng(latitude, longitude);
|
||||
}
|
||||
}
|
||||
|
||||
void OPMapGadgetWidget::setPosition(QPointF pos)
|
||||
@ -2366,6 +2353,32 @@ bool OPMapGadgetWidget::getGPSPositionSensor(double &latitude, double &longitude
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OPMapGadgetWidget::applyHomeLocationOnMap()
|
||||
{
|
||||
bool set;
|
||||
double LLA[3];
|
||||
|
||||
if (!obum) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// fetch the home location
|
||||
if (obum->getHomeLocation(set, LLA) < 0) {
|
||||
return false; // error
|
||||
}
|
||||
|
||||
if (m_telemetry_connected) {
|
||||
setHome(internals::PointLatLng(LLA[0], LLA[1]), LLA[2]);
|
||||
if (m_map) {
|
||||
if (m_map->UAV->GetMapFollowType() != UAVMapFollowType::None) {
|
||||
m_map->SetCurrentPosition(m_home_position.coord); // set the map position
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// *************************************************************************************
|
||||
|
||||
void OPMapGadgetWidget::setMapFollowingMode()
|
||||
|
@ -117,6 +117,7 @@ public:
|
||||
void setDefaultWaypointAltitude(qreal default_altitude);
|
||||
void setDefaultWaypointVelocity(qreal default_velocity);
|
||||
bool getGPSPositionSensor(double &latitude, double &longitude, double &altitude);
|
||||
bool applyHomeLocationOnMap();
|
||||
signals:
|
||||
void defaultLocationAndZoomChanged(double lng, double lat, double zoom);
|
||||
void overlayOpacityChanged(qreal);
|
||||
|
Loading…
Reference in New Issue
Block a user