Пример #1
0
        /// <summary>
        /// Reads This Object From an XML String
        /// </summary>
        /// <param name="xmldata">XML String Data</param>
        public void ReadFromXML(string xmldata)
        {
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(xmldata);
            XmlNodeList nodelist = doc.GetElementsByTagName("where");

            if (nodelist.Count == 0)
            {
                throw new FormatException("No Geo-OASIS Where Element found!");
            }
            else if (nodelist.Count > 1)
            {
                throw new FormatException("Multiple Geo-OASIS Where Elements found!");
            }

            XmlNode root = nodelist[0];

            foreach (XmlAttribute attrib in root.Attributes)
            {
                if (string.IsNullOrEmpty(attrib.InnerText))
                {
                    continue;
                }

                switch (attrib.LocalName)
                {
                case "relationshiptage":
                    this.relationship = new NCName(attrib.InnerText);
                    break;

                case "radius":
                    this.radius = double.Parse(attrib.InnerText);
                    break;

                case "featuretypetag":
                    this.featureType = new NCName(attrib.InnerText);
                    break;

                case "elev":
                    this.elevation = double.Parse(attrib.InnerText);
                    break;

                case "floor":
                    this.floor = double.Parse(attrib.InnerText);
                    break;

                case "#comment":
                    break;

                default:
                    if (attrib.Prefix != "xmlns")
                    {
                        throw new ArgumentException("Unexpected Attribute Name: " + attrib.LocalName + " in GeoOASISWhere");
                    }

                    break;
                }
            }

            foreach (XmlNode node in root.ChildNodes)
            {
                if (string.IsNullOrEmpty(node.InnerText))
                {
                    continue;
                }

                switch (node.LocalName)
                {
                case "Point":
                    this.location = new GMLPoint();
                    this.location.ReadXML(node);
                    break;

                case "LineString":
                    this.location = new GMLLineString();
                    this.location.ReadXML(node);
                    break;

                case "CircleByCenterPoint":
                    this.location = new GMLCircleByCenterPoint();
                    this.location.ReadXML(node);
                    break;

                case "Polygon":
                    this.location = new GMLPolygon();
                    this.location.ReadXML(node);
                    break;

                case "Envelope":
                    this.location = new GMLEnvelope();
                    this.location.ReadXML(node);
                    break;

                default:
                    throw new ArgumentException("Unexpected Node Name: " + node.LocalName + " in GeoOASISWhere");
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Reads an Geo-OASIS Where From An Existing DOM - You Must Parse The Top Level Element Before Calling This!
        /// </summary>
        /// <param name="rootnode">Node Containing the GML Position</param>
        public void ReadXML(XmlNode rootnode)
        {
            foreach (XmlAttribute attrib in rootnode.Attributes)
            {
                if (string.IsNullOrEmpty(attrib.InnerText))
                {
                    continue;
                }

                switch (attrib.LocalName)
                {
                case "relationshiptage":
                    this.relationship = new NCName(attrib.InnerText);
                    break;

                case "radius":
                    this.radius = double.Parse(attrib.InnerText);
                    break;

                case "featuretypetag":
                    this.featureType = new NCName(attrib.InnerText);
                    break;

                case "elev":
                    this.elevation = double.Parse(attrib.InnerText);
                    break;

                case "floor":
                    this.floor = double.Parse(attrib.InnerText);
                    break;

                case "interpolation":
                case "numArc":
                    break;

                default:
                    if (attrib.Prefix != "xmlns")
                    {
                        throw new ArgumentException("Unexpected Attribute: " + attrib.Name + " in GeoOASISWhere");
                    }

                    break;
                }
            }

            if (string.IsNullOrEmpty(rootnode.InnerText))
            {
                return;
            }

            switch (rootnode.LocalName)
            {
            case "Point":
                this.location = new GMLPoint();
                this.location.ReadXML(rootnode);
                break;

            case "LineString":
                this.location = new GMLLineString();
                this.location.ReadXML(rootnode);
                break;

            case "CircleByCenterPoint":
                this.location = new GMLCircleByCenterPoint();
                this.location.ReadXML(rootnode);
                break;

            case "Polygon":
                this.location = new GMLPolygon();
                this.location.ReadXML(rootnode);
                break;

            case "Envelope":
                this.location = new GMLEnvelope();
                this.location.ReadXML(rootnode);
                break;

            case "#comment":
                break;

            default:
                throw new ArgumentException("Unexpected Node Name: " + rootnode.Name + " in GeoOASISWhere");
            }
        }