package net.systemeD.halcyon.connection {
import flash.geom.Point;
- import net.systemeD.halcyon.Globals;
- import net.systemeD.halcyon.connection.actions.*;
+
+ import net.systemeD.halcyon.connection.actions.*;
public class Way extends Entity {
private var nodes:Array;
calculateBbox();
}
- public function update(version:uint, tags:Object, loaded:Boolean, nodes:Array, uid:Number = NaN, timestamp:String = null):void {
+ public function update(version:uint, tags:Object, loaded:Boolean, parentsLoaded:Boolean, nodes:Array, uid:Number = NaN, timestamp:String = null):void {
var node:Node;
for each (node in this.nodes) { node.removeParent(this); }
- updateEntityProperties(version,tags,loaded,uid,timestamp); this.nodes=nodes;
+ updateEntityProperties(version,tags,loaded,parentsLoaded,uid,timestamp); this.nodes=nodes;
for each (node in nodes) { node.addParent(this); }
calculateBbox();
}
public function getLastNode():Node {
return nodes[nodes.length-1];
}
+
+ /** Given one node, return the next in sequence, cycling around a loop if necessary. */
+ // TODO make behave correctly for P-shaped topologies?
+ public function getNextNode(node:Node):Node {
+ // If the last node in a loop is selected, this behaves correctly.
+ var i:uint = indexOfNode(node);
+ if(i < length-1)
+ return nodes[i+1];
+ return null;
+ // What should happen for very short lengths?
+ }
+
+ // TODO make behave correctly for P-shaped topologies?
+ /** Given one node, return the previous, cycling around a loop if necessary. */
+ public function getPrevNode(node:Node):Node {
+ var i:uint = indexOfNode(node);
+ if(i > 0)
+ return nodes[i-1];
+ if(i == 0 && isArea() )
+ return nodes[nodes.length - 2]
+ return null;
+ // What should happen for very short lengths?
+ }
public function insertNode(index:uint, node:Node, performAction:Function):void {
performAction(new AddNodeToWayAction(this, node, nodes, index));
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));
}