# Read in xml as text and return it's Way object representation
def self.from_xml(xml, create = false)
- p = XML::Parser.string(xml)
+ p = XML::Parser.string(xml, :options => XML::Parser::Options::NOERROR)
doc = p.parse
doc.find("//osm/way").each do |pt|
lock!
check_consistency(self, new_way, user)
rels = Relation.joins(:relation_members).where(:visible => true, :current_relation_members => { :member_type => "Way", :member_id => id }).order(:id)
- raise OSM::APIPreconditionFailedError.new("Way #{id} is still used by relations #{rels.collect(&:id).join(",")}.") unless rels.empty?
+ raise OSM::APIPreconditionFailedError.new("Way #{id} is still used by relations #{rels.collect(&:id).join(',')}.") unless rels.empty?
self.changeset_id = new_way.changeset_id
self.changeset = new_way.changeset
def save_with_history!
t = Time.now.getutc
+ self.version += 1
+ self.timestamp = t
+
# update the bounding box, note that this has to be done both before
# and after the save, so that nodes from both versions are included in the
# bbox. we use a copy of the changeset so that it isn't reloaded
cs.update_bbox!(bbox) unless nodes.empty?
Way.transaction do
- self.version += 1
- self.timestamp = t
- save!
+ # clone the object before saving it so that the original is
+ # still marked as dirty if we retry the transaction
+ clone.save!
tags = self.tags
WayTag.delete_all(:way_id => id)