diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2020-02-04 10:37:00 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-02-06 08:50:22 -0800 |
commit | cf1e3524a1e000c27ff97e69b21d87d92cbbcc1a (patch) | |
tree | 87102c36bfff7cc74310929990a378a916185b46 /core | |
parent | 96a03b4b26e85616b6cc851be1917c7e0f63b9c1 (diff) | |
download | subsurface-cf1e3524a1e000c27ff97e69b21d87d92cbbcc1a.tar.gz |
Gps coordinates: be more graceful when parsing coordinates
Some Wikipedia pages use special (non-ASCII) unicode symbols for
representing the " and ' separators. Before parsing, replace these
by the ASCII symbols to enable copy & paste from Wikipedia (and
other sources?).
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core')
-rw-r--r-- | core/qthelper.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/core/qthelper.cpp b/core/qthelper.cpp index cb1cd1159..0ad112124 100644 --- a/core/qthelper.cpp +++ b/core/qthelper.cpp @@ -237,10 +237,16 @@ bool parseGpsText(const QString &gps_text, double *latitude, double *longitude) static const QString POS_LON = QString("+E") + gettextFromC::tr("E"); static const QString NEG_LON = QString("-W") + gettextFromC::tr("W"); - //remove the useless spaces (but keep the ones separating numbers) + // Remove the useless spaces (but keep the ones separating numbers) + // and normalize different ways of writing separators. static const QRegExp SPACE_CLEANER("\\s*([" + POS_LAT + NEG_LAT + POS_LON + NEG_LON + degreeSigns() + "'\"\\s])\\s*"); - const QString normalized = gps_text.trimmed().toUpper().replace(SPACE_CLEANER, "\\1"); + const QString normalized = gps_text.trimmed().toUpper(). + replace(SPACE_CLEANER, "\\1"). + replace(QStringLiteral("′"), "'"). + replace(QStringLiteral("’"), "'"). + replace(QStringLiteral("''"), "\""). + replace(QStringLiteral("″"), "\""); if (normalized.isEmpty()) { *latitude = 0.0; |