示例#1
0
        /// <summary>
        /// Set data from XML fragment and list of coordinates
        /// </summary>
        /// <param name="pmdata">Placemark XML fragment</param>
        /// <param name="ns">XML namespace</param>
        /// <param name="coords">String with coordinate list</param>
        /// <remarks>
        /// This method is only used as base for inhertance
        /// </remarks>
        public void SetData(XmlNode pmdata, XmlNamespaceManager ns, string coords)
        {
            Nodes = new List <IKmlItem>();
            XmlNode nodeName = pmdata.SelectSingleNode("ns:name", ns);

            if (nodeName != null)
            {
                Name = nodeName.InnerText;
            }
            else
            {
                Name = "No Name";
            }
            string re = @" ";

            string[] result = Regex.Split(coords, re);
            foreach (string item in result)
            {
                string triple = item.Trim();
                if (triple != "")
                {
                    Placemark node = new Placemark();
                    node.SetCoord(triple);
                    Nodes.Add(node);
                }
            }
        }
        /// <summary>
        /// Set data from XML fragment
        /// </summary>
        /// <param name="pmdata">Placemark XML fragment</param>
        /// <param name="ns">XML namespace</param>
        public void SetData(XmlNode pmdata, XmlNamespaceManager ns)
        {
            Nodes = new List <IKmlItem>();

            XmlNodeList points = pmdata.SelectNodes("gx:Track/gx:coord", ns);

            foreach (XmlNode point in points)
            {
                Placemark node   = new Placemark();
                string    triple = point.InnerText.Trim().Replace(' ', ',');
                node.SetCoord(triple);
                Nodes.Add(node);
            }
        }