Make wayuis, nodeuis and markeruis private
[potlatch2.git] / net / systemeD / potlatch2 / controller / SelectedWayNode.as
index 22e48029b7df830590ca7d268c1824507223d071..def771b7b0a71e0d4b329091ef2a71f6a0af2881 100644 (file)
@@ -174,12 +174,14 @@ package net.systemeD.potlatch2.controller {
 
         /** Attempt to either merge the currently selected node with another very nearby node, or failing that,
         *   attach it mid-way along a very nearby way. */
+               // FIXME: why are we only merging one node at once? after all, shift-click to insert a node adds into all ways
         public function join():ControllerState {
                        var p:Point = new Point(controller.map.lon2coord(Node(firstSelected).lon),
                                                controller.map.latp2coord(Node(firstSelected).latp));
             var q:Point = map.localToGlobal(p);
 
             // First, look for POI nodes in 20x20 pixel box around the current node
+                       // FIXME: why aren't we using a hitTest for this?
             var hitnodes:Array = editableLayer.connection.getObjectsByBbox(
                 map.coord2lon(p.x-10),
                 map.coord2lon(p.x+10),
@@ -192,21 +194,17 @@ package net.systemeD.potlatch2.controller {
                 }
             }
             
-            var ways:Array=[]; var w:Way;
-            for each (var wayui:WayUI in editableLayer.wayuis) {
-                w=wayui.hitTest(q.x, q.y);
-                if (w && w!=selectedWay) { 
+                       var ways:Array=editableLayer.findWaysAtPoint(q.x, q.y, selectedWay);
+                       for each (var w:Way in ways) {
                 // hit a way, now let's see if we hit a specific node
-                    for (var i:uint = 0; i < w.length; i++) {
-                       n = w.getNode(i);
-                       var x:Number = map.lon2coord(n.lon);
-                       var y:Number = map.latp2coord(n.latp);
-                       if (n != selectedNode && Math.abs(x-p.x) + Math.abs(y-p.y) < 10) {
-                            return doMergeNodes(n);
-                        }    
-                    }
-                    ways.push(w); 
-                }
+                for (var i:uint = 0; i < w.length; i++) {
+                                       n = w.getNode(i);
+                                       var x:Number = map.lon2coord(n.lon);
+                                       var y:Number = map.latp2coord(n.latp);
+                                       if (n != selectedNode && Math.abs(x-p.x) + Math.abs(y-p.y) < 10) {
+                                               return doMergeNodes(n);
+                                       }
+                               }
             }
 
             // No nodes hit, so join our node onto any overlapping ways.
@@ -219,6 +217,7 @@ package net.systemeD.potlatch2.controller {
             // only merge one node at a time - too confusing otherwise?
             var msg:String = "Nodes merged."
             if (MergeNodesAction.lastProblemTags) {
+                               // FIXME: ugh, just ugh.
                 msg += " *Warning* The following tags conflicted and need attention: " + MergeNodesAction.lastProblemTags;
             }
             // somethingorother.dispatchEvent(new AttentionEvent(AttentionEvent.ALERT, null, msg));