Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible wrong conversion format for decimal separator #51

Open
luciantin opened this issue Oct 21, 2024 · 5 comments
Open

Possible wrong conversion format for decimal separator #51

luciantin opened this issue Oct 21, 2024 · 5 comments

Comments

@luciantin
Copy link

luciantin commented Oct 21, 2024

Hi Ichim, your map is amazing and thank you for all the hard work.

During development I noticed that points wouldn't show on some computers.
I found that the array containing lat and lon coords was in the wrong format on the problematic computers it probably has to do with the local computers localization settings.

It uses a comma as the decimal separator

image

Correctly formats the decimal separator

image

@ichim
Copy link
Owner

ichim commented Oct 21, 2024

Hello sir,
i understood. I think this mistake is from .NET - cultureInfo/Globalization. Thanks for the report, sir!

@ichim
Copy link
Owner

ichim commented Oct 22, 2024

Hello again,

I need more information!

image

I changed my windows settings so that the decimal separator is ",". The application works correctly. Use data stored in GeoJSON files or use Geometric.Points with StreamPoint collection??

@luciantin
Copy link
Author

Hi, you are right that it works correctly even with wrong windows localization settings.
I couldn't get the right format in dotnet by changing it in windows, it did not seem to affect CultureInfo.

This morning I got it working everywhere correctly, the way I fixed it globally was to set DefaultThreadCurrentCulture in Program.cs above builder.

        public static void Main(string[] args)
        {
        
            var cultureInfo = new CultureInfo("en-us");
            cultureInfo.NumberFormat.CurrencyDecimalSeparator = ".";  // prob not needed
            cultureInfo.NumberFormat.NumberDecimalSeparator = ".";   // prob not needed
            CultureInfo.DefaultThreadCurrentCulture = cultureInfo;
            CultureInfo.DefaultThreadCurrentUICulture = cultureInfo;
        
            var builder = WebApplication.CreateBuilder(args);

            ....
          }

I used data fetched from a database as a decimal converted to a double in DisplayPointsFromArray.addPoint.

I cant change the code inside the .cs file but I'm sure that if you set the culture, just inside the thread that invokes js code, you could get it to behave in the same way.

image

A problem ex. would be : The culture of the thread is "Croatian", the decimal separator is a comma and because of that the string.Join(",", coordinates2) will use a comma and output coords to js in the format [14,234352,27,3463456].

I hope this was helpful.

@ichim
Copy link
Owner

ichim commented Oct 22, 2024

Yes sir, i will be change/add and I make a new release!

@ichim
Copy link
Owner

ichim commented Oct 23, 2024

Hello sir,

In a few minutes version 2.2.0.8 will be available

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants