コード例 #1
0
ファイル: KMLObjectModel.cs プロジェクト: paladin74/Dapple
        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.");
        }
コード例 #2
0
ファイル: KMLObjectModel.cs プロジェクト: paladin74/Dapple
 internal KMLMultiGeometry(XmlElement element, KMLPlacemark owner, KMLFile source)
     : base(element, owner, source)
 {
     m_oChildren = KMLGeometry.GetGeometries(element, owner, source);
 }
コード例 #3
0
ファイル: KMLObjectModel.cs プロジェクト: paladin74/Dapple
        internal KMLLineString(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("tessellate"))
                {
                    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("coordinates"))
                {
                    String[] oTuples = oChildElement.InnerText.Replace(", ", ",").Split(new char[] { }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (String strTuple in oTuples)
                    {
                        m_oCoords.Add(new KMLCoordinates(strTuple));
                    }
                }
            }

            if (m_oCoords.Count == 0) throw new ArgumentException("The KML file contains a 'LinearRing' element without a 'coordinates' element.");
        }
コード例 #4
0
ファイル: KMLObjectModel.cs プロジェクト: paladin74/Dapple
        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();
        }
コード例 #5
0
ファイル: KMLObjectModel.cs プロジェクト: paladin74/Dapple
        internal static List<KMLGeometry> GetGeometries(XmlElement oElement, KMLPlacemark oOwner, KMLFile oSource)
        {
            List<KMLGeometry> result = new List<KMLGeometry>();

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

                if (oChildElement.Name.Equals("Point"))
                {
                    result.Add(new KMLPoint(oChildElement, oOwner, oSource));
                }
                else if (oChildElement.Name.Equals("LineString"))
                {
                    result.Add(new KMLLineString(oChildElement, oOwner, oSource));
                }
                else if (oChildElement.Name.Equals("LinearRing"))
                {
                    result.Add(new KMLLinearRing(oChildElement, oOwner, oSource));
                }
                else if (oChildElement.Name.Equals("Polygon"))
                {
                    result.Add(new KMLPolygon(oChildElement, oOwner, oSource));
                }
                else if (oChildElement.Name.Equals("MultiGeometry"))
                {
                    result.Add(new KMLMultiGeometry(oChildElement, oOwner, oSource));
                }
                else if (oChildElement.Name.Equals("Model"))
                {
                    result.Add(new KMLModel(oChildElement, oOwner, oSource));
                }
            }

            return result;
        }