Exemplo n.º 1
0
        internal KMLPolygon(XmlElement element, KMLPlacemark owner, KMLFile source)
            : base(element, owner, source)
        {
            foreach (XmlNode oChild in element.ChildNodes)
            {
                if (oChild.NodeType != XmlNodeType.Element) continue;
                XmlElement oChildElement = oChild as XmlElement;

                if (oChildElement.Name.Equals("extrude"))
                {
                    m_blExtrude = oChildElement.InnerText.Equals("1");
                }
                else if (oChildElement.Name.Equals("extrude"))
                {
                    m_blTessellate = oChildElement.InnerText.Equals("1");
                }
                else if (oChildElement.Name.Equals("altitudeMode"))
                {
                    m_eAltitudeMode = (KMLAltitudeMode)Enum.Parse(typeof(KMLAltitudeMode), oChildElement.InnerText);
                }
                else if (oChildElement.Name.Equals("outerBoundaryIs"))
                {
                    foreach (XmlNode oOuterBoundaryNode in oChildElement)
                    {
                        if (oOuterBoundaryNode.NodeType != XmlNodeType.Element) continue;
                        XmlElement oOuterBoundaryElement = oOuterBoundaryNode as XmlElement;

                        if (oOuterBoundaryElement.Name.Equals("LinearRing"))
                        {
                            m_oOuterBoundary = new KMLLinearRing(oOuterBoundaryElement, owner, source);
                        }
                    }
                }
                else if (oChildElement.Name.Equals("innerBoundaryIs"))
                {
                    foreach (XmlNode oInnerBoundaryNode in oChildElement)
                    {
                        if (oInnerBoundaryNode.NodeType != XmlNodeType.Element) continue;
                        XmlElement oInnerBoundaryElement = oInnerBoundaryNode as XmlElement;

                        if (oInnerBoundaryElement.Name.Equals("LinearRing"))
                        {
                            m_oInnerBoundaries.Add(new KMLLinearRing(oInnerBoundaryElement, owner, source));
                        }
                    }
                }
            }

            if (m_oOuterBoundary == null) throw new ArgumentException("The KML file contains a 'Polygon' element without an 'outerBoundaryIs' element.");
        }
Exemplo n.º 2
0
        private static Point3d[] GetPoints(KMLLinearRing oInput)
        {
            Point3d[] result = new Point3d[oInput.Count];

            for (int count = 0; count < oInput.Count; count++)
            {
                result[count] = new Point3d(oInput[count].Longitude, oInput[count].Latitude, oInput[count].Altitude);
            }

            return result;
        }