bug report in GoogleGeoCoder

11 views
Skip to first unread message

Lko

unread,
Aug 5, 2008, 5:16:03 AM8/5/08
to GeoCoding.Net
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

Chadly

unread,
Aug 5, 2008, 10:15:30 AM8/5/08
to GeoCoding.Net
Thanks for the report, Leos. To be honest, I haven't done any work on
internationalization of the current code. Does it cause problems
anywhere else -- like when trying to geocode an address in a different
language? Or is the only issue you have encountered the number
format?

Leos Jor

unread,
Aug 5, 2008, 10:31:38 AM8/5/08
to geocod...@googlegroups.com
I'm testing the geocoding using czech addresses and I've not encountered any other problems so far. I'll keep you informed if there are any other issues.
Thanks,
Leos

Chadly

unread,
Aug 5, 2008, 2:40:53 PM8/5/08
to GeoCoding.Net
Added test cases and fix for issue (http://code.google.com/p/geocoding-
net/issues/detail?id=3). Check latest source code for update.
Reply all
Reply to author
Forward
0 new messages