if params[:lat] && params[:lon]
@sources.push "latlon"
@sources.push "osm_nominatim_reverse"
- @sources.push "geonames_reverse"
+ @sources.push "geonames_reverse" if defined?(GEONAMES_USERNAME)
elsif params[:query].match(/^\d{5}(-\d{4})?$/)
@sources.push "us_postcode"
@sources.push "osm_nominatim"
@results = Array.new
# ask geonames.org
- response = fetch_xml("http://ws.geonames.org/countrySubdivision?lat=#{lat}&lng=#{lon}")
+ response = fetch_xml("http://api.geonames.org/countrySubdivision?lat=#{lat}&lng=#{lon}&username=#{GEONAMES_USERNAME}")
# parse the response
response.elements.each("geonames/countrySubdivision") do |geoname|
'S50 4.064 W14 22.645',
"50° 04.064' S, 014° 22.645' W"
].each do |code|
- post :search, :query => code
- assert_response :success
- assert_equal ['latlon' ,'osm_nominatim_reverse', 'geonames_reverse'], assigns(:sources)
- assert_nil @controller.params[:query]
- assert_in_delta -50.06773, @controller.params[:lat]
- assert_in_delta -14.37742, @controller.params[:lon]
+ latlon_check code, -50.06773, -14.37742
end
end
assert_response :success
assert_template "search"
assert_template :layout => "map"
- assert_equal ['latlon' ,'osm_nominatim_reverse', 'geonames_reverse'], assigns(:sources)
+ assert_equal ['latlon' ,'osm_nominatim_reverse'], assigns(:sources)
assert_nil @controller.params[:query]
assert_in_delta lat, @controller.params[:lat]
assert_in_delta lon, @controller.params[:lon]
assert_response :success
assert_template "search"
assert_template :layout => "xhr"
- assert_equal ['latlon' ,'osm_nominatim_reverse', 'geonames_reverse'], assigns(:sources)
+ assert_equal ['latlon' ,'osm_nominatim_reverse'], assigns(:sources)
assert_nil @controller.params[:query]
assert_in_delta lat, @controller.params[:lat]
assert_in_delta lon, @controller.params[:lon]