registerPOI for vector background layers
authorRichard Fairhurst <richard@systemed.net>
Sun, 7 Nov 2010 18:06:23 +0000 (18:06 +0000)
committerRichard Fairhurst <richard@systemed.net>
Sun, 7 Nov 2010 18:06:23 +0000 (18:06 +0000)
TODO.txt
net/systemeD/halcyon/VectorLayer.as
net/systemeD/halcyon/connection/Trace.as
net/systemeD/potlatch2/utils/GpxImporter.as

index 870f3bf..07004c0 100644 (file)
--- a/TODO.txt
+++ b/TODO.txt
@@ -3,8 +3,6 @@ Potlatch 2: main outstanding issues
 
 == Core geometry ==
 
-* purgeOutside simply doesn't work - WayUIs stay around. To investigate
-* Some combination of zoom / pan / purge leaves a copy of the selected WayUI around
 * P1-style J (join) / shift-J (unjoin)
 
 == Vector background layers ==
index e97a1cf..38fe519 100644 (file)
@@ -18,6 +18,7 @@ package net.systemeD.halcyon {
                public var ways:Object=new Object();                    // geodata
                public var nodes:Object=new Object();                   //  |
                public var relations:Object=new Object();               //  |
+               private var pois:Array=[];                                              //  |
         private var negativeID:Number = -1;
 
                public function VectorLayer(n:String,m:Map,s:String) {
@@ -48,6 +49,13 @@ package net.systemeD.halcyon {
                        relations[negativeID]=relation; negativeID--;
             return relation;
                }
+        public function registerPOI(node:Node):void {
+            if (pois.indexOf(node)<0) { pois.push(node); }
+        }
+        public function unregisterPOI(node:Node):void {
+                       var index:uint = pois.indexOf(node);
+                       if ( index >= 0 ) { pois.splice(index,1); }
+        }
 
                public function getObjectsByBbox(left:Number, right:Number, top:Number, bottom:Number):Object {
                        // ** FIXME: this is just copied-and-pasted from Connection.as, which really isn't very
@@ -57,10 +65,9 @@ package net.systemeD.halcyon {
                                if (way.within(left,right,top,bottom)) { o.waysInside.push(way); }
                                                                  else { o.waysOutside.push(way); }
                        }
-                       // ** FIXME: this needs to do POIs, not nodes (i.e. we need registerPOI for vector layers too)
-                       for each (var poi:Node in nodes) {
+                       for each (var poi:Node in pois) {
                                if (poi.within(left,right,top,bottom)) { o.poisInside.push(poi); }
-                                                                  else { o.poisOutside.push(poi); }
+                                                                 else { o.poisOutside.push(poi); }
                        }
                        return o;
                }
@@ -97,7 +104,8 @@ package net.systemeD.halcyon {
                        } else if (entity is Node && !entity.hasParentWays) {
                                // copy node through to main layer
                                // ** should be properly undoable
-                               oldNode=Node(entity)
+                               oldNode=Node(entity);
+                               unregisterPOI(oldNode);
                                var newPoiAction:CreatePOIAction = new CreatePOIAction(
                                        oldNode.getTagsCopy(), oldNode.lat, oldNode.lon);
                                MainUndoStack.getGlobalStack().addAction(newPoiAction);
@@ -111,7 +119,7 @@ package net.systemeD.halcyon {
                public function blank():void {
                        for each (var node:Node in nodes) { paint.deleteNodeUI(node); }
                        for each (var way:Way in ways) { paint.deleteWayUI(way); }
-                       relations={}; nodes={}; ways={};
+                       relations={}; nodes={}; ways={}; pois=[];
                }
 
        }
index 70ee06f..7e0e2a9 100644 (file)
@@ -122,7 +122,8 @@ package net.systemeD.halcyon.connection {
                 for each (var tag:XML in wpt.children()) {
                     tags[tag.name()]=tag.toString();
                 }
-                layer.createNode(tags, wpt.@lat, wpt.@lon);
+                var node:Node=layer.createNode(tags, wpt.@lat, wpt.@lon);
+                               layer.registerPOI(node);
             }
             layer.paint.redraw();
         }
index 46621c7..03532c6 100644 (file)
@@ -8,7 +8,7 @@ package net.systemeD.potlatch2.utils {
 
     /**
     * Implements parsing and loading of GPX files.
-    * For loading GPX traces from the OSM API, see halcyon/connenction/Trace.as
+    * For loading GPX traces from the OSM API, see halcyon/connection/Trace.as
     */
        public class GpxImporter extends Importer {
 
@@ -40,7 +40,8 @@ package net.systemeD.potlatch2.utils {
                                for each (var tag:XML in wpt.children()) {
                                        tags[tag.name()]=tag.toString();
                                }
-                               container.createNode(tags, wpt.@lat, wpt.@lon);
+                               var node:Node=container.createNode(tags, wpt.@lat, wpt.@lon);
+                               container.registerPOI(node);
                        }
                }
        }