mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
96a03b4b26
commit
cf1e3524a1
1 changed files with 8 additions and 2 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue