Parse WGS coordinates

This commit is contained in:
Klaus Basan
2019-07-23 13:59:56 +02:00
parent 511bc0fa52
commit 658fa50123
3 changed files with 49 additions and 1 deletions

View File

@@ -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°5942″S 150°5706″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()