X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/136c5a7bf1e850d188a86cfe65ace4c4c457fcb8..dc2a95903722644f6109244cec9a2d1e195fef0e:/app/models/way.rb diff --git a/app/models/way.rb b/app/models/way.rb index 1304d8a18..b413ccb28 100644 --- a/app/models/way.rb +++ b/app/models/way.rb @@ -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