]> git.openstreetmap.org Git - rails.git/blobdiff - app/controllers/map_bugs_controller.rb
Fixup some of the rss output and geocode bugs using nominatim
[rails.git] / app / controllers / map_bugs_controller.rb
index c0fc97a5f63aaf50947db6aafceb684f58a9e070..76f99123eab43485e65536456eda1a1e805a1526 100644 (file)
@@ -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