[fdo-trac] #706: Shape Provider modifies the CRT locale settings and destroys WMS Provider requests

FDO trac_fdo at osgeo.org
Tue Oct 12 05:06:03 EDT 2010


#706: Shape Provider modifies the CRT locale settings and destroys WMS Provider
requests
----------------------------+-----------------------------------------------
   Reporter:  sgamperl      |       Owner:  gregboone       
       Type:  defect        |      Status:  new             
   Priority:  critical      |   Milestone:  3.5.0           
  Component:  WMS Provider  |     Version:  3.5.0           
   Severity:  2             |    Keywords:  SHP, WMS, locale
External_id:                |  
----------------------------+-----------------------------------------------

Comment(by sgamperl):

 This issue is a little bit tricky. For Austria we use the culture DE-AT
 where the decimal seperator is ','. A printf or sprintf should result in a
 string with ',' seperator for double values.
 If no one sets the current culture the "C" culture is used by the program.
 So the first Format() results in 120.0. This is correct because in the "C"
 locale the seperator is '.'.
 After the call to "ShapeCPG()" the locale gets modified to the machine's
 current culture. In my case DE-AT which means a ',' seperator.

 If I then use the WMS provider I get an error because the GetMap request
 gets built with ',' as double seperator and that's not correct for the
 BBOX element of the GetMap request.

 Sample:

 double d = 120.0;

 FdoStringP p = FdoStringP::Format(L"%lf",d);

 ShapeCPG cpg = ShapeCPG();

 _locale_t t = __get_current_locale();

 setlocale(LC_ALL,"C");

 FdoStringP p2 = FdoStringP::Format(L"%lf",d);


 In my opinion there are 2 problems:
 (1) if the shape provider modifies the locale for his work, the provider
 has to set it back to the initial state
 (2) the wms provider must use the '.' seperator in the requests. so the
 provider should use the "C" locale independent of the default culture on
 the machine.

 The problem gets even trickier:
 When i modified the locale for the WMS provider setlocale(LC_ALL,"C") to
 ensure the right seperator, I didn't recognized a change in the behaviour.
 The problem is here, that if i mix CRT runtimes (e.g. release FDO build
 and debug test executable), i change only the locale for one CRT. If both
 are debug or release it works. The locale of the CRT is per process and
 per runtime (debug or release).

 Hope this information can help.

-- 
Ticket URL: <http://trac.osgeo.org/fdo/ticket/706#comment:2>
FDO <http://fdo.osgeo.org/>
Feature Data Objects


More information about the fdo-trac mailing list