]> 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 41b07eb96c4a8321e0638578e70ff1d5e4ca1798..76f99123eab43485e65536456eda1a1e805a1526 100644 (file)
@@ -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);