[Proj] Proj may give erroneous results depending on locale

Frank Warmerdam warmerdam at pobox.com
Tue Jul 20 14:10:31 EDT 2004


Peter S Galbraith wrote:
> Hi, a Debian user (Radoslaw Grzanka <radekg2 at poczta.onet.pl>) reported
> the following bug when his locale is set to pl_PL :
> 
> : Hello,
> :   I have encountered bug which resulted in proj giving different results
> : depending on locale set.
> :   As you can see in the signature my locale is pl_PL and when used with
> : gettext (or gtk+) gives wrong coordinates after transformation.
> :   I'm attaching simple testcase that shows the problem.
> :   The bug is also occures in testing vesion of package (4.4.7) and was
> : really hard to trace.
> : 
> : Best Regards,
> :   Radoslaw Grzanka
> 
> When compiling the following C++ code and linking with either 4.4.7 or
> 4.4.8 versions of proj, the bug appears when running the executable (on
> Debian systems).  I'm unfortunately not an expert in proj so cannot
> track this down.  I don't think this is Debian-specific (but I could be
> wrong).

Peter,

In my experience, most locale() problems relate to the number conventions for
the locale changing (ie. using comma instead of a period for the decimal mark
for instance).  The atof() and sprintf() function then honour the new format
and any atof() on existing floating point numbers from an init file for instance
are wrong.

In the past, my clumsy approach to handling such issues was to just
do a setlocale() back to the C locale inside programs.

In general I think it is a travesty that atof() and sprintf() have been thus
adversely affected by locale standards and I'm not too excited about having to
work around this in all sorts of hacky ways.

However, if you can give a suggestion on clean ways of dealing with such
problems, I would be interested.

Best regards,

-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent




More information about the Proj mailing list