elliotdennis / geocoding-net

Automatically exported from code.google.com/p/geocoding-net
0 stars 0 forks source link

Address coordinate parsing does not work under cs-CZ culture #3

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
See here:
http://groups.google.com/group/geocodingnet/browse_thread/thread/5927d2520444a52
5

Hi,

I found a bug in FromCoordinates method of GoogleGeoCoder class. When
you run the code under different culture setting then en-US (cs-CZ in
my case) you get "Input string was not in a correct format exception"
at line 66:
double longitude = double.Parse(coordinates[0]);

Possible fix:
        private Location FromCoordinates(string[] coordinates)
        {
            CultureInfo ci = new CultureInfo("en-US");
            double longitude = double.Parse(coordinates[0],
(IFormatProvider)ci.NumberFormat);
            double latitude = double.Parse(coordinates[1],
(IFormatProvider)ci.NumberFormat);
            Location gpsCoordinates = new Location(latitude,
longitude);
            return gpsCoordinates;
        }

Please note I have not read the documentation of the Google GeoCoding
API so I only suppose the format of the returned coordinates is en-
US.

Thanks
Leos

Original issue reported on code.google.com by chadl...@gmail.com on 5 Aug 2008 at 6:37

GoogleCodeExporter commented 9 years ago

Original comment by chadl...@gmail.com on 5 Aug 2008 at 6:39