Esempio n. 1
0
        private static void ProcessDelete(DeleteCollection delete, KmlFile file)
        {
            foreach (Feature source in delete)
            {
                if (source.TargetId != null)
                {
                    if (file.FindObject(source.TargetId) is Feature feature)
                    {
                        // Remove the Feature from the parent, which is either
                        // a Container or Kml
                        if (feature.Parent is Container container)
                        {
                            container.RemoveFeature(source.TargetId);
                        }
                        else
                        {
                            if (feature.Parent is Kml kml)
                            {
                                kml.Feature = null;
                            }
                        }

                        // Also remove it from the file
                        file.RemoveFeature(feature);
                    }
                }
            }
        }
Esempio n. 2
0
        private void GatherSchemaDataFields(SchemaData schemaData)
        {
            string prefix = "/";

            if (schemaData.SchemaUrl != null)
            {
                string id = schemaData.SchemaUrl.GetFragment();
                if (id != null) // Make sure a fragment was found
                {
                    Schema schema = _file.FindObject(id) as Schema;
                    if (schema != null) // Make sure it was found and the object is a Schema
                    {
                        foreach (var field in schema.Fields)
                        {
                            this.GatherSimpleFieldFields(field, schema);
                        }
                        this.PopulateSimpleFieldNameMap(schema);
                        prefix = schema.Name + prefix;
                    }
                }
            }

            foreach (var data in schemaData.SimpleData)
            {
                this.GatherSimpleDataFields(data, prefix);
            }
        }
        private static void ProcessDelete(DeleteCollection delete, KmlFile file)
        {
            foreach (var source in delete)
            {
                if (source.TargetId != null)
                {
                    Feature feature = file.FindObject(source.TargetId) as Feature;
                    if (feature != null)
                    {
                        // Remove the Feature from the parent, which is either
                        // a Container or Kml
                        Container container = feature.Parent as Container;
                        if (container != null)
                        {
                            container.RemoveFeature(source.TargetId);
                        }
                        else
                        {
                            Kml kml = feature.Parent as Kml;
                            if (kml != null)
                            {
                                kml.Feature = null;
                            }
                        }

                        // Also remove it from the file
                        file.RemoveFeature(feature);
                    }
                }
            }
        }
Esempio n. 4
0
 private static void ProcessChange(ChangeCollection change, KmlFile file)
 {
     foreach (KmlObject source in change)
     {
         if (source.TargetId != null)
         {
             KmlObject target = file.FindObject(source.TargetId);
             if (target != null)
             {
                 target.Merge(source);
                 target.TargetId = null; // Merge copied the TargetId from the source, but target shouldn't have it set
             }
         }
     }
 }
Esempio n. 5
0
 private static void ProcessCreate(CreateCollection create, KmlFile file)
 {
     foreach (Container source in create)
     {
         if (source.TargetId != null)
         {
             // Make sure it was found and that the target was a Container
             if (file.FindObject(source.TargetId) is Container target)
             {
                 foreach (Feature feature in source.Features)
                 {
                     Feature clone = feature.Clone(); // We never give the original source.
                     target.AddFeature(clone);
                     file.AddFeature(clone);
                 }
             }
         }
     }
 }