]> git.openstreetmap.org Git - rails.git/blobdiff - app/models/old_node.rb
Removing the in_world test from the model since it is included in the geo_record...
[rails.git] / app / models / old_node.rb
index 2f960d8866a3239066a14f1198ddac08a06646ff..6b6b71b53eaae06d0f7c591c919aaa51c81f3dd1 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
@@ -12,12 +14,6 @@ class OldNode < GeoRecord
     errors.add_to_base("Node is not in the world") unless in_world?
   end
 
-  def in_world?
-    return false if self.lat < -90 or self.lat > 90
-    return false if self.lon < -180 or self.lon > 180
-    return true
-  end
-
   def self.from_node(node)
     old_node = OldNode.new
     old_node.latitude = node.latitude
@@ -30,6 +26,12 @@ class OldNode < GeoRecord
     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'
@@ -47,6 +49,7 @@ class OldNode < GeoRecord
 
     el1['visible'] = self.visible.to_s
     el1['timestamp'] = self.timestamp.xmlschema
+    el1['version'] = self.version.to_s
     return el1
   end
 
@@ -81,6 +84,23 @@ class OldNode < GeoRecord
 
   def tags=(t)
     @tags = t 
-  end 
+  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