mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-17 10:55:32 +08:00
Parse WGS coordinates
This commit is contained in:
@@ -178,7 +178,7 @@ namespace BlackGui
|
|||||||
|
|
||||||
void CCoordinateForm::locationEntered()
|
void CCoordinateForm::locationEntered()
|
||||||
{
|
{
|
||||||
const QString l = ui->le_Location->text().trimmed().toUpper();
|
const QString l = ui->le_Location->text().trimmed().simplified().toUpper();
|
||||||
|
|
||||||
// location based on swift data
|
// location based on swift data
|
||||||
if (sApp && sApp->hasWebDataServices())
|
if (sApp && sApp->hasWebDataServices())
|
||||||
@@ -203,6 +203,29 @@ namespace BlackGui
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 33°59′42″S 150°57′06″E
|
||||||
|
if (l.contains(' '))
|
||||||
|
{
|
||||||
|
QString lat, lng;
|
||||||
|
const QStringList parts = l.split(' ');
|
||||||
|
for (const QString &p : parts)
|
||||||
|
{
|
||||||
|
if (p.contains('S') || p.contains('N'))
|
||||||
|
{
|
||||||
|
lat = p;
|
||||||
|
}
|
||||||
|
else if (p.contains('E') || p.contains('W'))
|
||||||
|
{
|
||||||
|
lng = p;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!lat.isEmpty() && !lng.isEmpty())
|
||||||
|
{
|
||||||
|
CCoordinateGeodetic c = m_coordinate;
|
||||||
|
c.setLatLongFromWgs84(lat, lng);
|
||||||
|
this->setCoordinate(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCoordinateForm::latEntered()
|
void CCoordinateForm::latEntered()
|
||||||
|
|||||||
@@ -330,11 +330,21 @@ namespace BlackMisc
|
|||||||
this->setLatLong(latitude, this->longitude());
|
this->setLatLong(latitude, this->longitude());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CCoordinateGeodetic::setLatitudeFromWgs84(const QString &wgs)
|
||||||
|
{
|
||||||
|
this->setLatitude(CLatitude::fromWgs84(wgs));
|
||||||
|
}
|
||||||
|
|
||||||
void CCoordinateGeodetic::setLongitude(const CLongitude &longitude)
|
void CCoordinateGeodetic::setLongitude(const CLongitude &longitude)
|
||||||
{
|
{
|
||||||
this->setLatLong(this->latitude(), longitude);
|
this->setLatLong(this->latitude(), longitude);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CCoordinateGeodetic::setLongitudeFromWgs84(const QString &wgs)
|
||||||
|
{
|
||||||
|
this->setLongitude(CLongitude::fromWgs84(wgs));
|
||||||
|
}
|
||||||
|
|
||||||
void CCoordinateGeodetic::setLatLong(const CLatitude &latitude, const CLongitude &longitude)
|
void CCoordinateGeodetic::setLatLong(const CLatitude &latitude, const CLongitude &longitude)
|
||||||
{
|
{
|
||||||
m_x = latitude.cos() * longitude.cos();
|
m_x = latitude.cos() * longitude.cos();
|
||||||
@@ -342,6 +352,12 @@ namespace BlackMisc
|
|||||||
m_z = latitude.sin();
|
m_z = latitude.sin();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CCoordinateGeodetic::setLatLongFromWgs84(const QString &latitude, const QString &longitude)
|
||||||
|
{
|
||||||
|
this->setLatitudeFromWgs84(latitude);
|
||||||
|
this->setLongitudeFromWgs84(longitude);
|
||||||
|
}
|
||||||
|
|
||||||
void CCoordinateGeodetic::setGeodeticHeightToNull()
|
void CCoordinateGeodetic::setGeodeticHeightToNull()
|
||||||
{
|
{
|
||||||
this->setGeodeticHeight(CAltitude::null());
|
this->setGeodeticHeight(CAltitude::null());
|
||||||
|
|||||||
@@ -277,12 +277,21 @@ namespace BlackMisc
|
|||||||
//! Set latitude
|
//! Set latitude
|
||||||
void setLatitude(const CLatitude &latitude);
|
void setLatitude(const CLatitude &latitude);
|
||||||
|
|
||||||
|
//! Set latitude
|
||||||
|
void setLatitudeFromWgs84(const QString &wgs);
|
||||||
|
|
||||||
//! Set longitude
|
//! Set longitude
|
||||||
void setLongitude(const CLongitude &longitude);
|
void setLongitude(const CLongitude &longitude);
|
||||||
|
|
||||||
|
//! Set longitude
|
||||||
|
void setLongitudeFromWgs84(const QString &wgs);
|
||||||
|
|
||||||
//! Set latitude and longitude
|
//! Set latitude and longitude
|
||||||
void setLatLong(const CLatitude &latitude, const CLongitude &longitude);
|
void setLatLong(const CLatitude &latitude, const CLongitude &longitude);
|
||||||
|
|
||||||
|
//! Set latitude and longitude
|
||||||
|
void setLatLongFromWgs84(const QString &latitude, const QString &longitude);
|
||||||
|
|
||||||
//! Set height (ellipsoidal or geodetic height)
|
//! Set height (ellipsoidal or geodetic height)
|
||||||
void setGeodeticHeight(const Aviation::CAltitude &height) { m_geodeticHeight = height; }
|
void setGeodeticHeight(const Aviation::CAltitude &height) { m_geodeticHeight = height; }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user