OpenWeatherMap-API-CSharp
OpenWeatherMap-API-CSharp copied to clipboard
Decimal Seeparator
Somehow this code seems to use the users decimal separator (in my case a comma) and thus ignoreing the . (US & as far as i know part of the JSON's standard).
Result is wind speeds are 1000 fold of what they are in the data retrieved
"speed": 11.32 thus results in the demo printing 1132 m/s/
Debugging a bit shows windata at line 45 of Wind.cs correctly shows dots as decimal separator, but windData.SelectToken("speed") shows {11,32} as value in the Watch window.
Solution (note; only tested in a country with a , as separator):
replace:
SpeedMetersPerSecond = double.Parse(windData.SelectToken("speed").ToString(), CultureInfo.InvariantCulture);
by
SpeedMetersPerSecond = windData.SelectToken("speed").Value<Double>();
thus preventing converting bwteeen double and string.
This change should be applied at all simimar code. And best to remove it for other data types as integers as well.