Merge pull request #47 from stevage/parking-types
[potlatch2.git] / net / systemeD / potlatch2 / controller / DragWayNode.as
index 1b618fd95004daed25b20fc291bffd9317227718..b8c7911ef89aae28938a74aff29f378bf5d83d60 100644 (file)
@@ -33,19 +33,13 @@ package net.systemeD.potlatch2.controller {
         }
 
         private function addNode(selectedWay:Way,event:MouseEvent):int {
-                       // find which other ways are under the mouse
-                       var ways:Array=[]; var w:Way;
-                       for each (var wayui:WayUI in editableLayer.wayuis) {
-                               w=wayui.hitTest(event.stageX, event.stageY);
-                               if (w && w!=selectedWay) { ways.push(w); }
-                       }
-
+                       var ways:Array = layer.findWaysAtPoint(event.stageX, event.stageY, selectedWay);
             var lat:Number = controller.map.coord2lat(event.localY);
             var lon:Number = controller.map.coord2lon(event.localX);
             var undo:CompositeUndoableAction = new CompositeUndoableAction("Insert node");
             var node:Node = selectedWay.connection.createNode({}, lat, lon, undo.push);
             var index:int = selectedWay.insertNodeAtClosestPosition(node, true, undo.push);
-                       for each (w in ways) { w.insertNodeAtClosestPosition(node, true, undo.push); }
+                       for each (var w:Way in ways) { w.insertNodeAtClosestPosition(node, true, undo.push); }
             MainUndoStack.getGlobalStack().addAction(undo);
                        return index;
         }
@@ -115,17 +109,17 @@ package net.systemeD.potlatch2.controller {
                        originalLat = draggingNode.lat;
                        originalLon = draggingNode.lon;
 
-                       editableLayer.setHighlightOnNodes(parentWay, { selectedway: true } );
-                       editableLayer.limitWayDrawing(parentWay, draggingIndex);
-                       editableLayer.setHighlight(draggingNode, { selected: true } );
-                       editableLayer.protectWay(parentWay);
-                       editableLayer.limitWayDrawing(parentWay, NaN, draggingIndex);
+                       layer.setHighlightOnNodes(parentWay, { selectedway: true } );
+                       layer.limitWayDrawing(parentWay, draggingIndex);
+                       layer.setHighlight(draggingNode, { selected: true } );
+                       layer.protectWay(parentWay);
+                       layer.limitWayDrawing(parentWay, NaN, draggingIndex);
         }
         override public function exitState(newState:ControllerState):void {
-                       editableLayer.unprotectWay(parentWay);
-                       editableLayer.limitWayDrawing(parentWay);
-                       editableLayer.setHighlightOnNodes(parentWay, { selectedway: false } );
-                       editableLayer.setHighlight(draggingNode, { selected: false } );
+                       layer.unprotectWay(parentWay);
+                       layer.limitWayDrawing(parentWay);
+                       layer.setHighlightOnNodes(parentWay, { selectedway: false } );
+                       layer.setHighlight(draggingNode, { selected: false } );
         }
         override public function toString():String {
             return "DragWayNode";