コード例 #1
0
ファイル: TestLineString.cs プロジェクト: atlefren/GeomDiff
        public void TestApplyDelete()
        {
            var p    = ReadWkt <LineString>("LINESTRING(1 1, 2 2, 3 3, 4 4)");
            var diff = new LineStringDiff()
            {
                Operation = Operation.Delete,
                Index     = 0,
                Value     = new List <PointDiff>()
                {
                    new PointDiff()
                    {
                        Index = 0, Operation = Operation.Noop, Value = new CoordinateDelta()
                        {
                            X = 1, Y = 1
                        }
                    },
                    new PointDiff()
                    {
                        Index = 1, Operation = Operation.Noop, Value = new CoordinateDelta()
                        {
                            X = 2, Y = 2
                        }
                    },
                    new PointDiff()
                    {
                        Index = 2, Operation = Operation.Noop, Value = new CoordinateDelta()
                        {
                            X = 3, Y = 3
                        }
                    },
                    new PointDiff()
                    {
                        Index = 3, Operation = Operation.Noop, Value = new CoordinateDelta()
                        {
                            X = 4, Y = 4
                        }
                    }
                }
            };
            var n = diff.Apply(p);

            Assert.IsNull(n);
        }
コード例 #2
0
ファイル: TestLineString.cs プロジェクト: atlefren/GeomDiff
        public void TestApplyCreate()
        {
            LineString p    = null;
            var        diff = new LineStringDiff()
            {
                Operation = Operation.Insert,
                Index     = 0,
                Value     = new List <PointDiff>()
                {
                    new PointDiff()
                    {
                        Index = 0, Operation = Operation.Insert, Value = new CoordinateDelta()
                        {
                            X = 1, Y = 1
                        }
                    },
                    new PointDiff()
                    {
                        Index = 1, Operation = Operation.Insert, Value = new CoordinateDelta()
                        {
                            X = 2, Y = 2
                        }
                    },
                    new PointDiff()
                    {
                        Index = 2, Operation = Operation.Insert, Value = new CoordinateDelta()
                        {
                            X = 3, Y = 3
                        }
                    }
                }
            };
            var n = diff.Apply(p);

            var p2 = ReadWkt <LineString>("LINESTRING(1 1, 2 2, 3 3)");

            Assert.AreEqual(WriteWkt(p2), WriteWkt(n));
        }
コード例 #3
0
ファイル: TestLineString.cs プロジェクト: atlefren/GeomDiff
        public void TestApplyModify()
        {
            var p    = ReadWkt <LineString>("LINESTRING(1 1, 2 2, 3 3, 4 4)");
            var diff = new LineStringDiff()
            {
                Operation = Operation.Modify,
                Index     = 0,
                Value     = new List <PointDiff>()
                {
                    new PointDiff()
                    {
                        Index = 0, Operation = Operation.Insert, Value = new CoordinateDelta()
                        {
                            X = 0, Y = 0
                        }
                    },
                    new PointDiff()
                    {
                        Index = 1, Operation = Operation.Modify, Value = new CoordinateDelta()
                        {
                            X = 0.5, Y = 0.5
                        }
                    },
                    new PointDiff()
                    {
                        Index = 3, Operation = Operation.Delete, Value = new CoordinateDelta()
                        {
                            X = 4, Y = 4
                        }
                    }
                }
            };
            var n = diff.Apply(p);

            var p2 = ReadWkt <LineString>("LINESTRING(0 0, 1 1, 2.5 2.5, 3 3)");

            Assert.AreEqual(WriteWkt(p2), WriteWkt(n));
        }
コード例 #4
0
 private static void Write(LineStringDiff diff, BinaryWriter writer, bool hasZ)
 => WriteList(diff.Value.Cast <IDiff>().ToList(), writer, hasZ);