Exemplo n.º 1
0
                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);
                            }
                        }
                    }
                }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
 private static void Write(PointDiff diff, BinaryWriter writer, bool hasZ)
 => WriteCoordinate(diff.Value, writer, hasZ);