-
Notifications
You must be signed in to change notification settings - Fork 2
/
OSMMeta.js
44 lines (37 loc) · 1.43 KB
/
OSMMeta.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/* Copyright (c) 2006-2012 by OpenLayers Contributors (see authors.txt for
* full list of contributors). Published under the 2-clause BSD license.
* See license.txt in the OpenLayers distribution or repository for the
* full text of the license. */
/**
* @requires OpenLayers/Format/OSM.js
*/
/**
* Class: OpenLayers.Format.OSMMeta
* Extended OSM parser. Adds meta attributes as tags.
* Create a new instance with the <OpenLayers.Format.OSMMeta> constructor.
*
* Inherits from:
* - <OpenLayers.Format.OSM>
*/
OpenLayers.Format.OSMMeta = OpenLayers.Class(OpenLayers.Format.OSM, {
// without id, which is already added as osm_id property to feature
metaAttributes: ['version', 'timestamp', 'uid', 'user', 'changeset'],
initialize: function(options) {
OpenLayers.Format.OSM.prototype.initialize.apply(this, [options]);
},
getTags: function(dom_node, interesting_tags) {
var tags = OpenLayers.Format.OSM.prototype.getTags.apply(this, arguments);
var meta = this.getMetaAttributes(dom_node);
tags = OpenLayers.Util.extend(tags, meta);
return tags;
},
getMetaAttributes: function(dom_node) {
var meta = {}, name;
for (var i = 0; i < this.metaAttributes.length; i++) {
name = this.metaAttributes[i];
meta[name] = dom_node.getAttribute(name);
}
return meta;
},
CLASS_NAME: "OpenLayers.Format.OSMMeta"
});