Add support for more GPS coordinate formats.

As requested in the user forum and in the mailing list, now support:
 - 46.473881 6.784696  (format used in XML files)
 - 48 51.491n 2 17.677e

I was not able to handle the XML format in a generic way without making
the code too ugly. So I've added an exception.

Signed-off-by: Patrick Valsecchi <patrick@thus.ch>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Patrick Valsecchi 2015-02-23 13:38:41 +01:00 committed by Dirk Hohndel
parent 0f6f1c7ccf
commit ce79b9ffa4
3 changed files with 73 additions and 22 deletions

View file

@ -77,6 +77,29 @@ void TestGpsCoords::testSpaceDecimalParse()
coord2double(52.83), coord2double(1.61));
}
void TestGpsCoords::testXmlFormatParse()
{
testParseOK("46.473881 6.784696",
coord2double(46.473881), coord2double(6.784696));
}
void TestGpsCoords::testNegativeXmlFormatParse()
{
testParseOK("46.473881 -6.784696",
coord2double(46.473881), -coord2double(6.784696));
}
void TestGpsCoords::testNoUnitParse()
{
testParseOK("48 51.491n 2 17.677e",
coord2double(48, 51.491), coord2double(2, 17.677));
}
void TestGpsCoords::testPrefixNoUnitParse()
{
testParseOK("n48 51.491 w2 17.677",
coord2double(48, 51.491), -coord2double(2, 17.677));
}
void TestGpsCoords::testParseOK(const QString &txt, double expectedLat,
double expectedLon)