summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2013-12-23 15:17:52 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-12-23 15:18:53 -0800
commita2bf4e76e4655f9473295b9890cf1aa6538c2cf9 (patch)
tree2a97b3ac37d446c63ef76e27a33e8e6cf9cc37d1
parent9405895285f90932bee9db439fe6a13234f65395 (diff)
downloadsubsurface-a2bf4e76e4655f9473295b9890cf1aa6538c2cf9.tar.gz
Accept decimal point and comma in gps coordinates
The previous implementation only accepted a decimal point. We now support both point and comma, regardless of locale. This also removes a debug message left behind in the previous patch. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--qthelper.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/qthelper.cpp b/qthelper.cpp
index 36b3ef182..e5df1d109 100644
--- a/qthelper.cpp
+++ b/qthelper.cpp
@@ -114,16 +114,16 @@ 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+)")
+ regExp = QString("\\s*([-NS%1%2]?)\\s*(\\d+)[,\\.](\\d+)[^-EW%3%4\\d]*([-EW%5%6]?)\\s*(\\d+)[,\\.](\\d+)")
.arg(tr("N")).arg(tr("S")).arg(tr("E")).arg(tr("W")).arg(tr("E")).arg(tr("W"));
}
QRegExp r(regExp);
@@ -157,7 +157,6 @@ bool parseGpsText(const QString& gps_text, double *latitude, double *longitude)
// qDebug("%s -> %8.5f / %8.5f", gps_text.toLocal8Bit().data(), *latitude, *longitude);
return true;
}
- qDebug() << "rejected";
return false;
}