X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/458402813cfc14d9e1cbca890b238ce78ee72357..81113f37b78937ad229b0c3db44b29435cf3afca:/app/controllers/map_bugs_controller.rb diff --git a/app/controllers/map_bugs_controller.rb b/app/controllers/map_bugs_controller.rb index c0fc97a5f..76f99123e 100644 --- a/app/controllers/map_bugs_controller.rb +++ b/app/controllers/map_bugs_controller.rb @@ -52,7 +52,7 @@ class MapBugsController < ApplicationController format.js format.xml {render :template => 'map_bugs/get_bugs.xml'} format.json { render :json => @bugs.to_json(:methods => [:lat, :lon], :only => [:id, :status, :date_created], :include => { :map_bug_comment => { :only => [:commenter_name, :date_created, :comment]}}) } - format.gpx {render :template => 'map_bugs/get_bugs.gpx'} +# format.gpx {render :template => 'map_bugs/get_bugs.gpx'} end end @@ -69,6 +69,18 @@ class MapBugsController < ApplicationController name = params['name'] if params['name']; @bug = MapBug.create_bug(lat, lon) + + + #TODO: move this into a helper function + url = "http://nominatim.openstreetmap.org/reverse?lat=" + lat.to_s + "&lon=" + lon.to_s + "&zoom=16" + response = REXML::Document.new(Net::HTTP.get(URI.parse(url))) + + if result = response.get_text("reversegeocode/result") + @bug.nearby_place = result.to_s + else + @bug.nearby_place = "unknown" + end + @bug.save; add_comment(@bug, comment, name); @@ -146,7 +158,7 @@ class MapBugsController < ApplicationController format.js format.xml {render :template => 'map_bugs/get_bugs.xml'} format.json { render :json => @bugs.to_json(:methods => [:lat, :lon], :only => [:id, :status, :date_created], :include => { :map_bug_comment => { :only => [:commenter_name, :date_created, :comment]}}) } - format.gpx {render :template => 'map_bugs/get_bugs.gpx'} +# format.gpx {render :template => 'map_bugs/get_bugs.gpx'} end end