Ticket #49 (closed defect: fixed)

Opened 2 years ago

Last modified 2 years ago

Reset LC_NUMERIC in pj_init()

Reported by: grisxa Owned by: warmerdam
Priority: major Milestone: 4.7.0
Component: Core Version: 4.6.1
Keywords: atof, locale, LC_NUMERIC Cc:

Description

As pj_init() calls pj_datum_set() that in turn calls locale-dependent atof() to convert, say, +towgs84 datum parameters, I suggest to reset LC_NUMERIC to "C" in beginning of pj_init() and get back on exit (see patch). There is some more atof() in source tree, so maybe another steps should be taken to make proj.4 really locale-independent. See also  http://trac.osgeo.org/proj/wiki/FAQ#DoesPROJ.4workindifferentinternationalnumericlocales

Attachments

proj-4.6.1.diff Download (1.1 KB) - added by grisxa 2 years ago.
LC_NUMERIC reset in pj_init()

Change History

Changed 2 years ago by grisxa

LC_NUMERIC reset in pj_init()

Changed 2 years ago by grisxa

I should also explain, how this bug happens.

Several multi-lingual applications, like  QLandkarteGT, call pj_init() and pj_transform() internally. If projection is specified in form "+init=epsg:2393", file /usr/share/proj/epsg is parsed and datum parameters for 2393 are used. But they are stored with a dot as decimal point, while pj_init() already operates locale-specific decimal point (comma in my case). So atof() rounds float numbers to integers (it stops parsing at first dot met). That is why I suggest to reset LC_NUMERIC.

As far as I can see, console utils from proj.4 don't have such issue, probably because they are not localized (don't use setlocale()).

Changed 2 years ago by warmerdam

  • status changed from new to closed
  • resolution set to fixed
  • milestone set to 4.7.0

I concur with your analysis and I have applied just a slight variation on the patch in trunk (r1630).

Note: See TracTickets for help on using tickets.