コード例 #1
0
        /// <summary>
        /// Adds a SubDivision To The List
        /// </summary>
        /// <param name="subdivisionin">SubDivision String</param>
        public void AddSubDivision(string subdivisionin)
        {
            if (string.IsNullOrEmpty(subdivisionin))
            {
                throw new ArgumentException("Input Value Can't Be Null or Empty!");
            }

            StringGeoTools.CheckSubdivision(subdivisionin);
            this.subdivision.Add(subdivisionin);
        }
コード例 #2
0
        /// <summary>
        /// Adds a UN Location Code To The List
        /// </summary>
        /// <param name="unloccode">UN Location Code String</param>
        public void AddLocCodeUN(string unloccode)
        {
            if (string.IsNullOrEmpty(unloccode))
            {
                throw new ArgumentNullException("Value Must Not Be Null or Empty");
            }

            StringGeoTools.CheckLocCodeUN(unloccode);
            this.loccodeUN.Add(unloccode);
        }
コード例 #3
0
        /// <summary>
        /// Adds a Country To The List
        /// </summary>
        /// <param name="countryin">Country String</param>
        public void AddCountry(string countryin)
        {
            if (string.IsNullOrEmpty(countryin))
            {
                throw new ArgumentException("Input Value Can't Be Null or Empty!");
            }

            StringGeoTools.CheckCountry(countryin);
            this.country.Add(countryin);
        }
コード例 #4
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);
        }
コード例 #5
0
        /// <summary>
        /// Adds a Circle To The List
        /// </summary>
        /// <param name="circlein">Circle String</param>
        public void AddCircle(string circlein)
        {
            if (string.IsNullOrEmpty(circlein))
            {
                throw new ArgumentException("Input Value Can't Be Null or Empty!");
            }

            StringGeoTools.CheckCircle(circlein);
            this.circle.Add(circlein);
        }
コード例 #6
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");
                }
            }
        }
コード例 #7
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());
                }
            }
        }