Separate Halcyon (rendering) into standalone target without Flex dependency; JavaScri...
[potlatch2.git] / net / systemeD / halcyon / connection / Way.as
1 package net.systemeD.halcyon.connection {
2
3     public class Way extends Entity {
4         private var nodes:Array;
5                 public static var entity_type:String = 'way';
6
7         public function Way(id:Number, version:uint, tags:Object, nodes:Array) {
8             super(id, version, tags);
9             this.nodes = nodes;
10         }
11
12         public function get length():uint {
13             return nodes.length;
14         }
15         
16         public function getNode(index:uint):Node {
17             return nodes[index];
18         }
19
20         public function insertNode(index:uint, node:Node):void {
21             nodes.splice(index, 0, node);
22         }
23
24         public function appendNode(node:Node):uint {
25             nodes.push(node);
26             return nodes.length;
27         }
28
29         public function removeNode(index:uint):void {
30             nodes.splice(index, 1);
31         }
32
33         public override function toString():String {
34             return "Way("+id+"@"+version+"): "+getTagList()+
35                      " "+nodes.map(function(item:Node,index:int, arr:Array):String {return item.id.toString();}).join(",");
36         }
37
38                 public function isArea():Boolean {
39                         return (nodes[0].id==nodes[nodes.length-1].id  && nodes.length>2);
40                 }
41
42                 public override function getType():String {
43                         return 'way';
44                 }
45     }
46
47 }