Basic way history for the moment
authorAndy Allan <gravitystorm@gmail.com>
Fri, 25 Feb 2011 19:53:26 +0000 (19:53 +0000)
committerTom Hughes <tom@compton.nu>
Wed, 9 Mar 2011 10:57:58 +0000 (10:57 +0000)
net/systemeD/halcyon/connection/XMLConnection.as
net/systemeD/potlatch2/history/HistoryDialog.mxml

index 4bbe914..7f8c3a1 100644 (file)
@@ -469,8 +469,12 @@ package net.systemeD.halcyon.connection {
         private function loadedHistory(event:Event):void {
             var _xml:XML = new XML(ExtendedURLLoader(event.target).data);
             var results:Array = [];
+
+            // only one type of entity should be returned, but this handles any
+
             for each(var nodeData:XML in _xml.node) {
-                var newNode:Node = new Node(Number(nodeData.@id),
+                var newNode:Node = new Node(
+                    Number(nodeData.@id),
                     uint(nodeData.@version),
                     parseTags(nodeData.tag),
                     true,
@@ -478,10 +482,32 @@ package net.systemeD.halcyon.connection {
                     Number(nodeData.@lon),
                     Number(nodeData.@uid),
                     nodeData.@timestamp,
-                    nodeData.@user);
+                    nodeData.@user
+                    );
                 results.push(newNode);
             }
-            // TODO implement ways and relations
+
+            for each(var wayData:XML in _xml.way) {
+                var nodes:Array = [];
+                for each(var nd:XML in wayData.nd) {
+                  nodes.push(new Node(Number(nd.ref), NaN, null, false, NaN, NaN));
+                }
+                var newWay:Way = new Way(
+                    Number(wayData.@id),
+                    uint(wayData.@version),
+                    parseTags(wayData.tag),
+                    true,
+                    nodes,
+                    Number(wayData.@uid),
+                    wayData.@timestamp,
+                    wayData.@user
+                    );
+                results.push(newWay);
+            }
+
+            for each(var relData:XML in _xml.relation) {
+                trace("relation history not implemented");
+            }
 
             // use the callback we stored earlier, and pass it the results
             ExtendedURLLoader(event.target).info['callback'](results);
index aa183c5..8765cd1 100644 (file)
@@ -82,6 +82,8 @@
     private function fetchHistory():void {
         if (entity is Node) {
             Connection.getConnection().fetchHistory(entity, processNode);
+        } else if (entity is Way) {
+            Connection.getConnection().fetchHistory(entity, processWay);
         } else {
             // not implemented
         }
         entityStates = results.reverse();
     }
 
+    private function processWay(results:Array):void {
+        // This is much more complicated that nodes.
+        // In potlatch(2) we show the user the number of different states, bearing in mind
+        // node movements (and tag changes?).
+        entityStates = results.reverse(); // mwahahaha, for now
+    }
+
     public function message(entity:Entity):void {
         if (entity.user != null) {
             var urlBase:String = Connection.getConnectionInstance().apiBase + '../../message/new/';