diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2013-12-24 08:12:12 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-12-24 08:12:12 -0800 |
commit | 18f0489188422c3e835e5b6169fa8b65bfe27fdd (patch) | |
tree | 2c3e1fbf2275b85efdd3cb70cdd3a1332f9df7ac | |
parent | 09096f9af418805560968e1721dcfb83bf9bd511 (diff) | |
download | subsurface-18f0489188422c3e835e5b6169fa8b65bfe27fdd.tar.gz |
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>
-rw-r--r-- | qthelper.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/qthelper.cpp b/qthelper.cpp index e5df1d109..111e01520 100644 --- a/qthelper.cpp +++ b/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: |