public void ExportToKml(String iFilename) { KmlHelper lKmlWriter = new KmlHelper(); EntityOffice.AddKmlStyles(lKmlWriter); WriteToKml(lKmlWriter, lKmlWriter.DocumentNode); lKmlWriter.SaveToFile(iFilename); }
public PopulationDataEntry(String iName, OfficeType iType, EntityLeaderList iLeaderList) { Name = iName; EntityOffice lOffice = new EntityOffice(); lOffice.Type = iType; lOffice.OfficialsList = iLeaderList; Offices.Add(lOffice); }
public PopulationDataEntry(String iName, OfficeType iType, EntityLeaderList iLeaderList) { Name = iName; EntityOffice lOffice = new EntityOffice(); lOffice.Type = iType; lOffice.OfficialsList = iLeaderList; Offices.Add(lOffice); }
public EntityOffice(EntityOffice iValue) { if (iValue.OfficialsList != null) { OfficialsList = (EntityLeaderList)iValue.OfficialsList.Clone(); } if (iValue.Location != null) { Location = (GeoPoint)iValue.Location.Clone(); } if (iValue.Address != null) { Address = (ThaiAddress)iValue.Address.Clone(); } foreach (Uri lUri in iValue.Websites) { Websites.Add(lUri); } Type = iValue.Type; }
public EntityOffice(EntityOffice iValue) { if (iValue.OfficialsList != null) { OfficialsList = (EntityLeaderList)iValue.OfficialsList.Clone(); } if (iValue.Location != null) { Location = (GeoPoint)iValue.Location.Clone(); } if (iValue.Address != null) { Address = (ThaiAddress)iValue.Address.Clone(); } foreach (Uri lUri in iValue.Websites) { Websites.Add(lUri); } Type = iValue.Type; }
internal static EntityOffice Load(XmlNode iNode) { EntityOffice RetVal = null; if (iNode != null && iNode.Name.Equals("office")) { RetVal = new EntityOffice(); string s = TambonHelper.GetAttributeOptionalString(iNode, "type"); if (!String.IsNullOrEmpty(s)) { RetVal.Type = (OfficeType)Enum.Parse(typeof(OfficeType), s); } if (iNode.HasChildNodes) { foreach (XmlNode lChildNode in iNode.ChildNodes) { if (lChildNode.Name == "officials") { EntityLeaderList lOfficials = EntityLeaderList.Load(lChildNode); RetVal.OfficialsList = lOfficials; } if (lChildNode.Name == "url") { RetVal.Websites.Add(new Uri(lChildNode.InnerText)); } if (lChildNode.Name == "address") { RetVal.Address = ThaiAddress.Load(lChildNode); } if (lChildNode.Name == "geo:Point") { RetVal.Location = GeoPoint.Load(lChildNode); } } } } return(RetVal); }
public PopulationDataEntry Parse(StreamReader reader) { // Column 1 : is number, then use // Column 2 : Amphoe name // Column 3 : Tambon name // Column 4 : Code // Column 5 : Name // Column 6 : Muban number // Column 7 : Location source/placemark // Column 8 : Location UTM Easting (47N, Indian 1974) // Column 9 : Location UTM Northing (47N, Indian 1974) String currentLine = String.Empty; PopulationDataEntry currentChangwat = new PopulationDataEntry(); PopulationDataEntry currentAmphoe = new PopulationDataEntry(); PopulationDataEntry currentTambon = new PopulationDataEntry(); while ((currentLine = reader.ReadLine()) != null) { var subStrings = currentLine.Split(new Char[] { '\t' }); if ((subStrings.Length > 0) & (!String.IsNullOrEmpty(subStrings[0])) & TambonHelper.IsNumeric(subStrings[0])) { PopulationDataEntry currentMuban = new PopulationDataEntry(); String amphoe = subStrings[1].Replace('"', ' ').Trim(); String tambon = subStrings[2].Replace('"', ' ').Trim(); String geocode = subStrings[3].Replace('"', ' ').Replace(" ", "").Trim(); currentMuban.Geocode = Convert.ToInt32(geocode); currentMuban.Name = subStrings[4].Replace('"', ' ').Trim(); currentMuban.Type = EntityType.Muban; String comment = subStrings[6].Replace('"', ' ').Trim(); String easting = subStrings[7].Replace('"', ' ').Replace('E', ' ').Trim(); String northing = subStrings[8].Replace('"', ' ').Replace('N', ' ').Trim(); if (TambonHelper.IsNumeric(easting) && TambonHelper.IsNumeric(northing)) { EntityOffice office = new EntityOffice(); office.Type = OfficeType.VillageHeadmanOffice; UtmPoint utmLocation = new UtmPoint(Convert.ToInt32(easting), Convert.ToInt32(northing), 47, true); office.Location = new GeoPoint(utmLocation, GeoDatum.DatumIndian1975()); office.Location.Datum = GeoDatum.DatumWGS84(); currentMuban.Offices.Add(office); } String mubanString = subStrings[5].Replace('"', ' ').Trim(); if (TambonHelper.IsNumeric(mubanString)) { Int32 muban = Convert.ToInt32(mubanString); if (muban != (currentMuban.Geocode % 100)) { comment = comment + Environment.NewLine + "Code is " + currentMuban.Geocode.ToString() + ','; comment = comment + " Muban number is " + muban.ToString(); currentMuban.Geocode = currentMuban.Geocode - (currentMuban.Geocode % 100) + muban; } } if ((currentMuban.Geocode / 10000) != currentAmphoe.Geocode) { currentAmphoe = new PopulationDataEntry(); currentAmphoe.Name = tambon; currentAmphoe.Type = EntityType.Amphoe; currentAmphoe.Geocode = (currentMuban.Geocode / 10000); currentChangwat.SubEntities.Add(currentAmphoe); } if ((currentMuban.Geocode / 100) != currentTambon.Geocode) { currentTambon = new PopulationDataEntry(); currentTambon.Name = tambon; currentTambon.Type = EntityType.Tambon; currentTambon.Geocode = (currentMuban.Geocode / 100); currentAmphoe.SubEntities.Add(currentTambon); } currentMuban.Comment = comment; currentTambon.SubEntities.Add(currentMuban); } } currentChangwat.Type = EntityType.Changwat; return(currentChangwat); }
public PopulationDataEntry Parse(StreamReader reader) { // Column 1 : is number, then use // Column 2 : Amphoe name // Column 3 : Tambon name // Column 4 : Code // Column 5 : Name // Column 6 : Muban number // Column 7 : Location source/placemark // Column 8 : Location UTM Easting (47N, Indian 1974) // Column 9 : Location UTM Northing (47N, Indian 1974) String currentLine = String.Empty; PopulationDataEntry currentChangwat = new PopulationDataEntry(); PopulationDataEntry currentAmphoe = new PopulationDataEntry(); PopulationDataEntry currentTambon = new PopulationDataEntry(); while ( (currentLine = reader.ReadLine()) != null ) { var subStrings = currentLine.Split(new Char[] { '\t' }); if ( (subStrings.Length > 0) & (!String.IsNullOrEmpty(subStrings[0])) & TambonHelper.IsNumeric(subStrings[0]) ) { PopulationDataEntry currentMuban = new PopulationDataEntry(); String amphoe = subStrings[1].Replace('"', ' ').Trim(); String tambon = subStrings[2].Replace('"', ' ').Trim(); String geocode = subStrings[3].Replace('"', ' ').Replace(" ", "").Trim(); currentMuban.Geocode = Convert.ToInt32(geocode); currentMuban.Name = subStrings[4].Replace('"', ' ').Trim(); currentMuban.Type = EntityType.Muban; String comment = subStrings[6].Replace('"', ' ').Trim(); String easting = subStrings[7].Replace('"', ' ').Replace('E', ' ').Trim(); String northing = subStrings[8].Replace('"', ' ').Replace('N', ' ').Trim(); if ( TambonHelper.IsNumeric(easting) && TambonHelper.IsNumeric(northing) ) { EntityOffice office = new EntityOffice(); office.Type = OfficeType.VillageHeadmanOffice; UtmPoint utmLocation = new UtmPoint(Convert.ToInt32(easting), Convert.ToInt32(northing), 47, true); office.Location = new GeoPoint(utmLocation, GeoDatum.DatumIndian1975()); office.Location.Datum = GeoDatum.DatumWGS84(); currentMuban.Offices.Add(office); } String mubanString = subStrings[5].Replace('"', ' ').Trim(); if ( TambonHelper.IsNumeric(mubanString) ) { Int32 muban = Convert.ToInt32(mubanString); if ( muban != (currentMuban.Geocode % 100) ) { comment = comment + Environment.NewLine + "Code is " + currentMuban.Geocode.ToString() + ','; comment = comment + " Muban number is " + muban.ToString(); currentMuban.Geocode = currentMuban.Geocode - (currentMuban.Geocode % 100) + muban; } } if ( (currentMuban.Geocode / 10000) != currentAmphoe.Geocode ) { currentAmphoe = new PopulationDataEntry(); currentAmphoe.Name = tambon; currentAmphoe.Type = EntityType.Amphoe; currentAmphoe.Geocode = (currentMuban.Geocode / 10000); currentChangwat.SubEntities.Add(currentAmphoe); } if ( (currentMuban.Geocode / 100) != currentTambon.Geocode ) { currentTambon = new PopulationDataEntry(); currentTambon.Name = tambon; currentTambon.Type = EntityType.Tambon; currentTambon.Geocode = (currentMuban.Geocode / 100); currentAmphoe.SubEntities.Add(currentTambon); } currentMuban.Comment = comment; currentTambon.SubEntities.Add(currentMuban); } } currentChangwat.Type = EntityType.Changwat; return currentChangwat; }
internal static PopulationDataEntry Load(XmlNode iNode) { PopulationDataEntry RetVal = null; if (iNode != null && iNode.Name.Equals("entity")) { RetVal = new PopulationDataEntry(); RetVal.Name = TambonHelper.GetAttributeOptionalString(iNode, "name").Trim(); RetVal.English = TambonHelper.GetAttributeOptionalString(iNode, "english").Trim(); RetVal.Total = TambonHelper.GetAttributeOptionalInt(iNode, "total", 0); RetVal.Obsolete = TambonHelper.GetAttributeOptionalBool(iNode, "obsolete", false); RetVal.Male = TambonHelper.GetAttributeOptionalInt(iNode, "male", 0); RetVal.Female = TambonHelper.GetAttributeOptionalInt(iNode, "female", 0); RetVal.Households = TambonHelper.GetAttributeOptionalInt(iNode, "households", 0); RetVal.Geocode = TambonHelper.GetAttributeOptionalInt(iNode, "geocode", 0); RetVal.GeocodeOfCorrespondingTambon = TambonHelper.GetAttributeOptionalInt(iNode, "tambon", 0); RetVal.Comment = TambonHelper.GetAttributeOptionalString(iNode, "comment"); string lNewGeocode = TambonHelper.GetAttributeOptionalString(iNode, "newgeocode"); foreach (string lSubString in lNewGeocode.Split(new Char[] { ' ' })) { if (!string.IsNullOrEmpty(lSubString)) { RetVal.NewGeocode.Add(Convert.ToInt32(lSubString)); } } string s = TambonHelper.GetAttributeOptionalString(iNode, "type"); if (!String.IsNullOrEmpty(s)) { RetVal.Type = (EntityType)Enum.Parse(typeof(EntityType), s); } string lGeocodeParent = TambonHelper.GetAttributeOptionalString(iNode, "parent"); foreach (string lSubString in lGeocodeParent.Split(new Char[] { ' ' })) { if (!string.IsNullOrEmpty(lSubString)) { RetVal.GeocodeParent.Add(Convert.ToInt32(lSubString)); } } if (iNode.HasChildNodes) { foreach (XmlNode lChildNode in iNode.ChildNodes) { if (lChildNode.Name == "office") { EntityOffice lOffice = EntityOffice.Load(lChildNode); RetVal.Offices.Add(lOffice); } if (lChildNode.Name == "history") { RetVal.ParseHistory(lChildNode); } if (lChildNode.Name == "entity") { RetVal.SubEntities.Add(PopulationDataEntry.Load(lChildNode)); } if (lChildNode.Name == "constituencies") { RetVal.ConstituencyList.ReadFromXml(lChildNode); } } } } return(RetVal); }
internal static EntityOffice Load(XmlNode iNode) { EntityOffice RetVal = null; if (iNode != null && iNode.Name.Equals("office")) { RetVal = new EntityOffice(); string s = TambonHelper.GetAttributeOptionalString(iNode, "type"); if (!String.IsNullOrEmpty(s)) { RetVal.Type = (OfficeType)Enum.Parse(typeof(OfficeType), s); } if (iNode.HasChildNodes) { foreach (XmlNode lChildNode in iNode.ChildNodes) { if (lChildNode.Name == "officials") { EntityLeaderList lOfficials = EntityLeaderList.Load(lChildNode); RetVal.OfficialsList=lOfficials; } if (lChildNode.Name == "url") { RetVal.Websites.Add(new Uri(lChildNode.InnerText)); } if (lChildNode.Name == "address") { RetVal.Address = ThaiAddress.Load(lChildNode); } if (lChildNode.Name == "geo:Point") { RetVal.Location = GeoPoint.Load(lChildNode); } } } } return RetVal; }