more delete
authorRichard Fairhurst <richard@systemed.net>
Sun, 10 Jan 2010 11:31:17 +0000 (11:31 +0000)
committerRichard Fairhurst <richard@systemed.net>
Sun, 10 Jan 2010 11:31:17 +0000 (11:31 +0000)
net/systemeD/halcyon/WayUI.as
net/systemeD/halcyon/connection/Way.as
net/systemeD/potlatch2/controller/SelectedWay.as

index ced3c61..3f1f22b 100755 (executable)
@@ -32,6 +32,7 @@ package net.systemeD.halcyon {
             way.addEventListener(Connection.TAG_CHANGE, wayTagChanged);
             way.addEventListener(Connection.WAY_NODE_ADDED, wayNodeAdded);
             way.addEventListener(Connection.WAY_NODE_REMOVED, wayNodeRemoved);
+                       way.addEventListener(Connection.WAY_DELETED, wayDeleted);
             attachNodeListeners();
                }
                
@@ -57,6 +58,10 @@ package net.systemeD.halcyon {
         private function nodeMoved(event:NodeMovedEvent):void {
             redraw();
         }
+               private function wayDeleted(event:EntityEvent):void {
+                       Globals.vars.root.addDebug("waydeleted fired on "+way.length+":"+event.entity);
+                       redraw();
+               }
 
                private function init():void {
                        recalculate();
@@ -75,6 +80,7 @@ package net.systemeD.halcyon {
                        var cx:Number=0, cy:Number=0;
                        pathlength=0;
                        patharea=0;
+                       if (way.length==0) { return; }
                        
                        lx = way.getNode(way.length-1).lon;
                        ly = way.getNode(way.length-1).latp;
@@ -190,6 +196,7 @@ package net.systemeD.halcyon {
                        // Draw icons
                        // ** there should be huge potential to optimise this - at present we're
                        //    running getStyles for every node in the way on every redraw
+                       // ** fix r/heading behaviour - that doesn't look right
                        var r:Number;
                        var nodetags:Object;
                        var nodeSelected:int=stateClasses["nodeSelected"];
index 2dd503f..de13b55 100644 (file)
@@ -97,7 +97,6 @@ package net.systemeD.halcyon.connection {
 
                public function mergeWith(way:Way,topos:int,frompos:int):void {
                        var i:int;
-                       Globals.vars.root.addDebug("way "+id+", merging with "+way.id+", adding to "+topos+" , from "+frompos);
 
                        // merge relations
                        for each (var r:Relation in way.parentRelations) {
@@ -123,11 +122,10 @@ package net.systemeD.halcyon.connection {
                                           else { for (i=way.length-1; i>=0; i--) { addToEnd(topos,way.getNode(i)); } }
 
                        // delete way
-                       
+                       way.remove();
                }
                
                private function addToEnd(topos:int,node:Node):void {
-                       Globals.vars.root.addDebug("adding "+node.id+" at "+topos);
                        if (topos==0) {
                                if (nodes[0]==node) { return; }
                                prependNode(node);
index d4d4f7e..217bf11 100644 (file)
@@ -84,6 +84,7 @@ package net.systemeD.potlatch2.controller {
 
                        // ** needs to prefer positive to negative IDs
                        // find common point
+                       if (way==selectedWay) { return false; }
                        if      (selectedWay.getNode(0)   ==way.getNode(0)   ) { selectedWay.mergeWith(way,0,0); }
                        else if (selectedWay.getNode(0)   ==way.getLastNode()) { selectedWay.mergeWith(way,0,way.length-1); }
                        else if (selectedWay.getLastNode()==way.getNode(0)   ) { selectedWay.mergeWith(way,selectedWay.length-1,0); }