Std::setlocale api

Hi,

Questions surrounding the use of setlocale in CImageClass when writing the world file (CImageClass::WriteWorldFile).

Any insight into the necessity of it in this use case?

Making the call with a locale specified as user-preferred (" ") may have undesired consequences as it would affect the entire application; and that is not a good outcome for a library.

In the least I would suggest saving the current locale (can do this using null as locale argument) and setting it back after writing the file. See attached patch.Image.cpp.zip (548 Bytes)

Thoughts?

Thanks,
LT

I confess I’m not very familiar with image-related activities.

@pmeems, are you able to address this?

Sorry for the late reply.
I had a quick look and the code is not used a lot anymore because MapWinGIS delegates the creation of the world file to GDAL.

@ultraLT Could you also provide a scenaria when this code would be used, including some sample data?
I’ll try to make a unit test of it and test it with your changes.

Hi,

The use case is quite simple.
We use Snapshot3 do get an image and then IImagePtr::Save() to generate a png output, specifying to include the creation of the world file.

The issue here appears to be the user locale as opposed to the system locale (see this).

On a Windows 10 environment we have changed the region settings on the OS with respect to language. So this affects the formatting of numbers and dates, etc…In our case we saw this when the language was set to Turkish.

A unit test could output some numbers in a certain format (i.e., a large number with a certain number of decimal places). Then invoke the CImageClass::WriteWorldFile api and note the change in the display of the output after the call is made.

LT