Skip to content

Commit

Permalink
Fix for bad parsing of doubles with some locales
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/branches/Release-0_7-candidate@3657 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
larsl committed Jun 23, 2005
1 parent 3a25605 commit 65edbf4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
16 changes: 8 additions & 8 deletions qgis/providers/gpx/gpsdata.cpp
Expand Up @@ -387,9 +387,9 @@ bool GPXHandler::startElement(const XML_Char* qName, const XML_Char** attr) {
mWpt = Waypoint();
for (int i = 0; attr[2*i] != NULL; ++i) {
if (!std::strcmp(attr[2*i], "lat"))
mWpt.lat = QString(attr[2*i+1]).toDouble();
mWpt.lat = mCLocale.toDouble(attr[2*i+1]);
else if (!std::strcmp(attr[2*i], "lon"))
mWpt.lon = QString(attr[2*i+1]).toDouble();
mWpt.lon = mCLocale.toDouble(attr[2*i+1]);
}
mObj = &mWpt;
}
Expand Down Expand Up @@ -513,9 +513,9 @@ bool GPXHandler::startElement(const XML_Char* qName, const XML_Char** attr) {
mRtept = Routepoint();
for (int i = 0; attr[2*i] != NULL; ++i) {
if (!std::strcmp(attr[2*i], "lat"))
mRtept.lat = QString(attr[2*i+1]).toDouble();
mRtept.lat = mCLocale.toDouble(attr[2*i+1]);
else if (!std::strcmp(attr[2*i], "lon"))
mRtept.lon = QString(attr[2*i+1]).toDouble();
mRtept.lon = mCLocale.toDouble(attr[2*i+1]);
}
parseModes.push(ParsingRoutepoint);
}
Expand All @@ -537,9 +537,9 @@ bool GPXHandler::startElement(const XML_Char* qName, const XML_Char** attr) {
mTrkpt = Trackpoint();
for (int i = 0; attr[2*i] != NULL; ++i) {
if (!std::strcmp(attr[2*i], "lat"))
mTrkpt.lat = QString(attr[2*i+1]).toDouble();
mTrkpt.lat = mCLocale.toDouble(attr[2*i+1]);
else if (!std::strcmp(attr[2*i], "lon"))
mTrkpt.lon = QString(attr[2*i+1]).toDouble();
mTrkpt.lon = mCLocale.toDouble(attr[2*i+1]);
}
parseModes.push(ParsingTrackpoint);
}
Expand Down Expand Up @@ -594,11 +594,11 @@ bool GPXHandler::endElement(const std::string& qName) {
mTrk.yMax = (mTrk.yMax > mTrkpt.lat ? mTrk.yMax : mTrkpt.lat);
}
else if (parseModes.top() == ParsingDouble) {
*mDouble = QString(mCharBuffer).toDouble();
*mDouble = mCLocale.toDouble(mCharBuffer);
mCharBuffer = "";
}
else if (parseModes.top() == ParsingInt) {
*mInt = QString(mCharBuffer).toInt();
*mInt = mCLocale.toInt(mCharBuffer);
mCharBuffer = "";
}
else if (parseModes.top() == ParsingString) {
Expand Down
4 changes: 3 additions & 1 deletion qgis/providers/gpx/gpsdata.h
Expand Up @@ -27,6 +27,7 @@
#include <vector>

#include <expat.h>
#include <qlocale.h>
#include <qstring.h>
#include <qtextstream.h>

Expand Down Expand Up @@ -242,7 +243,7 @@ class GPSData {
class GPXHandler {
public:

GPXHandler(GPSData& data) : mData(data) { }
GPXHandler(GPSData& data) : mData(data), mCLocale(QLocale::C) { }

/** This function is called when expat encounters a new start element in
the XML stream. */
Expand Down Expand Up @@ -299,6 +300,7 @@ class GPXHandler {
double* mDouble;
int* mInt;
QString mCharBuffer;
QLocale mCLocale;
};


Expand Down

0 comments on commit 65edbf4

Please sign in to comment.