Пример #1
0
        internal KMLOverlay(XmlElement element, KMLFile source)
            : base(element, source)
        {
            foreach (XmlNode oChild in element.ChildNodes)
            {
                if (oChild.NodeType != XmlNodeType.Element) continue;
                XmlElement oChildElement = oChild as XmlElement;

                if (oChildElement.Name.Equals("color"))
                {
                    m_oColor = KMLColorStyle.ParseColor(oChildElement.InnerText);
                }
                else if (oChildElement.Name.Equals("drawOrder"))
                {
                    m_iDrawOrder = Int32.Parse(oChildElement.InnerText, CultureInfo.InvariantCulture);
                }
                else if (oChildElement.Name.Equals("Icon"))
                {
                    m_oIcon = new KMLIconOrLink(oChildElement, source);
                }
            }
        }
Пример #2
0
        internal KMLModel(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("altitudeMode"))
                {
                    m_eAltitudeMode = (KMLAltitudeMode)Enum.Parse(typeof(KMLAltitudeMode), oChildElement.InnerText);
                }
                else if (oChildElement.Name.Equals("altitudeMode"))
                {
                    m_oLocation = new KMLLocation(oChildElement, source);
                }
                else if (oChildElement.Name.Equals("Orientation"))
                {
                    m_oOrientation = new KMLOrientation(oChildElement, source);
                }
                else if (oChildElement.Name.Equals("Scale"))
                {
                    m_oScale = new KMLScale(oChildElement, source);
                }
                else if (oChildElement.Name.Equals("Link"))
                {
                    m_oLink = new KMLIconOrLink(oChildElement, source);
                }
                else if (oChildElement.Name.Equals("ResourceMap"))
                {
                    foreach (XmlNode oResourceChild in oChildElement.ChildNodes)
                    {
                        if (oResourceChild.NodeType != XmlNodeType.Element) continue;
                        XmlElement oResourceChildElement = oResourceChild as XmlElement;

                        if (oResourceChildElement.Name.Equals("Alias"))
                        {
                            String strTargetHref = String.Empty;
                            String strSourceHref = String.Empty;

                            foreach (XmlNode oAliasChild in oResourceChildElement.ChildNodes)
                            {
                                if (oAliasChild.NodeType != XmlNodeType.Element) continue;
                                XmlElement oAliasChildElement = oAliasChild as XmlElement;

                                if (oAliasChildElement.Name.Equals("targetHref"))
                                    strTargetHref = oAliasChildElement.InnerText;
                                if (oAliasChildElement.Name.Equals("sourceHref"))
                                    strTargetHref = oAliasChildElement.InnerText;
                            }

                            if (!String.IsNullOrEmpty(strTargetHref) && !String.IsNullOrEmpty(strSourceHref))
                            {
                                m_oResourceMap.Add(strSourceHref, strTargetHref);
                            }
                        }
                    }
                }
            }

            if (m_oLocation == null) throw new ArgumentException("The KML file contains a 'Model' element without a 'Location' element.");
            if (m_oLink == null) throw new ArgumentException("The KML file contains a 'Model' element without a 'Link' element.");

            if (m_oOrientation == null) m_oOrientation = new KMLOrientation();
            if (m_oScale == null) m_oScale = new KMLScale();
        }
Пример #3
0
        internal KMLNetworkLink(XmlElement element, KMLFile source)
            : base(element, source)
        {
            foreach (XmlNode oChild in element.ChildNodes)
            {
                if (oChild.NodeType != XmlNodeType.Element) continue;
                XmlElement oChildElement = oChild as XmlElement;

                if (oChildElement.Name.Equals("refreshVisibility"))
                {
                    m_blRefreshVisibility = oChildElement.InnerText.Equals("1");
                }
                else if (oChildElement.Name.Equals("flyToView"))
                {
                    m_blFlyToView = oChildElement.InnerText.Equals("1");
                }
                else if (oChildElement.Name.Equals("Link"))
                {
                    m_oLink = new KMLIconOrLink(oChildElement, source);
                }
            }

            if (m_oLink == null) throw new ArgumentException("The KML file contains a 'NetworkLink' element without a 'Link' element.");
        }
Пример #4
0
        internal KMLIconStyle(XmlElement element, KMLFile source)
            : base(element, source)
        {
            bool blHotSpotSet = false;

            foreach (XmlNode oChild in element.ChildNodes)
            {
                if (oChild.NodeType != XmlNodeType.Element) continue;
                XmlElement oChildElement = oChild as XmlElement;

                if (oChildElement.Name.Equals("scale"))
                {
                    m_fScale = Single.Parse(oChildElement.InnerText, CultureInfo.InvariantCulture);
                }
                else if (oChildElement.Name.Equals("heading"))
                {
                    m_fHeading = Single.Parse(oChildElement.InnerText, CultureInfo.InvariantCulture);
                }
                else if (oChildElement.Name.Equals("Icon"))
                {
                    m_oIcon = new KMLIconOrLink(oChildElement, source);
                }
                else if (oChildElement.Name.Equals("hotSpot"))
                {
                    m_oHotSpot = new KMLVec2(oChildElement);
                    blHotSpotSet = true;
                }
            }

            if (!blHotSpotSet) m_oHotSpot = new KMLVec2(0.5, 0.5, KMLUnits.fraction, KMLUnits.fraction);
        }