mirror of
https://github.com/FoggedLens/iD.git
synced 2026-04-21 11:16:36 +02:00
Delete nodes. Fixes #112
This commit is contained in:
+14
-8
@@ -12,6 +12,7 @@ iD.format.XML = {
|
||||
decode: function(s) {
|
||||
return s.replace(/>/g,'>').replace(/</g,'<').replace(/"/g,'"');
|
||||
},
|
||||
// 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 } };
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
@@ -94,4 +94,5 @@ iD.Graph.prototype = {
|
||||
return ((+entity.id.slice(1)) < 0) && entity.modified;
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
+12
-7
@@ -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']()
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user