From 18f0489188422c3e835e5b6169fa8b65bfe27fdd Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Tue, 24 Dec 2013 08:12:12 -0800 Subject: 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 --- qthelper.cpp | 22 +++++++++++----------- 1 file 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: -- cgit v1.2.3-70-g09d2