]> git.openstreetmap.org Git - rails.git/blobdiff - app/models/old_node.rb
Tidy up a bit after shaun's merge...
[rails.git] / app / models / old_node.rb
index 4f10e65a5767ed87fa9515a9fe74441d0f0ed0ec..42f55f2d0fbd6db5ef66390e3bd08a192482ceb3 100644 (file)
@@ -1,4 +1,6 @@
-class OldNode < GeoRecord
+class OldNode < ActiveRecord::Base
+  include GeoRecord
+
   set_table_name 'nodes'
   
   validates_presence_of :user_id, :timestamp
@@ -27,8 +29,15 @@ class OldNode < GeoRecord
     old_node.timestamp = node.timestamp
     old_node.user_id = node.user_id
     old_node.id = node.id
+    old_node.version = node.version
     return old_node
   end
+  
+  def to_xml
+    doc = OSM::API.new.get_xml_doc
+    doc.root << to_xml_node()
+    return doc
+  end
 
   def to_xml_node
     el1 = XML::Node.new 'node'
@@ -46,6 +55,7 @@ class OldNode < GeoRecord
 
     el1['visible'] = self.visible.to_s
     el1['timestamp'] = self.timestamp.xmlschema
+    el1['version'] = self.version.to_s
     return el1
   end
 
@@ -57,16 +67,13 @@ class OldNode < GeoRecord
     #ok from here
     @attributes.update(OldNode.find(:first, :conditions => ['id = ? AND timestamp = ?', self.id, self.timestamp]).instance_variable_get('@attributes'))
    
-    sequence_id = 1
     self.tags.each do |k,v|
       tag = OldNodeTag.new
       tag.k = k
       tag.v = v
       tag.id = self.id
       tag.version = self.version
-      tag.sequence_id = sequence_id
       tag.save!
-      sequence_id += 1
     end
   end
 
@@ -84,5 +91,21 @@ class OldNode < GeoRecord
   def tags=(t)
     @tags = t 
   end 
-
+  def tags_as_hash 
+    hash = {} 
+    Tags.split(self.tags) do |k,v| 
+      hash[k] = v 
+    end 
+    hash 
+  end 
+  # Pretend we're not in any ways 
+  def ways 
+    return [] 
+  end 
+  # Pretend we're not in any relations 
+  def containing_relation_members 
+    return [] 
+  end 
 end