X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/e9527b363da441337ac8c44c9d3d3feada3eaa9c..c321c026f265c6c2b25a3d564232a12f6ca48c0a:/app/models/relation.rb diff --git a/app/models/relation.rb b/app/models/relation.rb index 94ef9d42a..a8789bc78 100644 --- a/app/models/relation.rb +++ b/app/models/relation.rb @@ -27,14 +27,13 @@ class Relation < ActiveRecord::Base def self.from_xml(xml, create=false) begin - p = XML::Parser.new - p.string = xml + p = XML::Parser.string(xml) doc = p.parse doc.find('//osm/relation').each do |pt| return Relation.from_xml_node(pt, create) end - rescue LibXML::XML::Error => ex + rescue LibXML::XML::Error, ArgumentError => ex raise OSM::APIBadXMLError.new("relation", xml, ex.message) end end @@ -49,8 +48,10 @@ class Relation < ActiveRecord::Base raise OSM::APIBadXMLError.new("relation", pt, "You are missing the required changeset in the relation") if pt['changeset'].nil? relation.changeset_id = pt['changeset'] + # The follow block does not need to be executed because they are dealt with + # in create_with_history, update_from and delete_with_history if create - relation.timestamp = Time.now + relation.timestamp = Time.now.getutc relation.visible = true relation.version = 0 else @@ -252,6 +253,7 @@ class Relation < ActiveRecord::Base raise OSM::APIPreconditionFailedError.new end self.changeset_id = new_relation.changeset_id + self.changeset = new_relation.changeset self.tags = new_relation.tags self.members = new_relation.members self.visible = true @@ -332,7 +334,7 @@ class Relation < ActiveRecord::Base # changed then we have to monitor their before and after state. tags_changed = false - t = Time.now + t = Time.now.getutc self.version += 1 self.timestamp = t self.save! @@ -371,6 +373,10 @@ class Relation < ActiveRecord::Base tag.id = self.id tag.save! end + + # reload, so that all of the members are accessible in their + # new state. + self.reload # same pattern as before, but this time we're collecting the # changed members in an array, as the bounding box updates for