예제 #1
0
        public string GetMultiTrackKml()
        {
            trackNo = trackNo + 1;
            Kml      kml             = NewGxKml();
            Document updatedDocument = GetUpdatedDocument();

            if (trackNo == 1)
            {
                kml.Feature = updatedDocument;
                return(StringOf(kml));
            }

            CreateCollection createCollection = new CreateCollection();

            createCollection.Add(updatedDocument);

            Update update = new Update();

            update.AddUpdate(createCollection);

            NetworkLinkControl networkLinkControl = new NetworkLinkControl();

            networkLinkControl.Cookie = $"seq={lastSeq}";
            networkLinkControl.Update = update;

            kml.NetworkLinkControl = networkLinkControl;
            return(StringOf(kml));
        }
예제 #2
0
        public void TestManyDeletes()
        {
            const int NumberOfFolders = 100;

            var folder = new Folder();

            for (int i = 0; i < NumberOfFolders; ++i)
            {
                folder.AddFeature(CreateFeature(i, true)); // Add the features with their Id set
            }
            Assert.That(folder.Features.Count(), Is.EqualTo(NumberOfFolders));

            var file   = KmlFile.Create(folder, false);
            var update = new Update();

            for (int i = 0; i < NumberOfFolders; ++i)
            {
                var delete = new DeleteCollection
                {
                    CreateFeature(i, false) // This time set the TargetId
                };
                update.AddUpdate(delete);
            }
            update.Process(file);
            Assert.That(folder.Features.Count(), Is.EqualTo(0));
        }
예제 #3
0
        public static void Run()
        {
            // Create our Kml
            var folder = new Folder();

            folder.Id   = "f0";
            folder.Name = "Folder 0";

            var placemark = new Placemark();

            placemark.Id   = "pm0";
            placemark.Name = "Placemark 0";
            folder.AddFeature(placemark);

            placemark      = new Placemark();
            placemark.Id   = "pm1";
            placemark.Name = "Placemark 1";
            folder.AddFeature(placemark);

            var kml = new Kml();

            kml.Feature = folder;

            // Display to the user
            var serializer = new Serializer();

            serializer.Serialize(kml);
            Console.WriteLine("Original Kml:\n" + serializer.Xml);

            // This is what we're going to change to
            placemark          = new Placemark();
            placemark.Geometry = new Point {
                Coordinate = new Vector(38, -120)
            };
            placemark.Name     = "new name";
            placemark.TargetId = "pm0";

            var update = new Update();

            update.AddUpdate(new ChangeCollection()
            {
                placemark
            });

            serializer.Serialize(update);
            Console.WriteLine("\nUpdate:\n" + serializer.Xml);

            // Run the update
            var file = KmlFile.Create(kml, false);

            update.Process(file);

            serializer.Serialize(kml);
            Console.WriteLine("\nUpdated Kml:\n" + serializer.Xml);
        }
예제 #4
0
        public void TestChangeCoordinates()
        {
            // Create the target
            var point = new Point
            {
                Coordinate = new Vector(38.38, -122.122)
            };

            var placemark = new Placemark
            {
                Id       = "placemark123",
                Geometry = point,
                Name     = "placemark name"
            };

            var file = KmlFile.Create(placemark, false);

            // Now create the Update
            const double latitude  = -38.38;
            const double longitude = 122.122;

            point = new Point
            {
                Coordinate = new Vector(latitude, longitude)
            };

            placemark = new Placemark
            {
                Geometry = point,
                TargetId = "placemark123"
            };

            var change = new ChangeCollection {
                placemark
            };

            var update = new Update();

            update.AddUpdate(change);

            // Now test the update worked
            update.Process(file);

            placemark = file.Root as Placemark;
            Assert.That(placemark, Is.Not.Null);
            Assert.That(placemark.Id, Is.EqualTo("placemark123"));
            Assert.That(placemark.Name, Is.EqualTo("placemark name"));

            point = placemark.Geometry as Point;
            Assert.That(point, Is.Not.Null);
            Assert.That(point.Coordinate.Latitude, Is.EqualTo(latitude));
            Assert.That(point.Coordinate.Longitude, Is.EqualTo(longitude));
        }
예제 #5
0
        public void TestInlineUpdate()
        {
            var document = new Document();

            document.AddStyle(new Style {
                Id = "style0"
            });

            var create = new CreateCollection {
                document
            };

            var update = new Update();

            update.AddUpdate(create);

            Update output = StyleResolver.InlineStyles(update);

            // Make sure it didn't change anything
            SampleData.CompareElements(update, output);
        }