X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/82e4970766d1493a8ee4088c0d9867b42e9f7558..ccebb796ab50c40fed7b76b9b2a7934cbca19cdb:/app/controllers/geocoder_controller.rb diff --git a/app/controllers/geocoder_controller.rb b/app/controllers/geocoder_controller.rb index 6db70a6f3..7eb817333 100644 --- a/app/controllers/geocoder_controller.rb +++ b/app/controllers/geocoder_controller.rb @@ -7,6 +7,7 @@ class GeocoderController < ApplicationController before_filter :authorize_web before_filter :set_locale + before_filter :require_oauth, :only => [:search] def search normalize_params @@ -15,7 +16,7 @@ class GeocoderController < ApplicationController 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" @@ -29,6 +30,8 @@ class GeocoderController < ApplicationController @sources.push "osm_nominatim" @sources.push "geonames" if defined?(GEONAMES_USERNAME) end + + render :layout => map_layout end def search_latlon @@ -256,7 +259,7 @@ class GeocoderController < ApplicationController @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|