예제 #1
0
 virtual protected void WriteToXmlElement(XmlElement iElement)
 {
     if (Geocode != 0)
     {
         iElement.SetAttribute("geocode", Geocode.ToString());
     }
     if (TambonGeocode != 0)
     {
         iElement.SetAttribute("tambon", TambonGeocode.ToString());
     }
     if (Owner != 0)
     {
         iElement.SetAttribute("owner", Owner.ToString());
     }
     if (!String.IsNullOrEmpty(Name))
     {
         iElement.SetAttribute("name", Name.ToString());
     }
     if (!String.IsNullOrEmpty(English))
     {
         iElement.SetAttribute("english", English.ToString());
     }
     foreach (RoyalGazetteContent lContent in mSubEntries)
     {
         lContent.ExportToXML(iElement);
     }
 }
예제 #2
0
        private void WriteToKml(KmlHelper lKmlWriter, XmlNode iNode)
        {
            XmlNode lNode        = iNode;
            String  lDescription = "Geocode: " + Geocode.ToString();

            if ((Type == EntityType.Changwat) | (Type == EntityType.Bangkok))
            {
                lNode = lKmlWriter.AddFolder(lNode, English, false);
            }
            String lName = English;

            if (Type == EntityType.Muban)
            {
                lName = "Mu " + (Geocode % 100).ToString();
                if (!String.IsNullOrEmpty(English))
                {
                    lName = lName + ' ' + English;
                }
            }
            if (!String.IsNullOrEmpty(this.Comment))
            {
                lDescription = lDescription + Environment.NewLine + this.Comment;
            }
            foreach (EntityOffice lOffice in Offices)
            {
                lOffice.AddToKml(lKmlWriter, lNode, lName, lDescription);
            }
            foreach (PopulationDataEntry lEntity in SubEntities)
            {
                lEntity.WriteToKml(lKmlWriter, lNode);
            }
        }
예제 #3
0
 private static Url HandleDefaults(Url url, Geocode location, bool enableDebug, Verbosity verbosity, List<string> fields)
 {
     if (enableDebug == true)
     {
         url.QueryString["debug"] = "true";
         if (verbosity == Verbosity.Verbose)
             url.QueryString["verbosity"] = "verbose";
     }
     if (location != null)
         url.QueryString["location"] = location.ToString();
     if (fields != null && fields.Count > 0)
         url.QueryString["fields"] = fields.Select(x => x.ToLower() ).ToDelimitedList(",");
     return url;
 }
예제 #4
0
 private static Url HandleDefaults(Url url, Geocode location, bool enableDebug, Verbosity verbosity, List <string> fields)
 {
     if (enableDebug == true)
     {
         url.QueryString["debug"] = "true";
         if (verbosity == Verbosity.Verbose)
         {
             url.QueryString["verbosity"] = "verbose";
         }
     }
     if (location != null)
     {
         url.QueryString["location"] = location.ToString();
     }
     if (fields != null && fields.Count > 0)
     {
         url.QueryString["fields"] = fields.Select(x => x.ToLower()).ToDelimitedList(",");
     }
     return(url);
 }
 public void GeocodeParsingTest()
 {
     var geo = new Geocode(10.0m, 10.0m);
     var valid = new[] 
     { 
         "10,10",        // without decimal points
         "10.0,10.0",    // normal
         " 10.0,10.0",   // with leading spaces
         "10.0,10.0",    // with trailing spaces
         "10.0 ,10.0 ",  // with leading space before comma
         "10.0, 10.0"    // with trailing space after comma
     };
     Array.ForEach(valid, value =>
         {
             Geocode geocode = null;
             Assert.IsTrue(Geocode.TryParse(value, out geocode), "Valid value {0} was not parsed correctly.", value);
             Assert.IsNotNull(geocode, "Geocode parsed for {0} was null.", value);
             Assert.IsTrue(geocode.Equals(geo), "Expected {0} but received {1}.", geo.ToString(), geocode.ToString());
         });
 }
