X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/5f4dcd34ff5943ff4de39bc8322013376a6de8b9..4fb775d6d516857066e0d3cc86877ead3f6cae08:/app/models/node.rb diff --git a/app/models/node.rb b/app/models/node.rb index 578735688..6346907f1 100644 --- a/app/models/node.rb +++ b/app/models/node.rb @@ -49,7 +49,7 @@ class Node < ActiveRecord::Base # Read in xml as text and return it's Node 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/node").each do |pt| @@ -185,8 +185,8 @@ class Node < ActiveRecord::Base add_metadata_to_xml_node(el, self, changeset_cache, user_display_name_cache) if visible? - el["lat"] = lat.to_s - el["lon"] = lon.to_s + el["lat"] = format("%.7f", lat) + el["lon"] = format("%.7f", lon) end add_tags_to_xml_node(el, node_tags) @@ -232,10 +232,14 @@ class Node < ActiveRecord::Base def save_with_history! t = Time.now.getutc + + self.version += 1 + self.timestamp = t + Node.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! # Create a NodeTag tags = self.tags