Exemplo n.º 1
0
        private sd.ExtendedData ExtendedData(Dictionary <string, string> dicData)
        {
            if (dicData is null)
            {
                return(new sd.ExtendedData());
            }
            var exdata = new sd.ExtendedData();

            foreach (var data in dicData)
            {
                string value = data.Value;
                if (data.Value.Length == 0)
                {
                    value = "Нет данных";
                }
                var dataDoc = new sd.Data
                {
                    Name  = data.Key,
                    Value = value
                };
                exdata.AddData(dataDoc);
            }

            return(exdata);
        }
Exemplo n.º 2
0
        public void AddPoint(Point point, string idStyle, Dictionary <string, string> dicData, sd.Folder folder = null)
        {
            var pointDoc = new sd.Point
            {
                Coordinate = new sb.Vector(point.Lon, point.Lat)
            };

            var exdata = new sd.ExtendedData();

            foreach (var data in dicData)
            {
                var dataDoc = new sd.Data
                {
                    Name  = data.Key,
                    Value = data.Value
                };
                exdata.AddData(dataDoc);
            }

            var placemark = new sd.Placemark
            {
                Name         = point.Name,
                Geometry     = pointDoc,
                StyleUrl     = new Uri($"#{idStyle}"),
                ExtendedData = exdata
            };

            if (folder == null)
            {
                Document.AddFeature(placemark);
            }
            else
            {
                folder.AddFeature(placemark);
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Creates an ExtendedData KML element from a graphic's attributes.
 /// </summary>
 /// <param name="attributes">A dictionary of graphic attributes</param>
 /// <returns></returns>
 public static ExtendedData ToExtendedData(Dictionary<string, object> attributes)
 {
     var datas = from kvp in attributes
                 where !_geometryInNameRe.IsMatch( kvp.Key)
                 select new Data
                 {
                     Name = kvp.Key,
                     //Value = kvp.Value?.ToString() // VS 2015
                     Value = kvp.Value != null ? kvp.Value.ToString() : null
                 };
     var xData = new ExtendedData();
     foreach (var data in datas)
     {
         xData.AddData(data);
     }
     return xData;
 }