remove objects from memory when changeset upload returns 'deleted'
authorRichard Fairhurst <richard@systemed.net>
Sat, 1 May 2010 11:09:59 +0000 (11:09 +0000)
committerRichard Fairhurst <richard@systemed.net>
Sat, 1 May 2010 11:09:59 +0000 (11:09 +0000)
net/systemeD/halcyon/connection/Connection.as
net/systemeD/halcyon/connection/XMLConnection.as

index 93e13958d82af1630ad032aeeeca704549e17409..c7d327ff319d69d1e269577d501e2d7f6b32f0a1 100755 (executable)
@@ -161,6 +161,18 @@ package net.systemeD.halcyon.connection {
             return relations[id];
         }
 
+               public function killNode(id:Number):void {
+                       delete nodes[id];
+               }
+               
+               public function killWay(id:Number):void {
+                       delete ways[id];
+               }
+               
+               public function killRelation(id:Number):void {
+                       delete relations[id];
+               }
+
         public function createNode(tags:Object, lat:Number, lon:Number, performCreate:Function):Node {
             var node:Node = new Node(nextNegative, 0, tags, true, lat, lon);
             performCreate(new CreateEntityAction(node, setNode));
index 8528ed51094b421c1ced24cab51490b8628be8e5..44f5441b165ddbd33fab1fc2b2ed7bf24d70c725 100644 (file)
@@ -263,19 +263,27 @@ package net.systemeD.halcyon.connection {
                 var newID:Number = Number(update.@new_id);
                 var version:uint = uint(update.@new_version);
                 var type:String = update.name();
+
+                               if (newID==0) {
+                                       // delete
+                       if ( type == "node" ) killNode(oldID);
+                       else if ( type == "way" ) killWay(oldID);
+                       else if ( type == "relation" ) killRelation(oldID);
+                                       
+                               } else {
+                                       // create/update
+                       var entity:Entity;
+                       if ( type == "node" ) entity = getNode(oldID);
+                       else if ( type == "way" ) entity = getWay(oldID);
+                       else if ( type == "relation" ) entity = getRelation(oldID);
+                       entity.markClean(newID, version);
                 
-                var entity:Entity;
-                if ( type == "node" ) entity = getNode(oldID);
-                else if ( type == "way" ) entity = getWay(oldID);
-                else if ( type == "relation" ) entity = getRelation(oldID);
-                entity.markClean(newID, version);
-                
-                if ( oldID != newID ) {
-                    if ( type == "node" ) renumberNode(oldID, entity as Node, false);
-                    else if ( type == "way" ) renumberWay(oldID, entity as Way, false);
-                    else if ( type == "relation" ) renumberRelation(oldID, entity as Relation, false);
-                }
-                // *** TODO *** handle deleting
+                       if ( oldID != newID ) {
+                           if ( type == "node" ) renumberNode(oldID, entity as Node, false);
+                           else if ( type == "way" ) renumberWay(oldID, entity as Way, false);
+                           else if ( type == "relation" ) renumberRelation(oldID, entity as Relation, false);
+                       }
+                               }
             }
 
                dispatchEvent(new SaveCompleteEvent(SAVE_COMPLETED, true));