Support the user attribute on entities
authorTom Hughes <tom@compton.nu>
Wed, 9 Mar 2011 10:57:37 +0000 (10:57 +0000)
committerTom Hughes <tom@compton.nu>
Wed, 9 Mar 2011 10:57:37 +0000 (10:57 +0000)
net/systemeD/halcyon/connection/Changeset.as
net/systemeD/halcyon/connection/Entity.as
net/systemeD/halcyon/connection/EntityCollection.as
net/systemeD/halcyon/connection/Marker.as
net/systemeD/halcyon/connection/Node.as
net/systemeD/halcyon/connection/Relation.as
net/systemeD/halcyon/connection/Way.as
net/systemeD/halcyon/connection/XMLBaseConnection.as
net/systemeD/halcyon/connection/XMLConnection.as

index 096651d..000a587 100644 (file)
@@ -4,7 +4,7 @@ package net.systemeD.halcyon.connection {
                public static var entity_type:String = 'changeset';
 
         public function Changeset(id:Number, tags:Object) {
-            super(id, 0, tags, true, NaN, '');
+            super(id, 0, tags, true, NaN, null, null);
         }
 
         public override function toString():String {
index 6a24481..b02b974 100644 (file)
@@ -12,6 +12,7 @@ package net.systemeD.halcyon.connection {
         private var _version:uint;
         private var _uid:Number;
         private var _timestamp:String;
+        private var _user:String;
         private var tags:Object = {};
         private var modified:Boolean = false;
         private var _loaded:Boolean = true;
@@ -22,11 +23,12 @@ package net.systemeD.halcyon.connection {
         /** Have all its parents (ie, relations that contain this object as a member, ways that contain this node) been loaded into memory */
         public var parentsLoaded:Boolean = true;
 
-        public function Entity(id:Number, version:uint, tags:Object, loaded:Boolean, uid:Number, timestamp:String) {
+        public function Entity(id:Number, version:uint, tags:Object, loaded:Boolean, uid:Number, timestamp:String, user:String) {
             this._id = id;
             this._version = version;
             this._uid = uid;
             this._timestamp = timestamp;
+            this._user = user
             this.tags = tags;
                        this._loaded = loaded;
             modified = id < 0;
@@ -62,9 +64,14 @@ package net.systemeD.halcyon.connection {
             return _timestamp;
         }
 
+        /** The username who last edited this entity (from OSM API). */
+        public function get user():String {
+            return _user;
+        }
+
         /** Set a bunch of properties in one hit. Implicitly makes entity not deleted. */
-        public function updateEntityProperties(version:uint, tags:Object, loaded:Boolean, parentsLoaded:Boolean, uid:Number, timestamp:String):void {
-            _version=version; this.tags=tags; _loaded=loaded; this.parentsLoaded=parentsLoaded; _uid = uid; _timestamp = timestamp;
+        public function updateEntityProperties(version:uint, tags:Object, loaded:Boolean, parentsLoaded:Boolean, uid:Number, timestamp:String, user:String):void {
+            _version=version; this.tags=tags; _loaded=loaded; this.parentsLoaded=parentsLoaded; _uid = uid; _timestamp = timestamp; _user = user;
             deleted=false;
         }
 
index 6056cc6..b6c0f44 100644 (file)
@@ -18,7 +18,7 @@ package net.systemeD.halcyon.connection {
                private var delayedEvents:Array = [];
 
         public function EntityCollection(entities:Array) {
-                       super(-1, 0, {}, true, -1, "");
+                       super(-1, 0, {}, true, NaN, null, null);
             _entities = entities;
                        
                        //To avoid firing on every contained entity, we wait some short time before firing the events
index 0180bfb..9d320eb 100644 (file)
@@ -11,7 +11,7 @@ package net.systemeD.halcyon.connection {
         private var _lon:Number;
 
         public function Marker(id:Number, version:uint, tags:Object, loaded:Boolean, lat:Number, lon:Number) {
-            super(id, version, tags, loaded, 0, null);
+            super(id, version, tags, loaded, NaN, null, null);
             this._lat = lat;
             this._latproj = lat2latp(lat);
             this._lon = lon;
index e185d3f..678e095 100644 (file)
@@ -7,15 +7,15 @@ package net.systemeD.halcyon.connection {
         private var _latproj:Number;
         private var _lon:Number;
 
-        public function Node(id:Number, version:uint, tags:Object, loaded:Boolean, lat:Number, lon:Number, uid:Number = NaN, timestamp:String = null) {
-            super(id, version, tags, loaded, uid, timestamp);
+        public function Node(id:Number, version:uint, tags:Object, loaded:Boolean, lat:Number, lon:Number, uid:Number = NaN, timestamp:String = null, user:String = null) {
+            super(id, version, tags, loaded, uid, timestamp, user);
             this._lat = lat;
             this._latproj = lat2latp(lat);
             this._lon = lon;
         }
 
-               public function update(version:uint, tags:Object, loaded:Boolean, parentsLoaded:Boolean, lat:Number, lon:Number, uid:Number = NaN, timestamp:String = null):void {
-                       updateEntityProperties(version,tags,loaded,parentsLoaded,uid,timestamp); setLatLonImmediate(lat,lon);
+               public function update(version:uint, tags:Object, loaded:Boolean, parentsLoaded:Boolean, lat:Number, lon:Number, uid:Number = NaN, timestamp:String = null, user:String = null):void {
+                       updateEntityProperties(version,tags,loaded,parentsLoaded,uid,timestamp,user); setLatLonImmediate(lat,lon);
                }
 
         public function get lat():Number {
index e6bdbd1..2f278e7 100644 (file)
@@ -6,19 +6,19 @@ package net.systemeD.halcyon.connection {
         private var members:Array;
                public static var entity_type:String = 'relation';
 
-        public function Relation(id:Number, version:uint, tags:Object, loaded:Boolean, members:Array, uid:Number = NaN, timestamp:String = null) {
-            super(id, version, tags, loaded, uid, timestamp);
+        public function Relation(id:Number, version:uint, tags:Object, loaded:Boolean, members:Array, uid:Number = NaN, timestamp:String = null, user:String = null) {
+            super(id, version, tags, loaded, uid, timestamp, user);
             this.members = members;
                        for each (var member:RelationMember in members)
                            member.entity.addParent(this);
         }
 
-        public function update(version:uint, tags:Object, loaded:Boolean, parentsLoaded:Boolean, members:Array, uid:Number = NaN, timestamp:String = null):void {
+        public function update(version:uint, tags:Object, loaded:Boolean, parentsLoaded:Boolean, members:Array, uid:Number = NaN, timestamp:String = null, user:String = null):void {
                        var member:RelationMember;
                        for each (member in this.members)
                            member.entity.removeParent(this);
 
-                       updateEntityProperties(version,tags,loaded,parentsLoaded,uid,timestamp);
+                       updateEntityProperties(version,tags,loaded,parentsLoaded,uid,timestamp,user);
                        this.members=members;
                        for each (member in members)
                            member.entity.addParent(this);
index 92d2655..bb5bdaf 100644 (file)
@@ -11,17 +11,17 @@ package net.systemeD.halcyon.connection {
                private var edge_b:Number;
                public static var entity_type:String = 'way';
 
-        public function Way(id:Number, version:uint, tags:Object, loaded:Boolean, nodes:Array, uid:Number = NaN, timestamp:String = null) {
-            super(id, version, tags, loaded, uid, timestamp);
+        public function Way(id:Number, version:uint, tags:Object, loaded:Boolean, nodes:Array, uid:Number = NaN, timestamp:String = null, user:String = null) {
+            super(id, version, tags, loaded, uid, timestamp, user);
             this.nodes = nodes;
                        for each (var node:Node in nodes) { node.addParent(this); }
                        calculateBbox();
         }
 
-               public function update(version:uint, tags:Object, loaded:Boolean, parentsLoaded:Boolean, nodes:Array, uid:Number = NaN, timestamp:String = null):void {
+               public function update(version:uint, tags:Object, loaded:Boolean, parentsLoaded:Boolean, nodes:Array, uid:Number = NaN, timestamp:String = null, user:String = null):void {
                        var node:Node;
                        for each (node in this.nodes) { node.removeParent(this); }
-                       updateEntityProperties(version,tags,loaded,parentsLoaded,uid,timestamp); this.nodes=nodes;
+                       updateEntityProperties(version,tags,loaded,parentsLoaded,uid,timestamp,user); this.nodes=nodes;
                        for each (node in nodes) { node.addParent(this); }
                        calculateBbox();
                }
index 391e498..47e30ab 100644 (file)
@@ -22,6 +22,7 @@ package net.systemeD.halcyon.connection {
             var version:uint;
             var uid:Number;
             var timestamp:String;
+            var user:String;
             var tags:Object;
             var node:Node, newNode:Node;
             var unusedNodes:Object={};
@@ -41,6 +42,7 @@ package net.systemeD.halcyon.connection {
                 version = uint(relData.@version);
                 uid = Number(relData.@uid);
                 timestamp = relData.@timestamp;
+                user = relData.@user;
                 
                 var rel:Relation = getRelation(id);
                 if ( rel == null || !rel.loaded ) {
@@ -78,9 +80,9 @@ package net.systemeD.halcyon.connection {
                     }
                     
                     if ( rel == null )
-                        setRelation(new Relation(id, version, tags, true, members, uid, timestamp), false);
+                        setRelation(new Relation(id, version, tags, true, members, uid, timestamp, user), false);
                     else {
-                        rel.update(version, tags, true, false, members, uid, timestamp);
+                        rel.update(version, tags, true, false, members, uid, timestamp, user);
                         sendEvent(new EntityEvent(NEW_RELATION, rel), false);
                     }
                 }
@@ -96,7 +98,8 @@ package net.systemeD.halcyon.connection {
                                                   Number(nodeData.@lat),
                                                   Number(nodeData.@lon),
                                                   Number(nodeData.@uid),
-                                                  nodeData.@timestamp);
+                                                  nodeData.@timestamp),
+                                                  nodeData.@user;
                                
                                if ( singleEntityRequest ) {
                                        // it's a revert request, so create/update the node
@@ -117,6 +120,7 @@ package net.systemeD.halcyon.connection {
                 version = uint(data.@version);
                 uid = Number(data.@uid);
                 timestamp = data.@timestamp;
+                user = data.@user;
 
                 var way:Way = getWay(id);
                 if ( way == null || !way.loaded || singleEntityRequest) {
@@ -130,10 +134,10 @@ package net.systemeD.halcyon.connection {
                                        }
                     tags = parseTags(data.tag);
                     if ( way == null ) {
-                        setWay(new Way(id, version, tags, true, nodes, uid, timestamp),false);
+                        setWay(new Way(id, version, tags, true, nodes, uid, timestamp, user),false);
                     } else {
                                                waycount++;
-                        way.update(version, tags, true, true, nodes, uid, timestamp);
+                        way.update(version, tags, true, true, nodes, uid, timestamp, user);
                         sendEvent(new EntityEvent(NEW_WAY, way), false);
                     }
                 }
index 394d9fe..4bbe914 100644 (file)
@@ -477,7 +477,8 @@ package net.systemeD.halcyon.connection {
                     Number(nodeData.@lat),
                     Number(nodeData.@lon),
                     Number(nodeData.@uid),
-                    nodeData.@timestamp);
+                    nodeData.@timestamp,
+                    nodeData.@user);
                 results.push(newNode);
             }
             // TODO implement ways and relations