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;
11 public function MergeWaysAction(way1:Way, way2:Way, toPos:uint, fromPos:uint) {
12 super("Merge ways "+way1.id+" "+way2.id);
16 this.fromPos = fromPos;
19 public override function doAction():uint {
20 // subactions are added to the composite list -- we then
21 // execute them all at the bottom. Doing it this way gives
22 // us an automatic undo
37 public override function undoAction():uint {
45 public function mergeRelations():void {
46 for each (var r:Relation in way2.parentRelations) {
47 // ** needs to copy roles as well
48 if (r.findEntityMemberIndex(way1)==-1) {
49 r.appendMember(new RelationMember(way1, ''), push);
54 public function mergeTags():void {
55 var way1Tags:Object = way1.getTagsHash();
56 var way2Tags:Object = way2.getTagsHash();
57 for (var k:String in way2Tags) {
58 var v1:String = way1Tags[k];
59 var v2:String = way2Tags[k];
60 if ( v1 && v1 != v2) {
61 way1.setTag(k, v1+"; "+v2, push);
62 // ** send a warning about tags not matching
64 way1.setTag(k, v2, push);
69 public function mergeNodes():void {
72 for (i = 0; i < way2.length; i++)
73 way1.addToEnd(toPos, way2.getNode(i), push);
75 for (i = way2.length-1; i >= 0; i--)
76 way1.addToEnd(toPos, way2.getNode(i), push);