예제 #6
0
        public void GeocodeParsingTest()
        {
            var geo   = new Geocode(10.0m, 10.0m);
            var valid = new[]
            {
                "10,10",        // without decimal points
                "10.0,10.0",    // normal
                " 10.0,10.0",   // with leading spaces
                "10.0,10.0",    // with trailing spaces
                "10.0 ,10.0 ",  // with leading space before comma
                "10.0, 10.0"    // with trailing space after comma
            };

            Array.ForEach(valid, value =>
            {
                Geocode geocode = null;
                Assert.IsTrue(Geocode.TryParse(value, out geocode), "Valid value {0} was not parsed correctly.", value);
                Assert.IsNotNull(geocode, "Geocode parsed for {0} was null.", value);
                Assert.IsTrue(geocode.Equals(geo), "Expected {0} but received {1}.", geo.ToString(), geocode.ToString());
            });
        }
예제 #7
0
        internal virtual void WriteToXMLNode(XmlElement iNode)
        {
            iNode.SetAttribute("name", Name);
            if (!String.IsNullOrEmpty(English))
            {
                iNode.SetAttribute("english", English);
            }
            if (Geocode != 0)
            {
                iNode.SetAttribute("geocode", Geocode.ToString());
            }
            String s = "";

            foreach (Int32 i in NewGeocode)
            {
                s = s + i.ToString() + " ";
            }
            if (!String.IsNullOrEmpty(s))
            {
                s = s.Remove(s.Length - 1);
                iNode.SetAttribute("newgeocode", s);
            }

            if (Type != EntityType.Unknown)
            {
                iNode.SetAttribute("type", Type.ToString());
            }
            if (Total > 0)
            {
                iNode.SetAttribute("total", Total.ToString());
            }
            if (Female > 0)
            {
                iNode.SetAttribute("female", Female.ToString());
            }
            if (Male > 0)
            {
                iNode.SetAttribute("male", Male.ToString());
            }
            if (Households > 0)
            {
                iNode.SetAttribute("households", Households.ToString());
            }
            s = "";
            foreach (Int32 i in GeocodeParent)
            {
                s = s + i.ToString() + " ";
            }
            if (!String.IsNullOrEmpty(s))
            {
                s = s.Remove(s.Length - 1);
                iNode.SetAttribute("parent", s);
            }
            if (!String.IsNullOrEmpty(Comment))
            {
                iNode.SetAttribute("comment", Comment);
            }
            foreach (EntityOffice lOffice in Offices)
            {
                lOffice.ExportToXML(iNode);
            }
            foreach (PopulationDataEntry lEntity in SubEntities)
            {
                lEntity.ExportToXML(iNode);
            }
        }
예제 #8
0
        public void CopyPopulationToConstituencies(PopulationDataEntry iPopulationSource)
        {
            PopulationDataEntry lSourcePopulationdataEntry = iPopulationSource.FindByCode(Geocode);

            if (lSourcePopulationdataEntry != null)
            {
                lSourcePopulationdataEntry.CalculateNumbersFromSubEntities();
                CopyPopulationDataFrom(lSourcePopulationdataEntry);
            }
            Debug.Assert(lSourcePopulationdataEntry != null, "No source data entry with geocode " + Geocode.ToString());
            if (lSourcePopulationdataEntry != null)
            {
                foreach (ConstituencyEntry lConstituency in ConstituencyList)
                {
                    GetPopulationData(lSourcePopulationdataEntry, lConstituency.AdministrativeEntities);
                    foreach (var lKeyValuePair in lConstituency.ExcludedAdministrativeEntities)
                    {
                        PopulationDataEntry lSourceSubEntity = iPopulationSource.FindByCode(lKeyValuePair.Key.Geocode);
                        GetPopulationData(lSourceSubEntity, lKeyValuePair.Value);
                    }
                    foreach (var lKeyValuePair in lConstituency.SubIncludedAdministrativeEntities)
                    {
                        PopulationDataEntry lSourceSubEntity = iPopulationSource.FindByCode(lKeyValuePair.Key.Geocode);
                        GetPopulationData(lSourceSubEntity, lKeyValuePair.Value);
                    }
                }
            }
            Int32 lPopulation = ConstituencyList.Population();
            Int32 lTotal      = Total;

            if ((lPopulation > 0) && (lTotal > 0))
            {
                Int32 lPopulationDiff = lPopulation - lTotal;
                Debug.Assert(lPopulationDiff == 0, "Population for " + English + " does not sum up, off by " + lPopulationDiff.ToString());
            }
        }