
ruby-geonames - issue #2
Geonames::WebService.find_nearby_postal_codes fails with latitude/longitude
Set up a Geonames::WebService.find_nearby_postal_codes to query for latitude/longitude, e.g.
postal_code_sc = Geonames::PostalCodeSearchCriteria.new postal_code_sc.latitude = '47' postal_code_sc.longitude = '9' p Geonames::WebService.find_nearby_postal_codes(postal_code_sc)
This should result in the results as seen on: http://ws.geonames.org/findNearbyPostalCodes?lat=47&lng=9
This is running on geonames 0.2.2
It is caused by the lack of an '=' sign in the to_query_params_string method in the Geonames::PostalCodeSearchCriteria class.
My suggested fix is to use:
if !@latitude.nil?
url = url + "&lat=" + CGI::escape( @latitude.to_s )
end
if !@longitude.nil?
url = url + "&lng=" + CGI::escape( @longitude.to_s )
end
Note the use of ".to_s" which will enable queries on fixnum latitude/longitude as well as strings.
Comment #1
Posted on May 8, 2009 by Massive BearI have applied your suggestion to my branch on GitHub:
http://github.com/elecnix/ruby-geonames/commit/99cb830a3455e1eb39625c626d06b2598cfd19bc
Status: New
Labels:
Type-Defect
Priority-Medium