[gnome-maps/wip/osm-edit: 26/47] osmApi: hook up facility to generate a changeset request
- From: Marcus Lundblad <mlundblad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/osm-edit: 26/47] osmApi: hook up facility to generate a changeset request
- Date: Thu, 30 Apr 2015 12:59:33 +0000 (UTC)
commit 7844c2bca25eb90a12f90a382ff0faa2cabe11d0
Author: Marcus Lundblad <ml update uu se>
Date: Thu Feb 12 23:00:33 2015 +0100
osmApi: hook up facility to generate a changeset request
It is not yet posting the request to the server.
src/osmChangeset.js | 25 +++++++++++++++++++++----
src/osmConnection.js | 10 +++++++++-
src/osmEdit.js | 4 ++++
src/osmObject.js | 9 +++++----
4 files changed, 39 insertions(+), 9 deletions(-)
---
diff --git a/src/osmChangeset.js b/src/osmChangeset.js
index efb7091..2172747 100644
--- a/src/osmChangeset.js
+++ b/src/osmChangeset.js
@@ -27,13 +27,30 @@ const OSMChangeset = new Lang.Class({
Name: 'OSMChangeset',
Extends: OSMObject.OSMObject,
- _init: function(comment) {
- // add default tags
- this.setTag('created_by', 'gnome-maps')); // TODO: add real version number
- this.setTag('comment', comment));
+ _init: function(comment, source) {
+ this.parent({});
+ // add default tags
+ this.setTag('created_by', 'gnome-maps'); // TODO: add real version number
+ this.setTag('comment', comment);
+ this.setTag('source', source);
+
// undefined changeset ID until the changeset has been opened
this._id = undefined;
},
+ toXML: function() {
+ let tags = this._serializeTagsToList();
+ let result = '<osm>\n' +
+ '\t<changeset>\n';
+
+ for (var i = 0; i < tags.length; i++) {
+ result += '\t\t' + tags[i] + '\n';
+ }
+
+ result += '\t</changeset>\n' +
+ '</osm>';
+
+ return result;
+ }
})
diff --git a/src/osmConnection.js b/src/osmConnection.js
index 94a8f56..012b95c 100644
--- a/src/osmConnection.js
+++ b/src/osmConnection.js
@@ -20,6 +20,7 @@
* Author: Marcus Lundblad <ml update uu se>
*/
+const OSMChangeset = imports.osmChangeset;
const OSMNode = imports.osmNode;
const OSMRelation = imports.osmRelation;
const OSMWay = imports.osmWay;
@@ -114,6 +115,13 @@ const OSMConnection = new Lang.Class({
default:
return null;
}
- }
+ },
+
+ openChangeset: function(comment, source, callback) {
+ let changeset = new OSMChangeset.OSMChangeset(comment, source);
+ let xml = changeset.toXML();
+
+ print('about open changeset:\n' + xml + '\n');
+ }
})
diff --git a/src/osmEdit.js b/src/osmEdit.js
index 5f41d39..f233bda 100644
--- a/src/osmEdit.js
+++ b/src/osmEdit.js
@@ -74,5 +74,9 @@ const OSMEditManager = new Lang.Class({
}
return osmType;
+ },
+
+ uploadObject: function(place, comment, source, callback) {
+ this._osmConnection.openChangeset(comment, source, callback);
}
});
diff --git a/src/osmObject.js b/src/osmObject.js
index 7c2a672..29e4350 100644
--- a/src/osmObject.js
+++ b/src/osmObject.js
@@ -22,6 +22,8 @@
const Lang = imports.lang;
+const GLib = imports.gi.GLib;
+
const OSMObject = new Lang.Class({
Name: 'OSMObject',
Abstract: true,
@@ -85,12 +87,11 @@ const OSMObject = new Lang.Class({
let list = [];
for (var v in this._tags) {
- list.push('<tag k="' + GLib.markup_escape(v) +
- '" v="' + GLib.markup_escape(this._tags[v]) +
+ list.push('<tag k="' + GLib.markup_escape_text(v, -1) +
+ '" v="' + GLib.markup_escape_text(this.getTag(v), -1) +
'"/>');
}
return list;
- }
-
+ }
});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]