split ways by pressing X (needs a shiny button!)
authorRichard Fairhurst <richard@systemed.net>
Sat, 9 Jan 2010 15:51:49 +0000 (15:51 +0000)
committerRichard Fairhurst <richard@systemed.net>
Sat, 9 Jan 2010 15:51:49 +0000 (15:51 +0000)
TODO.txt
net/systemeD/halcyon/connection/Way.as
net/systemeD/potlatch2/controller/SelectedWayNode.as

index 2c31e1e..dd57efa 100644 (file)
--- a/TODO.txt
+++ b/TODO.txt
@@ -1,5 +1,4 @@
 Potlatch 2: main outstanding issues
-(last updated 30th November 2009)
 -----------------------------------
 
 == Code tidying ==
@@ -11,7 +10,7 @@ Potlatch 2: main outstanding issues
 == Core geometry ==
 
 * Delete points and ways
-* Split and merge ways
+* Merge ways
 * Drag-and-drop POIs
 * Undo/redo
 * Reverse way direction
@@ -26,6 +25,8 @@ Potlatch 2: main outstanding issues
 
 == Server interaction ==
 
+* Should redraw members of a relation when the relation is loaded
+
 
 == UI ==
 
@@ -44,3 +45,4 @@ Potlatch 2: main outstanding issues
   (difficult because styles are decided before drawing)
 * Shields
 * Complete MapCSS support
+* Would be useful to be able to 'suspend' redrawing
index 735284c..1abcbc3 100644 (file)
@@ -64,6 +64,13 @@ package net.systemeD.halcyon.connection {
                        // ** we should send an event to delete the entire way
                }
 
+               public function sliceNodes(start:int,end:int):Array {
+                       return nodes.slice(start,end);
+               }
+
+               public function deleteNodesFrom(start:int):void {
+                       nodes.splice(start);
+               }
 
 
         /**
index c21e772..fc15185 100644 (file)
@@ -67,6 +67,13 @@ package net.systemeD.potlatch2.controller {
             return this;
         }
 
+               override public function processKeyboardEvent(event:KeyboardEvent):ControllerState {
+                       switch (event.keyCode) {
+                               case 88:        return splitWay();
+                       }
+                       return this;
+               }
+               
                override public function enterState():void {
             selectNode(initWay,initNode);
                        Globals.vars.root.addDebug("**** -> "+this);
@@ -90,5 +97,28 @@ package net.systemeD.potlatch2.controller {
                        else
                            return new DrawWay(selectedWay, isLast, true);
         }
+
+               public function splitWay():ControllerState {
+                       // abort if start or end
+                       if (selectedWay.getNode(0                   ) == selectedNode) { return this; }
+                       if (selectedWay.getNode(selectedWay.length-1) == selectedNode) { return this; }
+                       Globals.vars.root.addDebug("splitting way at "+selectedWay.indexOfNode(selectedNode));
+
+                       // create new way
+                       var newWay:Way = controller.connection.createWay(
+                               selectedWay.getTagsCopy(), 
+                               selectedWay.sliceNodes(selectedWay.indexOfNode(selectedNode),selectedWay.length));
+                       selectedWay.deleteNodesFrom(selectedWay.indexOfNode(selectedNode)+1);
+                       
+                       // copy relations
+                       for each (var r:Relation in selectedWay.parentRelations) {
+                               // ** needs to copy roles as well
+                               r.appendMember(new RelationMember(newWay, ''));
+                       }
+                       controller.map.ways[newWay.id].redraw();
+
+                       return new SelectedWay(selectedWay);
+               }
+
     }
 }