- way
- end
-
- # Find a way given it's ID, and in a single SQL call also grab its nodes
- #
-
- # You can't pull in all the tags too unless we put a sequence_id on the way_tags table and have a multipart key
- def self.find_eager(id)
- Way.find(id, :include => { :way_nodes => :node })
- # If waytag had a multipart key that was real, you could do this:
- # Way.find(id, :include => [:way_tags, {:way_nodes => :node}])
- end
-
- # Find a way given it's ID, and in a single SQL call also grab its nodes and tags
- def to_xml
- doc = OSM::API.new.get_xml_doc
- doc.root << to_xml_node
- doc
- end
-
- def to_xml_node(visible_nodes = nil, changeset_cache = {}, user_display_name_cache = {})
- el = XML::Node.new 'way'
- el['id'] = id.to_s
-
- add_metadata_to_xml_node(el, self, changeset_cache, user_display_name_cache)
-
- # make sure nodes are output in sequence_id order
- ordered_nodes = []
- way_nodes.each do |nd|
- if visible_nodes
- # if there is a list of visible nodes then use that to weed out deleted nodes
- if visible_nodes[nd.node_id]
- ordered_nodes[nd.sequence_id] = nd.node_id.to_s
- end
- else
- # otherwise, manually go to the db to check things
- if nd.node && nd.node.visible?
- ordered_nodes[nd.sequence_id] = nd.node_id.to_s
- end
- end