Change putChangeset to create osmChangeset and asJXON

This commit is contained in:
Bryan Housel
2017-03-11 14:12:34 -05:00
parent f783fe4942
commit a1323e482e

View File

@@ -4,10 +4,18 @@ import osmAuth from 'osm-auth';
import { JXON } from '../util/jxon';
import { d3geoTile } from '../lib/d3.geo.tile';
import { geoExtent } from '../geo/index';
import { osmEntity, osmNode, osmRelation, osmWay } from '../osm/index';
import {
osmChangeset,
osmEntity,
osmNode,
osmRelation,
osmWay
} from '../osm/index';
import { utilDetect } from '../util/detect';
import { utilRebind } from '../util/rebind';
var dispatch = d3.dispatch('authLoading', 'authDone', 'change', 'loading', 'loaded'),
urlroot = 'https://www.openstreetmap.org',
blacklists = ['.*\.google(apis)?\..*/(vt|kh)[\?/].*([xyz]=.*){3}.*'],
@@ -280,22 +288,6 @@ export default {
},
// Generate Changeset XML. Returns a string.
changesetJXON: function(tags) {
return {
osm: {
changeset: {
tag: _.map(tags, function(value, key) {
return { '@k': key, '@v': value };
}),
'@version': 0.6,
'@generator': 'iD'
}
}
};
},
// Generate [osmChange](http://wiki.openstreetmap.org/wiki/OsmChange)
// XML. Returns a string.
osmChangeJXON: function(changeset_id, changes) {
@@ -394,12 +386,14 @@ export default {
putChangeset: function(changes, version, comment, imageryUsed, callback) {
var that = this;
var that = this,
changeset = new osmChangeset({ tags: this.changesetTags(version, comment, imageryUsed) });
oauth.xhr({
method: 'PUT',
path: '/api/0.6/changeset/create',
options: { header: { 'Content-Type': 'text/xml' } },
content: JXON.stringify(that.changesetJXON(that.changesetTags(version, comment, imageryUsed)))
content: JXON.stringify(changeset.asJXON())
}, function(err, changeset_id) {
if (err) return callback(err);
oauth.xhr({