Tag commits with imagery used

This commit is contained in:
Ansis Brammanis
2013-01-08 16:04:31 -05:00
parent 4347b134de
commit fe634f4f9f
4 changed files with 13 additions and 6 deletions

View File

@@ -103,7 +103,7 @@ iD.Connection = function() {
return oauth.authenticated();
}
connection.putChangeset = function(changes, comment, callback) {
connection.putChangeset = function(changes, comment, imagery_used, callback) {
oauth.xhr({
method: 'PUT',
path: '/api/0.6/changeset/create',

View File

@@ -15,14 +15,15 @@ iD.format.XML = {
return s.replace(/>/g,'&gt;').replace(/</g,'&lt;').replace(/"/g,'&quot;');
},
// Generate Changeset XML. Returns a string.
changeset: function(comment) {
changeset: function(comment, imagery_used) {
return (new XMLSerializer()).serializeToString(
JXON.unbuild({
osm: {
changeset: {
tag: [
{ '@k': 'created_by', '@v': 'iD 0.0.0' },
{ '@k': 'comment', '@v': comment || '' }
{ '@k': 'comment', '@v': comment || '' },
{ '@k': 'imagery_used', '@v': imagery_used.join(';')}
],
'@version': 0.3,
'@generator': 'iD'

View File

@@ -1,5 +1,5 @@
iD.History = function() {
var stack, index,
var stack, index, imagery_used,
dispatch = d3.dispatch('change');
function perform(actions) {
@@ -16,7 +16,9 @@ iD.History = function() {
graph = actions[i](graph);
}
return {graph: graph, annotation: annotation};
imagery_used = 'Bing'; // TODO, un-hardcode
return {graph: graph, annotation: annotation, imagery_used: imagery_used};
}
function change(previous) {
@@ -108,6 +110,10 @@ iD.History = function() {
};
},
imagery_used: function(source) {
return _.unique(_.pluck(stack.slice(1, index + 1), 'imagery_used'));
},
reset: function () {
stack = [{graph: iD.Graph()}];
index = 0;

View File

@@ -99,7 +99,7 @@ window.iD = function(container) {
function save(e) {
d3.select('.shaded').remove();
var l = iD.loading('Uploading changes to OpenStreetMap.');
connection.putChangeset(history.changes(), e.comment, function(err, changeset_id) {
connection.putChangeset(history.changes(), e.comment, history.imagery_used(), function(err, changeset_id) {
l.remove();
history.reset();
map.flush().redraw();