protect for in loops with hasOwnProperty

This commit is contained in:
Bart van den Eijnden
2012-02-29 18:43:55 +01:00
parent d7a3ecac08
commit e3cc96dbfb
31 changed files with 385 additions and 266 deletions

View File

@@ -140,33 +140,35 @@ OpenLayers.Format.OSM = OpenLayers.Class(OpenLayers.Format.XML, {
feat_list[i] = feat;
}
for (var node_id in nodes) {
var node = nodes[node_id];
if (!node.used || this.checkTags) {
var tags = null;
if (nodes.hasOwnProperty(node_id)) {
var node = nodes[node_id];
if (!node.used || this.checkTags) {
var tags = null;
if (this.checkTags) {
var result = this.getTags(node.node, true);
if (node.used && !result[1]) {
continue;
}
tags = result[0];
} else {
tags = this.getTags(node.node);
}
if (this.checkTags) {
var result = this.getTags(node.node, true);
if (node.used && !result[1]) {
continue;
}
tags = result[0];
} else {
tags = this.getTags(node.node);
}
var feat = new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.Point(node['lon'], node['lat']),
tags);
if (this.internalProjection && this.externalProjection) {
feat.geometry.transform(this.externalProjection,
this.internalProjection);
}
feat.osm_id = parseInt(node_id);
feat.fid = "node." + feat.osm_id;
feat_list.push(feat);
}
// Memory cleanup
node.node = null;
var feat = new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.Point(node['lon'], node['lat']),
tags);
if (this.internalProjection && this.externalProjection) {
feat.geometry.transform(this.externalProjection,
this.internalProjection);
}
feat.osm_id = parseInt(node_id);
feat.fid = "node." + feat.osm_id;
feat_list.push(feat);
}
// Memory cleanup
node.node = null;
}
}
return feat_list;
},
@@ -273,9 +275,11 @@ OpenLayers.Format.OSM = OpenLayers.Class(OpenLayers.Format.XML, {
}
if (this.checkTags) {
for(var key in way.tags) {
if (this.areaTags[key]) {
poly_tags = true;
break;
if (way.tags.hasOwnProperty(key)) {
if (this.areaTags[key]) {
poly_tags = true;
break;
}
}
}
}
@@ -430,10 +434,12 @@ OpenLayers.Format.OSM = OpenLayers.Class(OpenLayers.Format.XML, {
*/
serializeTags: function(feature, node) {
for (var key in feature.attributes) {
var tag = this.createElementNS(null, "tag");
tag.setAttribute("k", key);
tag.setAttribute("v", feature.attributes[key]);
node.appendChild(tag);
if (feature.attributes.hasOwnProperty(key)) {
var tag = this.createElementNS(null, "tag");
tag.setAttribute("k", key);
tag.setAttribute("v", feature.attributes[key]);
node.appendChild(tag);
}
}
},