Use numerical IDs to save memory

This commit is contained in:
Tom MacWright
2012-10-31 22:45:03 -04:00
parent ecbbedadee
commit ee9b46c221
3 changed files with 7 additions and 8 deletions
+5 -5
View File
@@ -35,7 +35,7 @@ iD.Connection = function() {
var nodes = [], nelems = obj.getElementsByTagName('nd');
for (var i = 0; i < nelems.length; i++) {
var item = nelems[i];
nodes.push(item.attributes.ref.nodeValue);
nodes.push(+item.attributes.ref.nodeValue);
}
return nodes;
}
@@ -55,7 +55,7 @@ iD.Connection = function() {
for (var i = 0; i < elems.length; i++) {
var item = elems[i];
var id = item.attributes.ref.nodeValue,
var id = +item.attributes.ref.nodeValue,
type = item.attributes.type.nodeValue,
role = item.attributes.role.nodeValue;
@@ -74,10 +74,10 @@ iD.Connection = function() {
function objectData(obj) {
return {
type: obj.nodeName,
id: obj.attributes.id.nodeValue,
id: +obj.attributes.id.nodeValue,
tags: getTags(obj),
lat: (obj.attributes.lat) ? obj.attributes.lat.nodeValue : null,
lon: (obj.attributes.lon) ? obj.attributes.lon.nodeValue : null,
lat: (obj.attributes.lat) ? +obj.attributes.lat.nodeValue : null,
lon: (obj.attributes.lon) ? +obj.attributes.lon.nodeValue : null,
members: getMembers(obj),
nodes: getNodes(obj)
};
-2
View File
@@ -3,8 +3,6 @@ iD.Node = function(id, lat, lon, tags, loaded) {
this._id = iD.Util.id();
this.lat = lat;
this.lon = lon;
this[0] = lon;
this[1] = lat;
this.tags = tags || {};
this.loaded = (loaded === undefined) ? true : loaded;
};
+2 -1
View File
@@ -113,7 +113,8 @@ iD.Map = function(obj) {
function nodeline(d) {
return linegen(d.children.map(function(n) {
return connection.graph().index[n];
var node = connection.graph().index[n];
return [node.lon, node.lat];
}));
}