Пример #1
0
        public void TestReverseDelete()
        {
            var diff = new MultiPointDiff()
            {
                Index     = 0,
                Operation = Operation.Delete,
                Value     = new List <PointDiff>()
                {
                    new PointDiff()
                    {
                        Index = 0, Operation = Operation.Delete, Value = new CoordinateDelta()
                        {
                            X = 1, Y = 2
                        }
                    },
                    new PointDiff()
                    {
                        Index = 1, Operation = Operation.Delete, Value = new CoordinateDelta()
                        {
                            X = 3, Y = 3
                        }
                    }
                }
            };
            var reversed = (MultiPointDiff)diff.Reverse();

            Assert.AreEqual(0, reversed.Index);
            Assert.AreEqual(Operation.Insert, reversed.Operation);
        }
Пример #2
0
        public void TestApplyDelete()
        {
            var p    = ReadWkt <MultiPoint>("MULTIPOINT((2 2), (3 3))");
            var diff = new MultiPointDiff()
            {
                Index     = 0,
                Operation = Operation.Delete,
                Value     = new List <PointDiff>()
                {
                    new PointDiff()
                    {
                        Index = 0, Operation = Operation.Delete, Value = new CoordinateDelta()
                        {
                            X = 1, Y = 2
                        }
                    },
                    new PointDiff()
                    {
                        Index = 1, Operation = Operation.Delete, Value = new CoordinateDelta()
                        {
                            X = 3, Y = 3
                        }
                    }
                }
            };
            var n = diff.Apply(p);

            Assert.IsNull(n);
        }
Пример #3
0
        public void TestApplyCreate()
        {
            MultiPoint p    = null;
            var        diff = new MultiPointDiff()
            {
                Index     = 0,
                Operation = Operation.Insert,
                Value     = new List <PointDiff>()
                {
                    new PointDiff()
                    {
                        Index = 0, Operation = Operation.Insert, Value = new CoordinateDelta()
                        {
                            X = 1, Y = 2
                        }
                    },

                    new PointDiff()
                    {
                        Index = 1, Operation = Operation.Insert, Value = new CoordinateDelta()
                        {
                            X = 3, Y = 3
                        }
                    }
                }
            };
            var n  = diff.Apply(p);
            var p2 = ReadWkt <MultiPoint>("MULTIPOINT((1 2), (3 3))");

            Assert.AreEqual(WriteWkt(p2), WriteWkt(n));
        }
Пример #4
0
        public void TestReverseModify()
        {
            var diff = new MultiPointDiff()
            {
                Index     = 0,
                Operation = Operation.Modify,
                Value     = new List <PointDiff>()
                {
                    new PointDiff()
                    {
                        Index = 0, Operation = Operation.Insert, Value = new CoordinateDelta()
                        {
                            X = 1, Y = 2
                        }
                    },
                    new PointDiff()
                    {
                        Index = 0, Operation = Operation.Modify, Value = new CoordinateDelta()
                        {
                            X = -0.5, Y = 0.5
                        }
                    },
                    new PointDiff()
                    {
                        Index = 1, Operation = Operation.Delete, Value = new CoordinateDelta()
                        {
                            X = 3, Y = 3
                        }
                    }
                }
            };
            var reversed = (MultiPointDiff)diff.Reverse();

            Assert.AreEqual(0, reversed.Index);
            Assert.AreEqual(Operation.Modify, reversed.Operation);
            Assert.AreEqual(3, reversed.Value.Count);

            var d1 = reversed.Value[0];

            Assert.AreEqual(Operation.Delete, d1.Operation);
            Assert.AreEqual(0, d1.Index);
            Assert.AreEqual(1, d1.Value.X);
            Assert.AreEqual(2, d1.Value.Y);

            var d2 = reversed.Value[1];

            Assert.AreEqual(Operation.Modify, d2.Operation);
            Assert.AreEqual(1, d2.Index);
            Assert.AreEqual(0.5, d2.Value.X);
            Assert.AreEqual(-0.5, d2.Value.Y);

            var d3 = reversed.Value[2];

            Assert.AreEqual(Operation.Insert, d3.Operation);
            Assert.AreEqual(2, d3.Index);
            Assert.AreEqual(3, d3.Value.X);
            Assert.AreEqual(3, d3.Value.Y);
        }
Пример #5
0
        public void TestApplyModify()
        {
            var p    = ReadWkt <MultiPoint>("MULTIPOINT((2 2), (3 3))");
            var diff = new MultiPointDiff()
            {
                Index     = 0,
                Operation = Operation.Modify,
                Value     = new List <PointDiff>()
                {
                    new PointDiff()
                    {
                        Index = 0, Operation = Operation.Insert, Value = new CoordinateDelta()
                        {
                            X = 1, Y = 2
                        }
                    },
                    new PointDiff()
                    {
                        Index = 0, Operation = Operation.Modify, Value = new CoordinateDelta()
                        {
                            X = -0.5, Y = 0.5
                        }
                    },
                    new PointDiff()
                    {
                        Index = 1, Operation = Operation.Delete, Value = new CoordinateDelta()
                        {
                            X = 3, Y = 3
                        }
                    }
                }
            };
            var n  = diff.Apply(p);
            var p2 = ReadWkt <MultiPoint>("MULTIPOINT((1 2), (1.5 2.5))");

            Assert.AreEqual(WriteWkt(p2), WriteWkt(n));
        }
Пример #6
0
 private static void Write(MultiPointDiff diff, BinaryWriter writer, bool hasZ)
 => WriteList(diff.Value.Cast <IDiff>().ToList(), writer, hasZ);