Delete nodes. Fixes #112

This commit is contained in:
Tom MacWright
2012-11-26 14:29:54 -05:00
parent ab0b71f548
commit ee6cf2c146
4 changed files with 28 additions and 19 deletions
+14 -8
View File
@@ -12,6 +12,7 @@ iD.format.XML = {
decode: function(s) {
return s.replace(/>/g,'&gt;').replace(/</g,'&lt;').replace(/"/g,'&quot;');
},
// Generate Changeset XML. Returns a string.
changeset: function(comment) {
return (new XMLSerializer()).serializeToString(
JXON.unbuild({
@@ -27,21 +28,28 @@ iD.format.XML = {
}
}));
},
osmChange: function(userid, changeset, changes) {
// Generate [osmChange](http://wiki.openstreetmap.org/wiki/OsmChange)
// XML. Returns a string.
osmChange: function(userid, changeset_id, changes) {
return (new XMLSerializer()).serializeToString(
JXON.unbuild({
osmChange: {
'@version': 0.3,
'@generator': 'iD',
// TODO: copy elements first
create: changes.created.map(function(c) {
create: changes.create.map(function(c) {
var x = Object.create(c);
x.changeset = changeset;
x.changeset = changeset_id;
return x;
}).map(iD.format.XML.rep),
modify: changes.modified.map(function(c) {
modify: changes.modify.map(function(c) {
var x = Object.create(c);
x.changeset = changeset;
x.changeset = changeset_id;
return x;
}).map(iD.format.XML.rep),
'delete': changes['delete'].map(function(c) {
var x = Object.create(c);
x.changeset = changeset_id;
return x;
}).map(iD.format.XML.rep)
}
@@ -71,9 +79,7 @@ iD.format.XML = {
return { keyAttributes: { ref: e.id } };
}),
tag: _.map(entity.tags, function(v, k) {
return {
keyAttributes: { k: k, v: v }
};
return { keyAttributes: { k: k, v: v } };
})
}
};
+1
View File
@@ -94,4 +94,5 @@ iD.Graph.prototype = {
return ((+entity.id.slice(1)) < 0) && entity.modified;
});
}
};
+12 -7
View File
@@ -56,23 +56,28 @@ iD.History.prototype = {
}
},
modified: function() {
modify: function() {
return this.stack[this.index].creations();
},
created: function() {
create: function() {
return this.stack[this.index].creations();
},
deleted: function() {
// return this.stack[this.index].();
'delete': function() {
return _.difference(
_.pluck(this.stack[0].entities, 'id'),
_.pluck(this.stack[this.index].entities, 'id')
).map(function(id) {
return this.stack[0].entity(id);
}.bind(this));
},
changes: function() {
return {
modified: this.modified(),
created: this.created(),
deleted: this.deleted()
modify: this.modify(),
create: this.create(),
'delete': this['delete']()
};
}
};
+1 -4
View File
@@ -516,10 +516,7 @@ iD.Map = function(elem, connection) {
}
function commit() {
connection.createChangeset({
modified: history.graph().modifications(),
created: history.graph().creations()
});
connection.createChangeset(history.changes());
}
map.download = download;