end
pt.find('nd').each do |nd|
- way.add_nd_num(nd['id'])
+ way.add_nd_num(nd['ref'])
end
end
rescue
ordered_nodes.each do |nd_id|
if nd_id and nd_id != '0'
e = XML::Node.new 'nd'
- e['id'] = nd_id
+ e['ref'] = nd_id
el1 << e
end
end
@tags[k] = v
end
- def save_with_history
- begin
- Way.transaction do
- t = Time.now
- self.timestamp = t
- self.save!
+ def save_with_history!
+ t = Time.now
- tags = self.tags
+ Way.transaction do
+ self.timestamp = t
+ self.save!
+ end
- WayTag.delete_all(['id = ?', self.id])
+ WayTag.transaction do
+ tags = self.tags
- tags.each do |k,v|
- tag = WayTag.new
- tag.k = k
- tag.v = v
- tag.id = self.id
- tag.save!
- end
+ WayTag.delete_all(['id = ?', self.id])
- nds = self.nds
+ tags.each do |k,v|
+ tag = WayTag.new
+ tag.k = k
+ tag.v = v
+ tag.id = self.id
+ tag.save!
+ end
+ end
- WayNode.delete_all(['id = ?', self.id])
+ WayNode.transaction do
+ nds = self.nds
- i = 1
- nds.each do |n|
- nd = WayNode.new
- nd.id = self.id
- nd.node_id = n
- nd.sequence_id = i
- nd.save!
- i += 1
- end
+ WayNode.delete_all(['id = ?', self.id])
- old_way = OldWay.from_way(self)
- old_way.timestamp = t
- old_way.save_with_dependencies!
+ i = 1
+ nds.each do |n|
+ nd = WayNode.new
+ nd.id = self.id
+ nd.node_id = n
+ nd.sequence_id = i
+ nd.save!
+ i += 1
end
-
- return true
- rescue => ex
- puts ex
- return nil
end
+
+ old_way = OldWay.from_way(self)
+ old_way.timestamp = t
+ old_way.save_with_dependencies!
end
def preconditions_ok?