POIs, and relations, and stuff :)
[potlatch2.git] / net / systemeD / halcyon / connection / Node.as
1 package net.systemeD.halcyon.connection {
2
3     public class Node extends Entity {
4         private var _lat:Number;
5         private var _latproj:Number;
6         private var _lon:Number;
7
8         public function Node(id:Number, version:uint, tags:Object, loaded:Boolean, lat:Number, lon:Number) {
9             super(id, version, tags, loaded);
10             this.lat = lat;
11             this.lon = lon;
12         }
13
14                 public function update(version:uint, tags:Object, loaded:Boolean, lat:Number, lon:Number):void {
15                         updateEntityProperties(version,tags,loaded); this.lat=lat; this.lon=lon;
16                 }
17
18         public function get lat():Number {
19             return _lat;
20         }
21
22         public function get latp():Number {
23             return _latproj;
24         }
25
26         public function get lon():Number {
27             return _lon;
28         }
29
30         public function set lat(lat:Number):void {
31             var oldLat:Number = this._lat;
32             this._lat = lat;
33             this._latproj = lat2latp(lat);
34             markDirty();
35             dispatchEvent(new NodeMovedEvent(Connection.NODE_MOVED, this, oldLat, _lon));
36         }
37
38         public function set latp(latproj:Number):void {
39             this._latproj = latproj;
40             this._lat = latp2lat(lat);
41         }
42
43         public function set lon(lon:Number):void {
44             this._lon = lon;
45         }
46
47         public override function toString():String {
48             return "Node("+id+"@"+version+"): "+lat+","+lon+" "+getTagList();
49         }
50
51         public static function lat2latp(lat:Number):Number {
52             return 180/Math.PI * Math.log(Math.tan(Math.PI/4+lat*(Math.PI/180)/2));
53         }
54
55                 public function latp2lat(a:Number):Number {
56                     return 180/Math.PI * (2 * Math.atan(Math.exp(a*Math.PI/180)) - Math.PI/2);
57                 }
58                 
59                 public override function getType():String {
60                         return 'node';
61                 }
62     }
63
64 }