mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 14:55:36 +08:00
Parse WGS coordinates
This commit is contained in:
committed by
Mat Sutcliffe
parent
7ea9e7c2b2
commit
f40dbb6c81
@@ -178,7 +178,7 @@ namespace BlackGui
|
||||
|
||||
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
|
||||
if (sApp && sApp->hasWebDataServices())
|
||||
@@ -203,6 +203,29 @@ namespace BlackGui
|
||||
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()
|
||||
|
||||
@@ -330,11 +330,21 @@ namespace BlackMisc
|
||||
this->setLatLong(latitude, this->longitude());
|
||||
}
|
||||
|
||||
void CCoordinateGeodetic::setLatitudeFromWgs84(const QString &wgs)
|
||||
{
|
||||
this->setLatitude(CLatitude::fromWgs84(wgs));
|
||||
}
|
||||
|
||||
void CCoordinateGeodetic::setLongitude(const CLongitude &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)
|
||||
{
|
||||
m_x = latitude.cos() * longitude.cos();
|
||||
@@ -342,6 +352,12 @@ namespace BlackMisc
|
||||
m_z = latitude.sin();
|
||||
}
|
||||
|
||||
void CCoordinateGeodetic::setLatLongFromWgs84(const QString &latitude, const QString &longitude)
|
||||
{
|
||||
this->setLatitudeFromWgs84(latitude);
|
||||
this->setLongitudeFromWgs84(longitude);
|
||||
}
|
||||
|
||||
void CCoordinateGeodetic::setGeodeticHeightToNull()
|
||||
{
|
||||
this->setGeodeticHeight(CAltitude::null());
|
||||
|
||||
@@ -277,12 +277,21 @@ namespace BlackMisc
|
||||
//! Set latitude
|
||||
void setLatitude(const CLatitude &latitude);
|
||||
|
||||
//! Set latitude
|
||||
void setLatitudeFromWgs84(const QString &wgs);
|
||||
|
||||
//! Set longitude
|
||||
void setLongitude(const CLongitude &longitude);
|
||||
|
||||
//! Set longitude
|
||||
void setLongitudeFromWgs84(const QString &wgs);
|
||||
|
||||
//! Set latitude and 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)
|
||||
void setGeodeticHeight(const Aviation::CAltitude &height) { m_geodeticHeight = height; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user