Esempio n. 1
0
        /// <summary>
        /// if the given point is inside any objects return a list of their names
        /// </summary>
        /// <param name="longitude"></param>
        /// <param name="latitude"></param>
        /// <returns></returns>
        public ArrayList isInside(float longitude, float latitude)
        {
            ArrayList result = new ArrayList();

            for (int i = 0; i < Polygons.Count; i++)
            {
                kmlPlacemarkPolygon poly = (kmlPlacemarkPolygon)Polygons[i];
                if (poly.isInside(longitude, latitude))
                {
                    result.Add(poly.Name);
                }
            }
            return(result);
        }
Esempio n. 2
0
        /// <summary>
        /// returns the polygon with the given location name
        /// </summary>
        /// <param name="location_name"></param>
        /// <returns></returns>
        public kmlPlacemarkPolygon GetPolygon(String location_name)
        {
            kmlPlacemarkPolygon location = null;
            int i = 0;

            while ((i < Polygons.Count) && (location == null))
            {
                kmlPlacemarkPolygon poly = (kmlPlacemarkPolygon)Polygons[i];
                if (poly.Name == location_name)
                {
                    location = poly;
                }
                i++;
            }
            return(location);
        }
Esempio n. 3
0
        /// <summary>
        /// return an xml element
        /// </summary>
        /// <param name="doc">xml document to add the data to</param>
        /// <returns>an xml element</returns>
        public XmlElement getXml(XmlDocument doc)
        {
            XmlElement elem = doc.CreateElement("Document");

            doc.DocumentElement.AppendChild(elem);
            xml.AddTextElement(doc, elem, "name", Name);
            xml.AddTextElement(doc, elem, "description", Description);

            if (Polygons.Count > 0)
            {
                XmlElement elemPoly = doc.CreateElement("Polygons");
                elem.AppendChild(elemPoly);
                for (int i = 0; i < Polygons.Count; i++)
                {
                    kmlPlacemarkPolygon poly = (kmlPlacemarkPolygon)Polygons[i];
                    elemPoly.AppendChild(poly.getXml(doc));
                }
            }

            if (Points.Count > 0)
            {
                XmlElement elemPoints = doc.CreateElement("Points");
                elem.AppendChild(elemPoints);
                for (int i = 0; i < Points.Count; i++)
                {
                    kmlPlacemarkPoint pt = (kmlPlacemarkPoint)Points[i];
                    elemPoints.AppendChild(pt.getXml(doc));
                }
            }

            if (Paths.Count > 0)
            {
                XmlElement elemPaths = doc.CreateElement("Paths");
                elem.AppendChild(elemPaths);
                for (int i = 0; i < Paths.Count; i++)
                {
                    kmlPlacemarkPath path = (kmlPlacemarkPath)Paths[i];
                    elemPaths.AppendChild(path.getXml(doc));
                }
            }

            return(elem);
        }
Esempio n. 4
0
        /// <summary>
        /// parse an xml node to extract data
        /// </summary>
        /// <param name="xnod"></param>
        /// <param name="level"></param>
        public void LoadFromXml(XmlNode xnod, int level, String ObjectType)
        {
            XmlNode xnodWorking;

            if (xnod.Name == "name")
                Name = xnod.InnerText;

            if (xnod.Name == "description")
                Description = xnod.InnerText;

            if (xnod.Name == "Polygons")
            {
                ObjectType = xnod.Name;
                Polygons.Clear();
            }

            if (xnod.Name == "Points")
            {
                ObjectType = xnod.Name;
                Points.Clear();
            }

            if (xnod.Name == "Paths")
            {
                ObjectType = xnod.Name;
                Paths.Clear();
            }

            if (xnod.Name == "Placemark")
            {
                if (ObjectType == "Polygons")
                {
                    kmlPlacemarkPolygon poly = new kmlPlacemarkPolygon();
                    poly.LoadFromXml(xnod, level);
                    Polygons.Add(poly);
                }
                if (ObjectType == "Points")
                {
                    kmlPlacemarkPoint pt = new kmlPlacemarkPoint();
                    pt.LoadFromXml(xnod, level);
                    Points.Add(pt);
                }
                if (xnod.Name == "Paths")
                {
                    kmlPlacemarkPath path = new kmlPlacemarkPath();
                    path.LoadFromXml(xnod, level);
                    Paths.Add(path);
                }
            }

            // call recursively on all children of the current node
            if (xnod.HasChildNodes)
            {
                xnodWorking = xnod.FirstChild;
                while (xnodWorking != null)
                {
                    LoadFromXml(xnodWorking, level + 1, ObjectType);
                    xnodWorking = xnodWorking.NextSibling;
                }
            }
        }
Esempio n. 5
0
 public void Add(kmlPlacemarkPolygon polygon)
 {
     Polygons.Add(polygon);
 }
Esempio n. 6
0
        /// <summary>
        /// parse an xml node to extract data
        /// </summary>
        /// <param name="xnod"></param>
        /// <param name="level"></param>
        public void LoadFromXml(XmlNode xnod, int level, String ObjectType)
        {
            XmlNode xnodWorking;

            if (xnod.Name == "name")
            {
                Name = xnod.InnerText;
            }

            if (xnod.Name == "description")
            {
                Description = xnod.InnerText;
            }

            if (xnod.Name == "Polygons")
            {
                ObjectType = xnod.Name;
                Polygons.Clear();
            }

            if (xnod.Name == "Points")
            {
                ObjectType = xnod.Name;
                Points.Clear();
            }

            if (xnod.Name == "Paths")
            {
                ObjectType = xnod.Name;
                Paths.Clear();
            }

            if (xnod.Name == "Placemark")
            {
                if (ObjectType == "Polygons")
                {
                    kmlPlacemarkPolygon poly = new kmlPlacemarkPolygon();
                    poly.LoadFromXml(xnod, level);
                    Polygons.Add(poly);
                }
                if (ObjectType == "Points")
                {
                    kmlPlacemarkPoint pt = new kmlPlacemarkPoint();
                    pt.LoadFromXml(xnod, level);
                    Points.Add(pt);
                }
                if (xnod.Name == "Paths")
                {
                    kmlPlacemarkPath path = new kmlPlacemarkPath();
                    path.LoadFromXml(xnod, level);
                    Paths.Add(path);
                }
            }

            // call recursively on all children of the current node
            if (xnod.HasChildNodes)
            {
                xnodWorking = xnod.FirstChild;
                while (xnodWorking != null)
                {
                    LoadFromXml(xnodWorking, level + 1, ObjectType);
                    xnodWorking = xnodWorking.NextSibling;
                }
            }
        }
Esempio n. 7
0
 public void Add(kmlPlacemarkPolygon polygon)
 {
     Polygons.Add(polygon);
 }