]> git.openstreetmap.org Git - rails.git/blobdiff - app/models/way.rb
Added tests for changeset upload code. Refactored diff reading code and put it into...
[rails.git] / app / models / way.rb
index 1304d8a184da14254064c732ae252b4db6978756..b413ccb280d24c4e56fdb287b4b57a3029298ed0 100644 (file)
@@ -299,4 +299,21 @@ class Way < ActiveRecord::Base
   def tags_as_hash
     return self.tags
   end
+
+  ##
+  # if any referenced nodes are placeholder IDs (i.e: are negative) then
+  # this calling this method will fix them using the map from placeholders 
+  # to IDs +id_map+. 
+  def fix_placeholders!(id_map)
+    self.nds.map! do |node_id|
+      if node_id < 0
+        new_id = id_map[:node][node_id]
+        raise "invalid placeholder for #{node_id.inspect}: #{new_id.inspect}" if new_id.nil?
+        new_id
+      else
+        node_id
+      end
+    end
+  end
+
 end