]> git.openstreetmap.org Git - rails.git/blob - lib/object_metadata.rb
Supply hints for OSRM
[rails.git] / lib / object_metadata.rb
1 module ObjectMetadata
2   def add_metadata_to_xml_node(el, osm, changeset_cache, user_display_name_cache)
3     el['changeset'] = osm.changeset_id.to_s
4     el['redacted'] = osm.redaction.id.to_s if osm.redacted?
5     el['timestamp'] = osm.timestamp.xmlschema
6     el['version'] = osm.version.to_s
7     el['visible'] = osm.visible.to_s
8
9     if changeset_cache.key?(osm.changeset_id)
10       # use the cache if available
11     else
12       changeset_cache[osm.changeset_id] = osm.changeset.user_id
13     end
14
15     user_id = changeset_cache[osm.changeset_id]
16
17     if user_display_name_cache.key?(user_id)
18       # use the cache if available
19     elsif osm.changeset.user.data_public?
20       user_display_name_cache[user_id] = osm.changeset.user.display_name
21     else
22       user_display_name_cache[user_id] = nil
23     end
24
25     unless user_display_name_cache[user_id].nil?
26       el['user'] = user_display_name_cache[user_id]
27       el['uid'] = user_id.to_s
28     end
29   end
30
31   def add_tags_to_xml_node(el, tags)
32     tags.each do |tag|
33       tag_el = XML::Node.new('tag')
34
35       tag_el['k'] = tag.k
36       tag_el['v'] = tag.v
37
38       el << tag_el
39     end
40   end
41 end