示例#1
0
        public void TestAltMarkupData()
        {
            using (var stream = SampleData.CreateStream("Engine.Data.Entity Data.kml"))
            {
                KmlFile file = KmlFile.Load(stream);
                Placemark placemark = file.Root as Placemark;
                Assert.That(placemark, Is.Not.Null);

                EntityMapper mapper = new EntityMapper(file);
                mapper.ParseEntityFields(placemark);

                Assert.That(mapper.Entities.Count, Is.EqualTo(6));
                for (int i = 0; i < 4; ++i)
                {
                    Assert.That(mapper.Markup[i], Is.EqualTo(AltMarkup[i]));
                }

                // Assert that a second parse produces the same result (this
                // is different to the C++ version, which clears the Entities
                // but adds to the Markup - we reset both.
                mapper.ParseEntityFields(placemark);
                Assert.That(mapper.Entities.Count, Is.EqualTo(6));
                Assert.That(mapper.Markup.Count, Is.EqualTo(4));
            }
        }
示例#2
0
        public static void Run()
        {
            KmlFile file = Program.OpenFile("Enter a file to show the features of:");

            if ((file != null) && (file.Root != null))
            {
                EntityMapper mapper = new EntityMapper(file);
                foreach (var element in file.Root.Flatten())
                {
                    Feature feature = element as Feature;
                    if (feature != null)
                    {
                        string name = feature.Name ?? "Unnamed feature";
                        string balloon = mapper.CreateBalloonText(feature);

                        Console.WriteLine("Feature balloon text for '{0}'\n{1}\n", name, balloon);
                    }
                }
            }
        }
示例#3
0
        public void TestAltMarkupSchemaData()
        {
            using (var stream = SampleData.CreateStream("Engine.Data.Schema Data.kml"))
            {
                KmlFile file = KmlFile.Load(stream);
                Kml root = file.Root as Kml;
                Assert.That(root, Is.Not.Null);

                Document document = root.Feature as Document;
                Placemark placemark = document.Features.ElementAt(0) as Placemark;

                EntityMapper mapper = new EntityMapper(file);
                mapper.ParseEntityFields(placemark);

                for (int i = 0; i < 2; ++i)
                {
                    Assert.That(mapper.Markup[i], Is.EqualTo(SchemaMappings[i]));
                }
            }
        }
示例#4
0
        public void TestGetEntityFields()
        {
            using (var stream = SampleData.CreateStream("Engine.Data.Entities.kml"))
            {
                KmlFile file = KmlFile.Load(stream);
                Document document = file.Root as Document;
                Assert.That(document, Is.Not.Null);

                Placemark placemark = document.Features.ElementAt(0) as Placemark;
                EntityMapper mapper = new EntityMapper(file);
                mapper.ParseEntityFields(placemark);

                // Make sure it found everything
                Assert.That(mapper.Entities.Count, Is.EqualTo(ExpectedEntities.Count));
                foreach (var entry in mapper.Entities)
                {
                    Assert.That(entry.Value, Is.EqualTo(ExpectedEntities[entry.Key]));
                }
            }
        }
示例#5
0
        public void TestExpandEntities()
        {
            using (var stream = SampleData.CreateStream("Engine.Data.Entities.kml"))
            {
                KmlFile file = KmlFile.Load(stream);
                Document document = file.Root as Document;
                Assert.That(document, Is.Not.Null);

                Placemark placemark = document.Features.ElementAt(0) as Placemark;
                EntityMapper mapper = new EntityMapper(file);
                mapper.ParseEntityFields(placemark);

                // Verify that CreateExpandedEntities handles various kinds of
                // entity references, spacing, multiple references.
                foreach (var replacement in Replacements)
                {
                    Assert.That(mapper.ExpandEntities(replacement.Item1), Is.EqualTo(replacement.Item2));
                }
            }
        }