Create the concept of Marker entities, and use them for bugs
authorAndy Allan <gravitystorm@gmail.com>
Tue, 16 Nov 2010 15:01:01 +0000 (15:01 +0000)
committerAndy Allan <gravitystorm@gmail.com>
Tue, 16 Nov 2010 15:01:01 +0000 (15:01 +0000)
net/systemeD/halcyon/VectorLayer.as
net/systemeD/halcyon/connection/Marker.as [new file with mode: 0644]
net/systemeD/potlatch2/utils/BugLoader.as

index e833573..9fcacfe 100644 (file)
@@ -25,6 +25,8 @@ package net.systemeD.halcyon {
                public var nodes:Object=new Object();                   //  |
                public var relations:Object=new Object();               //  |
                private var pois:Array=[];                                              //  |
+
+        private var markers:Object=new Object();        // markers
         private var negativeID:Number = -1;
 
         /** Create a new VectorLayer
@@ -75,6 +77,13 @@ package net.systemeD.halcyon {
                        relations[negativeID]=relation; negativeID--;
             return relation;
                }
+
+        public function createMarker(tags:Object,lat:Number,lon:Number:Marker {
+            var marker:Marker = new Marker(negativeID, 0, tags, true, lat, lon);
+            markers[negativeID]=node; negativeID--;
+            return marker;
+        }
+
         public function registerPOI(node:Node):void {
             if (pois.indexOf(node)<0) { pois.push(node); }
         }
diff --git a/net/systemeD/halcyon/connection/Marker.as b/net/systemeD/halcyon/connection/Marker.as
new file mode 100644 (file)
index 0000000..673cba7
--- /dev/null
@@ -0,0 +1,46 @@
+package net.systemeD.halcyon.connection {
+
+
+    /**
+    * A marker is a generic entity that can be used for representing non-Node point features.
+    * For example, it can be used for displaying bug reports or waypoints on VectorBackground layers
+    */
+    public class Marker extends Entity {
+        private var _lat:Number;
+        private var _latproj:Number;
+        private var _lon:Number;
+
+        public function Marker(id:Number, version:uint, tags:Object, loaded:Boolean, lat:Number, lon:Number) {
+            super(id, version, tags, loaded, uid, timestamp);
+            this._lat = lat;
+            this._latproj = lat2latp(lat);
+            this._lon = lon;
+        }
+
+        public function get lat():Number {
+            return _lat;
+        }
+
+        public function get latp():Number {
+            return _latproj;
+        }
+
+        public function get lon():Number {
+            return _lon;
+        }
+
+        public static function lat2latp(lat:Number):Number {
+            return 180/Math.PI * Math.log(Math.tan(Math.PI/4+lat*(Math.PI/180)/2));
+        }
+
+        public static function latp2lat(a:Number):Number {
+            return 180/Math.PI * (2 * Math.atan(Math.exp(a*Math.PI/180)) - Math.PI/2);
+        }
+
+        public override function toString():String {
+            return "Marker("+id+"@"+version+"): "+lat+","+lon+" "+getTagList();
+        }
+
+        public override function getType():String {
+            return 'node';
+        }
\ No newline at end of file
index 43de9e9..267587f 100644 (file)
@@ -40,7 +40,7 @@ package net.systemeD.potlatch2.utils {
               var lon:Number = feature.geometry.coordinates[0];
               var lat:Number = feature.geometry.coordinates[1];
               trace(lat, lon);
-              var node:Node = layer.createNode({"name":feature.properties.description,"bug_id":feature.id}, lat, lon);
+              var node:Node = layer.createMarker({"name":feature.properties.description,"bug_id":feature.id}, lat, lon);
               layer.registerPOI(node);
             }
             layer.paint.updateEntityUIs(layer.getObjectsByBbox(map.edge_l,map.edge_r,map.edge_t,map.edge_b), false, false);