]> git.openstreetmap.org Git - rails.git/blobdiff - app/models/way.rb
Added user home lat and lon
[rails.git] / app / models / way.rb
index d568cb026908f21ae2c05512b59a632d0fee2ec8..b7d0ec118f92bf3c4e5e239173e7179d842527d3 100644 (file)
@@ -45,15 +45,8 @@ class Way < ActiveRecord::Base
   end
 
   def to_xml
-    doc = XML::Document.new
-    doc.encoding = 'UTF-8' 
-    root = XML::Node.new 'osm'
-    root['version'] = '0.4'
-    root['generator'] = 'OpenStreetMap server'
-
-    doc.root = root
-
-    root << to_xml_node()
+    doc = OSM::API.new.get_xml_doc
+    doc.root << to_xml_node()
     return doc
   end
 
@@ -62,7 +55,7 @@ class Way < ActiveRecord::Base
     el1['id'] = self.id.to_s
     el1['visible'] = self.visible.to_s
     el1['timestamp'] = self.timestamp.xmlschema
-    
+    el1['user'] = self.user.display_name if self.user.data_public?
     # make sure segments are output in sequence_id order\r
     ordered_segments = []\r
     self.way_segments.each do |seg| \r
@@ -85,12 +78,22 @@ class Way < ActiveRecord::Base
 
 
   def segs
-    @segs = Array.new unless @segs
+    unless @segs
+        @segs = Array.new
+        self.way_segments.each do |seg|
+            @segs += [seg.segment_id]
+        end
+    end
     @segs
   end
 
   def tags
-    @tags = Hash.new unless @tags
+    unless @tags
+        @tags = Hash.new
+        self.way_tags.each do |tag|
+            @tags[tag.k] = tag.v
+        end
+    end
     @tags
   end