Exemplo n.º 1
0
 private static void Write(MultiLineStringDiff diff, BinaryWriter writer, bool hasZ)
 => WriteList(diff.Value.Cast <IDiff>().ToList(), writer, hasZ);
Exemplo n.º 2
0
        public void TestApplyCreate()
        {
            MultiLineString p    = null;
            var             diff = new MultiLineStringDiff()
            {
                Operation = Operation.Insert,
                Index     = 0,
                Value     = new List <LineStringDiff>()
                {
                    new LineStringDiff()
                    {
                        Index     = 0,
                        Operation = Operation.Insert,
                        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
                                }
                            },
                            new PointDiff()
                            {
                                Index = 3, Operation = Operation.Insert, Value = new CoordinateDelta()
                                {
                                    X = 4, Y = 4
                                }
                            }
                        }
                    },
                    new LineStringDiff()
                    {
                        Index     = 1,
                        Operation = Operation.Insert,
                        Value     = new List <PointDiff>()
                        {
                            new PointDiff()
                            {
                                Index = 0, Operation = Operation.Insert, Value = new CoordinateDelta()
                                {
                                    X = 10, Y = 10
                                }
                            },
                            new PointDiff()
                            {
                                Index = 1, Operation = Operation.Insert, Value = new CoordinateDelta()
                                {
                                    X = 20, Y = 20
                                }
                            }
                        }
                    }
                }
            };


            var n = diff.Apply(p);

            var p2 = ReadWkt <MultiLineString>("MULTILINESTRING((1 1, 2 2, 3 3, 4 4), (10 10, 20 20))");

            Assert.AreEqual(WriteWkt(p2), WriteWkt(n));
        }
Exemplo n.º 3
0
        public void TestApplyModify()
        {
            var p    = ReadWkt <MultiLineString>("MULTILINESTRING((1 1, 2 2, 3 3, 4 4), (10 10, 20 20))");
            var diff = new MultiLineStringDiff()
            {
                Operation = Operation.Modify,
                Index     = 0,
                Value     = new List <LineStringDiff>()
                {
                    new LineStringDiff()
                    {
                        Index     = 0,
                        Operation = Operation.Modify,
                        Value     = new List <PointDiff>()
                        {
                            new PointDiff()
                            {
                                Index = 0, Operation = Operation.Insert, Value = new CoordinateDelta()
                                {
                                    X = 0, Y = 0
                                }
                            },
                            new PointDiff()
                            {
                                Index = 0, 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
                                }
                            }
                        }
                    },
                    new LineStringDiff()
                    {
                        Index     = 1,
                        Operation = Operation.Delete,
                        Value     = new List <PointDiff>()
                        {
                            new PointDiff()
                            {
                                Index = 0, Operation = Operation.Delete, Value = new CoordinateDelta()
                                {
                                    X = 10, Y = 10
                                }
                            },
                            new PointDiff()
                            {
                                Index = 1, Operation = Operation.Delete, Value = new CoordinateDelta()
                                {
                                    X = 20, Y = 20
                                }
                            }
                        }
                    },
                    new LineStringDiff()
                    {
                        Index     = 1,
                        Operation = Operation.Insert,
                        Value     = new List <PointDiff>()
                        {
                            new PointDiff()
                            {
                                Index = 0, Operation = Operation.Insert, Value = new CoordinateDelta()
                                {
                                    X = 4, Y = 5
                                }
                            },
                            new PointDiff()
                            {
                                Index = 1, Operation = Operation.Insert, Value = new CoordinateDelta()
                                {
                                    X = 6, Y = 7
                                }
                            }
                        }
                    }
                }
            };
            var n  = diff.Apply(p);
            var p2 = ReadWkt <MultiLineString>("MULTILINESTRING((0 0, 1.5 1.5, 2 2, 3 3), (4 5, 6 7))");

            Assert.AreEqual(WriteWkt(p2), WriteWkt(n));
        }
Exemplo n.º 4
0
        public void TestApplyDelete()
        {
            var p    = ReadWkt <MultiLineString>("MULTILINESTRING((1 1, 2 2, 3 3, 4 4), (10 10, 20 20))");
            var diff = new MultiLineStringDiff()
            {
                Operation = Operation.Delete,
                Index     = 0,
                Value     = new List <LineStringDiff>()
                {
                    new LineStringDiff()
                    {
                        Index     = 0,
                        Operation = Operation.Delete,
                        Value     = new List <PointDiff>()
                        {
                            new PointDiff()
                            {
                                Index = 0, Operation = Operation.Delete, Value = new CoordinateDelta()
                                {
                                    X = 0, Y = 0
                                }
                            },
                            new PointDiff()
                            {
                                Index = 1, Operation = Operation.Delete, Value = new CoordinateDelta()
                                {
                                    X = 0.5, Y = 0.5
                                }
                            },
                            new PointDiff()
                            {
                                Index = 3, Operation = Operation.Delete, Value = new CoordinateDelta()
                                {
                                    X = 4, Y = 4
                                }
                            }
                        }
                    },
                    new LineStringDiff()
                    {
                        Index     = 1,
                        Operation = Operation.Delete,
                        Value     = new List <PointDiff>()
                        {
                            new PointDiff()
                            {
                                Index = 0, Operation = Operation.Delete, Value = new CoordinateDelta()
                                {
                                    X = 10, Y = 10
                                }
                            },
                            new PointDiff()
                            {
                                Index = 1, Operation = Operation.Delete, Value = new CoordinateDelta()
                                {
                                    X = 20, Y = 20
                                }
                            }
                        }
                    }
                }
            };
            var n = diff.Apply(p);

            Assert.IsNull(n);
        }