1 package net.systemeD.halcyon.connection.actions {
3 import net.systemeD.halcyon.connection.*;
5 public class MergeWaysAction extends CompositeUndoableAction {
8 private var toPos:uint;
9 private var fromPos:uint;
10 // ** FIXME: not at all elegant having these stuffed in static variables; we should probably use events instead
11 static public var lastTagsMerged:Boolean;
12 static public var lastRelationsMerged:Boolean;
14 public function MergeWaysAction(way1:Way, way2:Way, toPos:uint, fromPos:uint) {
15 super("Merge ways "+way1.id+" "+way2.id);
19 this.fromPos = fromPos;
20 lastTagsMerged = false;
21 lastRelationsMerged = false;
24 public override function doAction():uint {
25 // subactions are added to the composite list -- we then
26 // execute them all at the bottom. Doing it this way gives
27 // us an automatic undo
32 lastTagsMerged = way1.mergeTags(way2,push);
42 public override function undoAction():uint {
50 public function mergeRelations():void {
51 for each (var r:Relation in way2.parentRelations) {
52 // ** needs to copy roles as well
53 if (r.findEntityMemberIndex(way1)==-1) {
54 r.appendMember(new RelationMember(way1, ''), push);
55 lastRelationsMerged=true;
61 public function mergeNodes():void {
64 for (i = 0; i < way2.length; i++)
65 way1.addToEnd(toPos, way2.getNode(i), push);
67 for (i = way2.length-1; i >= 0; i--)
68 way1.addToEnd(toPos, way2.getNode(i), push);