示例#1
0
 /// <summary>
 /// Extracts the placemarks from the feature.
 /// </summary>
 /// <param name="feature">The feature.</param>
 /// <param name="placemarks">The list to add the placemark to.</param>
 private static void ExtractPlacemarks(Dom.Feature feature, List <Dom.Placemark> placemarks)
 {
     // Is the passed in value a Placemark?
     Dom.Placemark placemark = feature as Dom.Placemark;
     if (placemark != null)
     {
         placemarks.Add(placemark);
     }
     else
     {
         // Is it a Container, as the Container might have a child Placemark?
         Dom.Container container = feature as Dom.Container;
         if (container == null)
         {
             return;
         }
         // Check each Feature to see if it's a Placemark or another Container
         foreach (var f in container.Features)
         {
             ExtractPlacemarks(f, placemarks);
         }
     }
 }
 TreeViewItem ProcessFeature(Feature feature)
 {
     if (feature is Document)
     {
         return ProcessDocument(feature as Document);
     }
     else if (feature is Folder)
     {
         return ProcessFolder(feature as Folder);
     }
     else if (feature is Placemark)
     {
         return ProcessPlacemark(feature as Placemark);
     }
     else if (feature is Container)
     {
         return ProcessContainer(feature as Container);
     }
     return null;
 }
        private static void ExpandBox(Feature feature, BoundingBox box)
        {
            Placemark placemark = feature as Placemark;
            if (placemark != null)
            {
                GeometryExtensions.ExpandBox(placemark.Geometry, box); // Can pass in nulls
                return;
            }

            Container container = feature as Container;
            if (container != null)
            {
                foreach (var f in container.Features)
                {
                    ExpandBox(f, box);
                }

                return;
            }

            // It's not a placemark or container, try it as a IBoundsInformation
            // and allow the conversion to fail
            GeometryExtensions.ExpandBox(feature as IBoundsInformation, box);
        }
示例#4
0
 private static void ExtractPlacemarks(Feature feature, List<Placemark> placemarks)
 {
     var placemark = feature as Placemark;
     if (!string.IsNullOrEmpty(placemark?.Name) && !placemark.Name.StartsWith("Line #"))
     {
         placemarks.Add(placemark);
     }
     else
     {
         var container = feature as Container;
         if (container == null) return;
         foreach (var f in container.Features)
         {
             ExtractPlacemarks(f, placemarks);
         }
     }
 }
        private void GetExtendedDataFields(Feature feature)
        {
            if (feature.ExtendedData != null)
            {
                foreach (var data in feature.ExtendedData.Data)
                {
                    this.GatherDataFields(data);
                }

                foreach (var schema in feature.ExtendedData.SchemaData)
                {
                    this.GatherSchemaDataFields(schema);
                }
            }
        }
        private void GetFeatureFields(Feature feature)
        {
            // KmlObject's fields
            AddtoDictionary(_map, "id", feature.Id);
            AddtoDictionary(_map, "targetId", feature.TargetId);

            // Feature's fields
            // TODO: OGC KML 2.2 does not single out specific elements -
            // any simple field or attribute of Feature is an entity candidate,
            // however, these are the select few chosen by the C++ version
            AddtoDictionary(_map, "name", feature.Name);
            AddtoDictionary(_map, "address", feature.Address);
            AddtoDictionary(_map, "Snippet", feature.Snippet);
            AddtoDictionary(_map, "description", feature.Description);
        }
        /// <summary>
        /// Maps all replaceable entities in the specified <see cref="Feature"/>.
        /// </summary>
        /// <param name="feature">
        /// The <c>Feature</c> to search for replaceable entities.
        /// </param>
        /// <exception cref="ArgumentNullException">feature is null.</exception>
        public void ParseEntityFields(Feature feature)
        {
            if (feature == null)
            {
                throw new ArgumentNullException("feature");
            }

            _fieldMap.Clear();
            _map.Clear();
            _markup.Clear();

            this.GetFeatureFields(feature);
            this.GetExtendedDataFields(feature);
        }
示例#8
0
 private static object[] GetAssetProperties(Feature f)
 {
     return new object[]
     {
         f.Id,
         f.StyleUrl != null ? f.StyleUrl.ToString().Replace("#", "") : "",
         f
     };
 }
 void ProcessFeature(Feature feature)
 {
     if (feature is Document)
     {
         ProcessDocument(feature as Document);
     }
 }
示例#10
-1
 private static void ExtractPlacemarks(Feature feature, List<Placemark> placemarks)
 {
     if (feature is Placemark)
     {
         placemarks.Add(feature as Placemark);
     }
     else if (feature is Container)
     {
         foreach (var f in ((Container)feature).Features)
             ExtractPlacemarks(f, placemarks);
     }
 }
示例#11
-1
        /// <summary>
        /// Creates a balloon text for the specified feature, calling
        /// <see cref="ParseEntityFields"/> to gather information.
        /// </summary>
        /// <param name="feature">The feature to create a balloon text for.</param>
        /// <returns>
        /// The expanded version of the feature's balloon text, if specified;
        /// otherwise an automatically generated HTML summary of the feature.
        /// </returns>
        /// <exception cref="ArgumentNullException">feature is null.</exception>
        /// <remarks>
        /// By default this method will not resolve any external styles.
        /// </remarks>
        public string CreateBalloonText(Feature feature)
        {
            this.ParseEntityFields(feature); // Will throw is feature is null

            Style style = StyleResolver.CreateResolvedStyle(feature, this.file, StyleState.Normal);
            if ((style.Balloon != null) && (style.Balloon.Text != null))
            {
                return this.ExpandEntities(style.Balloon.Text);
            }

            // If the Balloon doesn't exist or doesn't have any text then we'll
            // make an HTML default table.
            StringBuilder html = new StringBuilder();
            if (feature.Name != null)
            {
                html.Append("<h3>");
                html.Append(feature.Name);
                html.Append("</h3><br/><br/>");
            }

            if ((feature.Description != null) && (feature.Description.Text != null))
            {
                html.Append(this.ExpandEntities(feature.Description.Text));
            }

            // Now a table of the extended data
            if (this.markup.Count != 0)
            {
                html.AppendLine("\n<table border=\"1\">");
                foreach (var data in this.markup)
                {
                    html.Append("<tr><td>");
                    html.Append(data.Item1);
                    html.Append("</td><td>");
                    html.Append(data.Item2);
                    html.AppendLine("</tr>");
                }
            }

            return html.ToString();
        }
示例#12
-1
 private static void ExtractPlacemarks(Feature feature, List<Placemark> placemarks)
 {
     // Is the passed in value a Placemark?
     Placemark placemark = feature as Placemark;
     if (placemark != null)
     {
         placemarks.Add(placemark);
     }
     else
     {
         // Is it a Container, as the Container might have a child Placemark?
         Container container = feature as Container;
         if (container != null)
         {
             // Check each Feature to see if it's a Placemark or another Container
             foreach (var f in container.Features)
             {
                 ExtractPlacemarks(f, placemarks);
             }
         }
     }
 }
 public void SetFeature(Feature feature)
 {
     _feature = feature;
     ProcessSchema();
 }
示例#14
-1
 /// <summary>
 /// Adds the specified <see cref="Feature"/> to this instance.
 /// </summary>
 /// <param name="feature">The <c>Feature</c> to add to this instance.</param>
 /// <exception cref="ArgumentNullException">feature is null.</exception>
 /// <exception cref="InvalidOperationException">
 /// feature belongs to another <see cref="Element"/>.
 /// </exception>
 public void AddFeature(Feature feature)
 {
     this.AddChild(feature);
 }