+
+ OMHelper.add_tags_to_xml_node(el, node.node_tags)
+
+ el
+ end
+
+ def xml_for_way(way)
+ doc = OSM::API.new.get_xml_doc
+ doc.root << xml_node_for_way(way)
+ doc
+ end
+
+ def xml_node_for_way(way)
+ el = XML::Node.new "way"
+ el["id"] = way.id.to_s
+
+ OMHelper.add_metadata_to_xml_node(el, way, {}, {})
+
+ # make sure nodes are output in sequence_id order
+ ordered_nodes = []
+ way.way_nodes.each do |nd|
+ ordered_nodes[nd.sequence_id] = nd.node_id.to_s if nd.node&.visible?
+ end
+
+ ordered_nodes.each do |nd_id|
+ next unless nd_id && nd_id != "0"
+
+ node_el = XML::Node.new "nd"
+ node_el["ref"] = nd_id
+ el << node_el
+ end
+
+ OMHelper.add_tags_to_xml_node(el, way.way_tags)
+
+ el
+ end
+
+ def xml_for_relation(relation)
+ doc = OSM::API.new.get_xml_doc
+ doc.root << xml_node_for_relation(relation)
+ doc
+ end
+
+ def xml_node_for_relation(relation)
+ el = XML::Node.new "relation"
+ el["id"] = relation.id.to_s
+
+ OMHelper.add_metadata_to_xml_node(el, relation, {}, {})
+
+ relation.relation_members.each do |member|
+ member_el = XML::Node.new "member"
+ member_el["type"] = member.member_type.downcase
+ member_el["ref"] = member.member_id.to_s
+ member_el["role"] = member.member_role
+ el << member_el
+ end
+
+ OMHelper.add_tags_to_xml_node(el, relation.relation_tags)
+
+ el
+ end
+
+ class OMHelper
+ extend ObjectMetadata