# Read in xml as text and return it's Node object representation
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/node').each do |pt|
return Node.from_xml_node(pt, create)
end
- rescue LibXML::XML::Error => ex
+ rescue LibXML::XML::Error, ArgumentError => ex
raise OSM::APIBadXMLError.new("node", xml, ex.message)
end
end
raise OSM::APIBadXMLError.new("node", pt, "lon missing") if pt['lon'].nil?
node.lat = pt['lat'].to_f
node.lon = pt['lon'].to_f
+ raise OSM::APIBadXMLError.new("node", pt, "changeset id missing") if pt['changeset'].nil?
node.changeset_id = pt['changeset'].to_i
raise OSM::APIBadUserInput.new("The node is outside this world") unless node.in_world?
# visible if it says it is, or as the default if the attribute
# is missing.
- node.visible = pt['visible'].nil? or pt['visible'] == 'true'
+ # Don't need to set the visibility, when it is set explicitly in the create/update/delete
+ #node.visible = pt['visible'].nil? or pt['visible'] == 'true'
- if create
- node.timestamp = Time.now
- else
- if pt['timestamp']
- node.timestamp = Time.parse(pt['timestamp'])
- end
- end
+ # We don't care about the time, as it is explicitly set on create/update/delete
tags = []
def update_from(new_node, user)
check_consistency(self, new_node, user)
- # update changeset with *old* position first
+ # update changeset first
+ self.changeset_id = new_node.changeset_id
+ self.changeset = new_node.changeset
+
+ # update changeset bbox with *old* position first
changeset.update_bbox!(bbox);
# FIXME logic needs to be double checked
- self.changeset_id = new_node.changeset_id
self.latitude = new_node.latitude
self.longitude = new_node.longitude
self.tags = new_node.tags
self.visible = true
- # update changeset with *new* position
+ # update changeset bbox with *new* position
changeset.update_bbox!(bbox);
save_with_history!
private
def save_with_history!
- t = Time.now
+ t = Time.now.getutc
Node.transaction do
self.version += 1
self.timestamp = t