public AutomationDiff(Song.Automation a, Song.Automation b, int index) { this.a = a; this.b = b; this.index = index; deviceIndex = a.DeviceIndex != b.DeviceIndex; paramId = a.ParamId != b.ParamId; if (a.DeltaCodedPoints.Count != b.DeltaCodedPoints.Count) { pointCounts = true; } else { for (int i = 0; i < a.Points.Count; i++) { var aPoint = a.DeltaCodedPoints[i]; var bPoint = b.DeltaCodedPoints[i]; var pointDiff = new PointDiff(aPoint, bPoint, i); if (!pointDiff.IsEmpty) { pointDiffs.Add(pointDiff); } } } }
public void TestApplyDelete() { var p = ReadWkt <Point>("POINT(10.53 60.10)"); var diff = new PointDiff() { Index = 0, Operation = Operation.Delete, Value = new CoordinateDelta() { X = 1, Y = 2 } }; var n = diff.Apply(p); Assert.AreEqual(null, n); }
public void TestApplyCreate() { var diff = new PointDiff() { Index = 0, Operation = Operation.Insert, Value = new CoordinateDelta() { X = 1, Y = 2 } }; var n = diff.Apply(null); var p2 = ReadWkt <Point>("POINT(1 2)"); Assert.AreEqual(p2, n); }
public void TestReverseModify() { var diff = new PointDiff() { Index = 0, Operation = Operation.Modify, Value = new CoordinateDelta() { X = -0.01 } }; var reversed = (PointDiff)diff.Reverse(); Assert.AreEqual(0, reversed.Index); Assert.AreEqual(Operation.Modify, reversed.Operation); Assert.AreEqual(0.01, reversed.Value.X); }
public void TestReverseDelete() { var diff = new PointDiff() { Index = 0, Operation = Operation.Delete, Value = new CoordinateDelta() { X = 1, Y = 2 } }; var reversed = (PointDiff)diff.Reverse(); Assert.AreEqual(0, reversed.Index); Assert.AreEqual(Operation.Insert, reversed.Operation); Assert.AreEqual(1, reversed.Value.X); Assert.AreEqual(2, reversed.Value.Y); }
public void TestApplyModify() { var p = ReadWkt <Point>("POINT(10.53 60.10)"); var diff = new PointDiff() { Index = 0, Operation = Operation.Modify, Value = new CoordinateDelta() { X = -0.01 } }; var n = diff.Apply(p); var p2 = ReadWkt <Point>("POINT(10.52 60.10)"); Assert.AreEqual(p2, n); }
private static void Write(PointDiff diff, BinaryWriter writer, bool hasZ) => WriteCoordinate(diff.Value, writer, hasZ);