From a1323e482e0bee2174c932317beca1c651d1d7bc Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Sat, 11 Mar 2017 14:12:34 -0500 Subject: [PATCH] Change putChangeset to create osmChangeset and asJXON --- modules/services/osm.js | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/modules/services/osm.js b/modules/services/osm.js index 14bdca643..94f00bf38 100644 --- a/modules/services/osm.js +++ b/modules/services/osm.js @@ -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({