]> git.openstreetmap.org Git - rails.git/blobdiff - app/models/way.rb
added a marker to show a location on the map
[rails.git] / app / models / way.rb
index a6e0cecf968805958d1b36ff06601af2ad5672b8..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
 
@@ -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