sibartlett / Geo

A geospatial library for .NET
https://www.nuget.org/packages/Geo/
GNU Lesser General Public License v3.0
179 stars 39 forks source link

Parsing of coordinates is not Culture independent #34

Closed alex-piccione closed 4 years ago

alex-piccione commented 7 years ago

Running the unit tests on a PC with .Net in Italian ("it-IT" ) it does not pass.

Coordinate.cs TryParse() assumes the current Thread culture use dot as decimal separator.

method should use the double.Parse() and double.TryParse() overrides with NumberStyles and IFormatProvider parameters as I seen in other classes.

Example: var deg1 = double.Parse(match.Groups["Deg1"].Value); should be: var deg1 = double.Parse(match.Groups["Deg1"].Value, CultureInfo.InvariantCulture);

double.TryParse(match.Groups["Min1"].Value, out temp) should be: double.TryParse(match.Groups["Min1"].Value, NumberStyles.None, CultureInfo.InvariantCulture, out temp)

I'm not sure NumberStyles.None is the best choice, but it works.

Alex