]> git.openstreetmap.org Git - rails.git/blobdiff - app/controllers/node_controller.rb
rails updates
[rails.git] / app / controllers / node_controller.rb
index b104688d38a58632cbadf75779a14eb1a3208e96..ae0d00c75c5dc6901bb2bf57bce54779f07cc96b 100644 (file)
@@ -37,6 +37,16 @@ class NodeController < ApplicationController
     case request.method
 
     when :get
+      unless node
+        render :nothing => true, :status => 500
+        return
+      end
+
+      unless node.visible
+        render :nothing => true, :status => 410
+        return
+      end
+
       render :text => node.to_xml.to_s
       return
 
@@ -68,4 +78,33 @@ class NodeController < ApplicationController
     end
 
   end
+
+  def history
+    node = Node.find(params[:id])
+
+    unless node
+      render :nothing => true, :staus => 404
+      return
+    end
+
+    doc = XML::Document.new
+    doc.encoding = 'UTF-8' 
+    root = XML::Node.new 'osm'
+    root['version'] = '0.4'
+    root['generator'] = 'OpenStreetMap server'
+    doc.root = root
+
+    node.old_nodes.each do |old_node|
+      el1 = XML::Node.new 'node'
+      el1['id'] = old_node.id.to_s
+      el1['lat'] = old_node.latitude.to_s
+      el1['lon'] = old_node.longitude.to_s
+      Node.split_tags(el1, old_node.tags)
+      el1['visible'] = old_node.visible.to_s
+      el1['timestamp'] = old_node.timestamp.xmlschema
+      root << el1
+    end
+
+    render :text => doc.to_s
+  end
 end