Add an angle calculation for ways
authorAndy Allan <gravitystorm@gmail.com>
Tue, 25 Jan 2011 18:52:18 +0000 (18:52 +0000)
committerAndy Allan <gravitystorm@gmail.com>
Tue, 25 Jan 2011 18:52:18 +0000 (18:52 +0000)
net/systemeD/halcyon/connection/Way.as

index f34fb89..6a8aa59 100644 (file)
@@ -218,6 +218,16 @@ package net.systemeD.halcyon.connection {
                        return left;
                }
 
+        public function get angle():Number {
+            var dx:Number = nodes[nodes.length-1].lon - nodes[0].lon;
+            var dy:Number = nodes[nodes.length-1].latp - nodes[0].latp;
+            if (dx != 0 || dy != 0) {
+                return Math.atan2(dx,dy)*(180/Math.PI);
+            } else {
+                return 0;
+            }
+        }
+
                internal override function isEmpty():Boolean {
                        return (deleted || (nodes.length==0));
                }