Bug#482126: qlandkarte: .gpx-export is locale dependent
Hello Michael! On Sat, May 24, 2008 at 12:00:10PM +0200, Michael Hanke wrote: > thanks for your analysis. However, your test tool behaves exacly the > like your log shows on my Qt 4.3 system. > > Could you please try the attached patch from the upstream SVN and tell > me if it fixes the bug? If so, I will update the package with it. Yes, that fixes it, but two remarks: 1. the patch is reversed. 2. you significantly decrease the precision: before: after: QDomElement::setAttribute in dom/qdom.cpp:4829 uses int count = qsnprintf(buf, sizeof(buf), "%.16g", value); so you should probably use 16 as well. > diff --git a/src/CGarminDBRoute.cpp b/src/CGarminDBRoute.cpp > index 0ae34e8..29a5fef 100644 > --- a/src/CGarminDBRoute.cpp > +++ b/src/CGarminDBRoute.cpp > @@ -168,8 +168,8 @@ void CGarminDBRoute::saveGPX(CGpx& gpx) > QDomElement gpxRtept = gpx.createElement("rtept"); > gpxRoute.appendChild(gpxRtept); > > -gpxRtept.setAttribute("lat",QString::number(rtept->v,'f',6)); > -gpxRtept.setAttribute("lon",QString::number(rtept->u,'f',6)); > +gpxRtept.setAttribute("lat",rtept->v); > +gpxRtept.setAttribute("lon",rtept->u); BYtE Philipp -- Philipp Matthias Hahn <[EMAIL PROTECTED]> GPG/PGP: 9A540E39 @ keyrings.debian.org -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Bug#482126: qlandkarte: .gpx-export is locale dependent
Hi Pilipp, thanks for your analysis. However, your test tool behaves exacly the like your log shows on my Qt 4.3 system. Could you please try the attached patch from the upstream SVN and tell me if it fixes the bug? If so, I will update the package with it. Thanks, Michael -- GPG key: 1024D/3144BE0F Michael Hanke http://apsy.gse.uni-magdeburg.de/hanke ICQ: 48230050 diff --git a/src/CGarminDBRoute.cpp b/src/CGarminDBRoute.cpp index 0ae34e8..29a5fef 100644 --- a/src/CGarminDBRoute.cpp +++ b/src/CGarminDBRoute.cpp @@ -168,8 +168,8 @@ void CGarminDBRoute::saveGPX(CGpx& gpx) QDomElement gpxRtept = gpx.createElement("rtept"); gpxRoute.appendChild(gpxRtept); -gpxRtept.setAttribute("lat",QString::number(rtept->v,'f',6)); -gpxRtept.setAttribute("lon",QString::number(rtept->u,'f',6)); +gpxRtept.setAttribute("lat",rtept->v); +gpxRtept.setAttribute("lon",rtept->u); QString str = QString("%1").arg(++cnt,3,10,QChar('0')); diff --git a/src/CGarminDBTrack.cpp b/src/CGarminDBTrack.cpp index 422fa39..5e705e8 100644 --- a/src/CGarminDBTrack.cpp +++ b/src/CGarminDBTrack.cpp @@ -206,8 +206,8 @@ void CGarminDBTrack::saveGPX(CGpx& gpx) while(trkpt != (*track)->end()) { QDomElement gpxTrkpt = gpx.createElement("trkpt"); trkseg.appendChild(gpxTrkpt); -gpxTrkpt.setAttribute("lat",QString::number(trkpt->lat,'f',6)); -gpxTrkpt.setAttribute("lon",QString::number(trkpt->lon,'f',6)); +gpxTrkpt.setAttribute("lat",trkpt->lat); +gpxTrkpt.setAttribute("lon",trkpt->lon); if(trkpt->alt != 1e25f || trkpt->dpth != 1e25f) { QDomElement ele = gpx.createElement("ele"); diff --git a/src/CGarminDBWpt.cpp b/src/CGarminDBWpt.cpp index 4d8b52b..7a14fca 100644 --- a/src/CGarminDBWpt.cpp +++ b/src/CGarminDBWpt.cpp @@ -384,8 +384,8 @@ void CGarminDBWpt::saveGPX(CGpx& gpx) } QDomElement wpt = gpx.createElement("wpt"); root.appendChild(wpt); -wpt.setAttribute("lat",QString::number((*w)->lat,'f',6)); -wpt.setAttribute("lon",QString::number((*w)->lon,'f',6)); +wpt.setAttribute("lat",(*w)->lat); +wpt.setAttribute("lon",(*w)->lon); if((*w)->alt != 1e25f || (*w)->dpth != 1e25f) { QDomElement ele = gpx.createElement("ele");
Bug#482126: qlandkarte: .gpx-export is locale dependent
Hello! On Wed, May 21, 2008 at 10:53:13AM +0200, Michael Hanke wrote: > On Tue, May 20, 2008 at 11:12:37PM +0200, Philipp Matthias Hahn wrote: > > Package: qlandkarte > > Version: 0.7.2~dfsg.1-1 > > Severity: important > > > > Upstream-Bug, please forward. > > > > Depending on which locale is set when QLandkarte is launched, the saved > > .gpx files contain differenr number-formats in the @lon and @lat > > attribute of track-points. For example, Germany uses ',' whilte the USA > > use '.' as the floatingpoint-delimiter. > I cannot reproduce this bug, nor can upstream. I tried with your LANG > settings and I always get '.' as the delimiter. Whatever causes this bug > on your system seems to be within Qt. Please also see upstream's > response: > > http://sourceforge.net/mailarchive/forum.php?thread_name=20080521053226.GB3492%40localhost&forum_name=qlandkarte-users It's not the fault of QLandkarte, but Qt4 seams to be broken to use "printf(%g)" for the conversion of doubles to strings. Please consider re-assigning this bug to qt4-x11. Nether the less it affects QLandkarte. $ locale LANG=de_DE.UTF-8 LC_CTYPE="de_DE.UTF-8" LC_NUMERIC="de_DE.UTF-8" LC_TIME="de_DE.UTF-8" LC_COLLATE="de_DE.UTF-8" LC_MONETARY="de_DE.UTF-8" LC_MESSAGES="de_DE.UTF-8" LC_PAPER="de_DE.UTF-8" LC_NAME="de_DE.UTF-8" LC_ADDRESS="de_DE.UTF-8" LC_TELEPHONE="de_DE.UTF-8" LC_MEASUREMENT="de_DE.UTF-8" LC_IDENTIFICATION="de_DE.UTF-8" LC_ALL= qt4-x11-4.4.0/src/xml/dom/qdom.cpp:4823 void QDomElement::setAttribute(const QString& name, double value) { if (!impl) return; QString x; char buf[256]; int count = qsnprintf(buf, sizeof(buf), "%.16g", value); $ gdb bin/qlandkarte (gdb) s QDomElement::setAttribute (this=0xbfe82550, [EMAIL PROTECTED], value=53.125089034438133) at dom/qdom.cpp:4825 ^ (gdb) n 4829int count = qsnprintf(buf, sizeof(buf), "%.16g", value); ^ (gdb) print buf $14 = "53,12508903443813\000... ^ qt4-x11-4.4.0/src/corelib/tools/qvsnprintf.cpp:77 int qvsnprintf(char *str, size_t n, const char *fmt, va_list ap) { if (!str || !fmt) return -1; QString buf; buf.vsprintf(fmt, ap); qt4-x11-4.4.0/src/corelib/tools/qstring.cpp:4542 QString &QString::vsprintf(const char* cformat, va_list ap) { ...:4760 case 'g': ...:4780 subst = locale.d()->doubleToString(d, precision, form, width, flags); qt4-x11-4.4.0/src/corelib/tools/qlocale.cpp:3601 QString QLocalePrivate::doubleToString(double d, int precision, DoubleForm form, int width, unsigned flags) const { ...:3707 num_str = decimalForm(digits, decpt, precision, mode, always_show_decpt, flags & ThousandsGroup, *this); qt4-x11-4.4.0/src/corelib/tools/qlocale.cpp:3304 static QString &decimalForm(QString &digits, int decpt, uint precision, PrecisionMode pm, bool always_show_decpt, bool thousands_group, const QLocalePrivate &locale) { ...: digits.insert(decpt, locale.decimal()); I'll also attach my short test program "dom.cc" to be compiled with c++ -I/usr/include/qt4 -lQtXml -o dom dom.cc #include #include #include #include int main(int argc, char **argv, char **env) { double value = 3.1415 + argc; setlocale(LC_ALL, ""); QLocale::setDefault( QLocale::system() ); QString x; char buf[256]; int count = qsnprintf(buf, sizeof(buf), "%.16g", value); if (count > 0) { x = QString::fromLatin1(buf, count); std::cout << qPrintable(x) << std::endl; } x.setNum(value); // Fallback std::cout << qPrintable(x) << std::endl; QDomDocument doc( "root" ); QDomElement root = doc.createElement( "root" ); root.setAttribute( "double", value ); doc.appendChild( root ); QString xml = doc.toString(); std::cout << qPrintable(xml) << std::endl; return 0; } LANG=en_US.UTF-8 ./dom 4.1415001 4.1415 LANG=de_DE.UTF-8 ./dom 4,1415001 4.1415 > On this system I'm running qt 4.3. Could you try if the bug also > occurs with Qt 4.3 instead of 4.4? I currently don't have access to any machine running Qt 4.3, but if I find one I'll send another mail with the output of my test programm. BYtE Philipp --
Bug#482126: qlandkarte: .gpx-export is locale dependent
Hi Philipp, On Tue, May 20, 2008 at 11:12:37PM +0200, Philipp Matthias Hahn wrote: > Package: qlandkarte > Version: 0.7.2~dfsg.1-1 > Severity: important > > Upstream-Bug, please forward. > > Depending on which locale is set when QLandkarte is launched, the saved > .gpx files contain differenr number-formats in the @lon and @lat > attribute of track-points. For example, Germany uses ',' whilte the USA > use '.' as the floatingpoint-delimiter. I cannot reproduce this bug, nor can upstream. I tried with your LANG settings and I always get '.' as the delimiter. Whatever causes this bug on your system seems to be within Qt. Please also see upstream's response: http://sourceforge.net/mailarchive/forum.php?thread_name=20080521053226.GB3492%40localhost&forum_name=qlandkarte-users > Versions of packages qlandkarte depends on: > ii libc62.7-11 GNU C Library: Shared libraries > ii libgcc1 1:4.3.0-4 GCC support library > ii libqt4-network 4.4.0-2 Qt 4 network module > ii libqt4-xml 4.4.0-2 Qt 4 XML module > ii libqtcore4 4.4.0-2 Qt 4 core module > ii libqtgui44.4.0-2 Qt 4 GUI module > ii libstdc++6 4.3.0-4 The GNU Standard C++ Library v3 > ii libusb-0.1-4 2:0.1.12-11 userspace USB programming library > ii proj 4.6.0-1 Cartographic projection filter > and On this system I'm running qt 4.3. Could you try if the bug also occurs with Qt 4.3 instead of 4.4? Thanks, Michael -- GPG key: 1024D/3144BE0F Michael Hanke http://apsy.gse.uni-magdeburg.de/hanke ICQ: 48230050 -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Bug#482126: qlandkarte: .gpx-export is locale dependent
Package: qlandkarte Version: 0.7.2~dfsg.1-1 Severity: important Upstream-Bug, please forward. Depending on which locale is set when QLandkarte is launched, the saved .gpx files contain differenr number-formats in the @lon and @lat attribute of track-points. For example, Germany uses ',' whilte the USA use '.' as the floatingpoint-delimiter. LANG=en_US.UTF-8 qlandkarte http://www.w3.org/2001/XMLSchema-instance"; version="1.1" xmlns="http://www.topografix.com/GPX/1/1"; creator="QLandkarte" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"; > http://qlandkarte.sourceforge.net/"; > QLandkarte 2008-05-20T21:03:45Z ACTIVE LOG 16 ^^ -46.9673 2008-05-20T17:47:37Z 0 LANG=de_DE.UTF-8 qlandkarte http://www.w3.org/2001/XMLSchema-instance"; version="1.1" xmlns="http://www.topografix.com/GPX/1/1"; creator="QLandkarte" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"; > http://qlandkarte.sourceforge.net/"; > QLandkarte 2008-05-20T21:00:29Z ACTIVE LOG 16 ^^ -46.9673 2008-05-20T17:47:37Z 0 TThis breaks importing the file in JOSM, since that program expects '.'. -- System Information: Debian Release: lenny/sid APT prefers unstable APT policy: (989, 'unstable') Architecture: i386 (i686) Kernel: Linux 2.6.25.4 (SMP w/2 CPU cores; PREEMPT) Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/bash Versions of packages qlandkarte depends on: ii libc62.7-11 GNU C Library: Shared libraries ii libgcc1 1:4.3.0-4 GCC support library ii libqt4-network 4.4.0-2 Qt 4 network module ii libqt4-xml 4.4.0-2 Qt 4 XML module ii libqtcore4 4.4.0-2 Qt 4 core module ii libqtgui44.4.0-2 Qt 4 GUI module ii libstdc++6 4.3.0-4 The GNU Standard C++ Library v3 ii libusb-0.1-4 2:0.1.12-11 userspace USB programming library ii proj 4.6.0-1 Cartographic projection filter and qlandkarte recommends no packages. -- no debconf information -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]