[gnome-maps/wip/osm-edit: 24/47] osmApi: handle the version attribute in OSMObject



commit 7b46f01b22c6b5dce1e2a1442182c11568c16fd5
Author: Marcus Lundblad <ml update uu se>
Date:   Thu Feb 12 21:33:25 2015 +0100

    osmApi: handle the version attribute in OSMObject
    
    Also started implementing XML serializing support.

 src/osmObject.js |   29 ++++++++++++++++++++++++++++-
 1 files changed, 28 insertions(+), 1 deletions(-)
---
diff --git a/src/osmObject.js b/src/osmObject.js
index 89bb288..7c2a672 100644
--- a/src/osmObject.js
+++ b/src/osmObject.js
@@ -33,6 +33,11 @@ const OSMObject = new Lang.Class({
            this._id = params.id;
        else
            this._id = undefined;
+
+       if (params.version)
+           this._version = params.version;
+       else
+           this._version = 1;
        
        if (params.tags)
            this._tags = params.tags;
@@ -48,6 +53,10 @@ const OSMObject = new Lang.Class({
        this._id = val;
     },
 
+    get version() {
+       return this._version;
+    },
+
     get changeset() {
        return this._changeset;
     },
@@ -65,5 +74,23 @@ const OSMObject = new Lang.Class({
     },
 
     //Abstract
-    toXML: function() { }
+    toXML: function() { },
+
+    _serializeAttributes: function() {
+       return 'id="' + this._id + ' changeset="' + this._changeset +
+           ' version="' + this._version + '"';
+    },
+
+    _serializeTagsToList: function() {
+       let list = [];
+
+       for (var v in this._tags) {
+           list.push('<tag k="' + GLib.markup_escape(v) +
+                     '" v="' + GLib.markup_escape(this._tags[v]) +
+                     '"/>');
+       }
+
+       return list;
+    }
+                     
 });


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]