mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
Make decimals optional in GPS coordinates
As an aside, our resolution is great and certainly high enough for the real world, but it's easy to get into situations where we don't display the exact same degrees / minutes / seconds as the user entered... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
09096f9af4
commit
18f0489188
1 changed files with 11 additions and 11 deletions
22
qthelper.cpp
22
qthelper.cpp
|
@ -114,13 +114,13 @@ bool parseGpsText(const QString& gps_text, double *latitude, double *longitude)
|
|||
// so handle the three formats we understand separately
|
||||
if (gps_text.count(QChar('"')) == 2) {
|
||||
gpsStyle = SECONDS;
|
||||
regExp = QString("\\s*([NS%1%2])\\s*(\\d+)[" UTF8_DEGREE "\\s]+(\\d+)[\'\\s]+(\\d+)[,\\.](\\d+)[^EW%3%4]*"
|
||||
"([EW%6%7])\\s*(\\d+)[" UTF8_DEGREE "\\s]+(\\d+)[\'\\s]+(\\d+)[,\\.](\\d+)")
|
||||
regExp = QString("\\s*([NS%1%2])\\s*(\\d+)[" UTF8_DEGREE "\\s]+(\\d+)[\'\\s]+(\\d+)([,\\.](\\d+))?[^EW%3%4]*"
|
||||
"([EW%6%7])\\s*(\\d+)[" UTF8_DEGREE "\\s]+(\\d+)[\'\\s]+(\\d+)([,\\.](\\d+))?")
|
||||
.arg(tr("N")).arg(tr("S")).arg(tr("E")).arg(tr("W")).arg(tr("E")).arg(tr("W"));
|
||||
} else if (gps_text.count(QChar('\'')) == 2) {
|
||||
gpsStyle = MINUTES;
|
||||
regExp = QString("\\s*([NS%1%2])\\s*(\\d+)[" UTF8_DEGREE "\\s]+(\\d+)[,\\.](\\d+)[^EW%3%4]*"
|
||||
"([EW%6%7])\\s*(\\d+)[" UTF8_DEGREE "\\s]+(\\d+)[,\\.](\\d+)")
|
||||
regExp = QString("\\s*([NS%1%2])\\s*(\\d+)[" UTF8_DEGREE "\\s]+(\\d+)([,\\.](\\d+))?[^EW%3%4]*"
|
||||
"([EW%6%7])\\s*(\\d+)[" UTF8_DEGREE "\\s]+(\\d+)([,\\.](\\d+))?")
|
||||
.arg(tr("N")).arg(tr("S")).arg(tr("E")).arg(tr("W")).arg(tr("E")).arg(tr("W"));
|
||||
} else {
|
||||
regExp = QString("\\s*([-NS%1%2]?)\\s*(\\d+)[,\\.](\\d+)[^-EW%3%4\\d]*([-EW%5%6]?)\\s*(\\d+)[,\\.](\\d+)")
|
||||
|
@ -133,15 +133,15 @@ bool parseGpsText(const QString& gps_text, double *latitude, double *longitude)
|
|||
switch(gpsStyle) {
|
||||
case SECONDS:
|
||||
*latitude = r.cap(2).toInt() + r.cap(3).toInt() / 60.0 +
|
||||
(r.cap(4) + QString(".") + r.cap(5)).toDouble() / 3600.0;
|
||||
*longitude = r.cap(7).toInt() + r.cap(8).toInt() / 60.0 +
|
||||
(r.cap(9) + QString(".") + r.cap(10)).toDouble() / 3600.0;
|
||||
eastWest = 6;
|
||||
(r.cap(4) + QString(".") + r.cap(6)).toDouble() / 3600.0;
|
||||
*longitude = r.cap(8).toInt() + r.cap(9).toInt() / 60.0 +
|
||||
(r.cap(10) + QString(".") + r.cap(12)).toDouble() / 3600.0;
|
||||
eastWest = 7;
|
||||
break;
|
||||
case MINUTES:
|
||||
*latitude = r.cap(2).toInt() + (r.cap(3) + QString(".") + r.cap(4)).toDouble() / 60.0;
|
||||
*longitude = r.cap(6).toInt() + (r.cap(7) + QString(".") + r.cap(8)).toDouble() / 60.0;
|
||||
eastWest = 5;
|
||||
*latitude = r.cap(2).toInt() + (r.cap(3) + QString(".") + r.cap(5)).toDouble() / 60.0;
|
||||
*longitude = r.cap(7).toInt() + (r.cap(8) + QString(".") + r.cap(10)).toDouble() / 60.0;
|
||||
eastWest = 6;
|
||||
break;
|
||||
case DECIMAL:
|
||||
default:
|
||||
|
|
Loading…
Reference in a new issue