Пример #1
0
        /// <summary>
        /// Adds a Polygon To The List
        /// </summary>
        /// <param name="polyin">Polygon String</param>
        public void AddPolygon(string polyin)
        {
            if (string.IsNullOrEmpty(polyin))
            {
                throw new ArgumentException("Input Value Can't Be Null or Empty!");
            }

            StringGeoTools.CheckPolygon(polyin);
            this.polygon.Add(polyin);
        }
Пример #2
0
        /// <summary>
        /// Reads an XML Object From An Existing DOM
        /// </summary>
        /// <param name="rootNode">Node Containing the Root Object Element</param>
        internal void ReadXML(XmlNode rootNode)
        {
            NameValueType namevaluetmp;

            char[] delimSpace = { ' ' };
            char[] delimComma = { ',' };
            foreach (XmlNode node in rootNode.ChildNodes)
            {
                if (string.IsNullOrEmpty(node.InnerText))
                {
                    continue;
                }

                switch (node.LocalName)
                {
                case "areaDesc":
                    this.areaDesc = node.InnerText;
                    break;

                case "polygon":
                    string polygonString = node.InnerText;
                    StringGeoTools.CheckPolygon(polygonString);
                    this.polygon.Add(polygonString);
                    break;

                case "circle":
                    string circlePt = node.InnerText;
                    StringGeoTools.CheckCircle(circlePt);
                    this.circle.Add(circlePt);
                    break;

                case "geocode":
                    namevaluetmp = new NameValueType();
                    namevaluetmp.ReadXML(node);
                    this.geoCode.Add(namevaluetmp);
                    break;

                case "altitude":
                    StringGeoTools.CheckDecimal(decimal.Parse(node.InnerText));
                    this.altitude = decimal.Parse(node.InnerText);
                    break;

                case "ceiling":
                    StringGeoTools.CheckDecimal(decimal.Parse(node.InnerText));
                    this.ceiling = decimal.Parse(node.InnerText);
                    break;

                case "#comment":
                    break;

                default:
                    throw new FormatException("Invalid value: " + node.InnerText + " found in Area Type");
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Writes This Object to an Existing XML Document
        /// </summary>
        /// <param name="xwriter">Pointer to the XMLWriter Writing the Document</param>
        internal void WriteXML(XmlWriter xwriter)
        {
            this.Validate();

            if (string.IsNullOrEmpty(this.capNamespace))
            {
                this.capNamespace = EDXLConstants.CAP12Namespace;
            }

            xwriter.WriteElementString("areaDesc", this.capNamespace, this.areaDesc);
            if (this.polygon.Count != 0)
            {
                foreach (string poly in this.polygon)
                {
                    string fixedPoly = string.Empty;
                    try
                    {
                        fixedPoly = StringGeoTools.ValidatePolygon(poly);
                    }
                    catch (FormatException fe)
                    {
                        if (fe.ToString().Contains("Needs Flipped"))
                        {
                            string flipped = StringGeoTools.FlipPolygon(poly);
                            fixedPoly = StringGeoTools.ValidatePolygon(flipped);
                        }
                        else
                        {
                            throw fe;
                        }
                    }

                    StringGeoTools.CheckPolygon(fixedPoly); // redundant checks possibly, but not a big deal
                    xwriter.WriteElementString("polygon", this.capNamespace, fixedPoly);
                }
            }

            if (this.circle.Count != 0)
            {
                foreach (string circ in this.circle)
                {
                    StringGeoTools.CheckCircle(circ);
                    xwriter.WriteElementString("circle", this.capNamespace, circ);
                }
            }

            if (this.geoCode.Count != 0)
            {
                foreach (NameValueType name_type in this.geoCode)
                {
                    xwriter.WriteStartElement("geocode", this.capNamespace);
                    name_type.CapNamespace = this.capNamespace;
                    name_type.WriteXML(xwriter);
                    xwriter.WriteEndElement();
                }
            }

            if (this.altitude != null)
            {
                StringGeoTools.CheckDecimal(this.altitude);
                xwriter.WriteElementString("altitude", this.capNamespace, this.altitude.ToString());
                if (this.ceiling != null)
                {
                    StringGeoTools.CheckDecimal(this.ceiling);
                    xwriter.WriteElementString("ceiling", this.capNamespace, this.ceiling.ToString());
                }
            }
        }