[fdo-users] Re : Re : weird issue

Mateusz Loskot mateusz at loskot.net
Fri Mar 9 05:21:39 EST 2007


Ytse wrote:
> Ok, I've continued my investigations and found a way to get to the 
> result I'm waiting for
> 
> To summarize the issue : 
> Providers\SHP\Src\ShpRead\RowData.cpp::GetData() method uses the 
> atof() function that implicitely uses the current locale. 
> Providers\SHP\Src\ShpRead\RowData.cpp::SetData() method uses the 
> sprintf() function that also implicitely uses the current locale.
> 
> But the shp files should be written using invariant culture (well, I 
> don't know about the official specifications but considering how 
> ArcView ord Excel can't read the decimal values using the french 
> comma decimal separator, I guess that's it)

The ESRI Shapefile doesn't say anything about handling data in with
locale-awareness or not.

> I've tried adding setlocale(LC_NUMERIC,"C"); in ::RowData (and back 
> to default in ::~) and it works fine then
> 
> Could anyone confirm the SHP specifications ? If that's the way to 
> go, could anyone define the best place to set/unset the locale ? 
> (guess the row isn't the best place, maybe that should be done in 
> ::ShpConnection)

In GDAL, there is locale independent function - CPLAtof - used in such
cases:

http://trac.osgeo.org/gdal/browser/trunk/gdal/port/cpl_strtod.cpp#L530

It should be enough to replace atof() with CPLAtof() call in FDO
provider for Shapefile.

Cheers
-- 
Mateusz Loskot
http://mateusz.loskot.net


More information about the fdo-users mailing list