Beispiel #1
0
        private void btnCreateKml_Click(object sender, EventArgs e)
        {
            var allEntities = new List <PopulationDataEntry>();

            foreach (PopulationDataEntry provinceGeocode in TambonHelper.ProvinceGeocodes)
            {
                PopulationData provinceEntities = TambonHelper.GetGeocodeList(provinceGeocode.Geocode);
                allEntities.Add(provinceEntities.Data);
            }
            PopulationDataEntry master = new PopulationDataEntry();

            master.SubEntities.AddRange(allEntities);
            String outFilename = Path.Combine(GlobalSettings.XMLOutputDir, "offices.kml");

            master.ExportToKml(outFilename);

            var geotaggedOffices = new Dictionary <OfficeType, Int32>();
            var anyOffices       = new Dictionary <OfficeType, Int32>();
            var flatList         = master.FlatList(EntityTypeHelper.AllEntityTypes);

            foreach (var entity in flatList)
            {
                foreach (var office in entity.Offices)
                {
                    if (office.Location != null)
                    {
                        if (!geotaggedOffices.ContainsKey(office.Type))
                        {
                            geotaggedOffices.Add(office.Type, 0);
                        }
                        geotaggedOffices[office.Type]++;
                    }
                    if (!anyOffices.ContainsKey(office.Type))
                    {
                        anyOffices.Add(office.Type, 0);
                    }
                    anyOffices[office.Type]++;
                }
            }
            String officeTypeInfo = String.Empty;

            foreach (OfficeType officeType in System.Enum.GetValues(typeof(OfficeType)))
            {
                if (geotaggedOffices.ContainsKey(officeType))
                {
                    officeTypeInfo =
                        officeTypeInfo +
                        String.Format("{0} {1} (of {2})", officeType, geotaggedOffices[officeType], anyOffices[officeType])
                        + Environment.NewLine;
                }
            }

            var    provincesWithoutPAOLocation     = flatList.FindAll(x => x.Offices.Any(y => (y.Type == OfficeType.PAOOffice) && (y.Location == null)));
            String provincesWithoutPAOLocationInfo = String.Format("No PAO location ({0}): ", provincesWithoutPAOLocation.Count());

            foreach (var entity in provincesWithoutPAOLocation)
            {
                provincesWithoutPAOLocationInfo = provincesWithoutPAOLocationInfo + String.Format("{0} ({1}),", entity.English, entity.Geocode);
            }
            var    districtsWithoutOffice     = flatList.FindAll(x => x.Offices.Any(y => (y.Type == OfficeType.DistrictOffice) && (y.Location == null)));
            String districtsWithoutOfficeInfo = String.Format("No district office location ({0}): ", districtsWithoutOffice.Count());

            foreach (var entity in districtsWithoutOffice)
            {
                districtsWithoutOfficeInfo = districtsWithoutOfficeInfo + String.Format("{0} ({1}),", entity.English, entity.Geocode);
            }

            var info = officeTypeInfo + Environment.NewLine + provincesWithoutPAOLocationInfo + Environment.NewLine + districtsWithoutOfficeInfo;

            var form = new StringDisplayForm("Office types", info);

            form.Show();
        }
Beispiel #2
0
        private void btnCreateKml_Click(object sender, EventArgs e)
        {
            var allEntities = new List<PopulationDataEntry>();
            foreach ( PopulationDataEntry provinceGeocode in TambonHelper.ProvinceGeocodes )
            {
                PopulationData provinceEntities = TambonHelper.GetGeocodeList(provinceGeocode.Geocode);
                allEntities.Add(provinceEntities.Data);
            }
            PopulationDataEntry master = new PopulationDataEntry();
            master.SubEntities.AddRange(allEntities);
            String outFilename = Path.Combine(GlobalSettings.XMLOutputDir, "offices.kml");
            master.ExportToKml(outFilename);

            var geotaggedOffices = new Dictionary<OfficeType, Int32>();
            var anyOffices = new Dictionary<OfficeType, Int32>();
            var flatList = master.FlatList(EntityTypeHelper.AllEntityTypes);
            foreach ( var entity in flatList )
            {
                foreach ( var office in entity.Offices )
                {
                    if ( office.Location != null )
                    {
                        if ( !geotaggedOffices.ContainsKey(office.Type) )
                        {
                            geotaggedOffices.Add(office.Type, 0);
                        }
                        geotaggedOffices[office.Type]++;
                    }
                    if ( !anyOffices.ContainsKey(office.Type) )
                    {
                        anyOffices.Add(office.Type, 0);
                    }
                    anyOffices[office.Type]++;
                }
            }
            String officeTypeInfo = String.Empty;
            foreach ( OfficeType officeType in System.Enum.GetValues(typeof(OfficeType)) )
            {
                if ( geotaggedOffices.ContainsKey(officeType) )
                {
                    officeTypeInfo =
                        officeTypeInfo +
                        String.Format("{0} {1} (of {2})", officeType, geotaggedOffices[officeType], anyOffices[officeType])
                        + Environment.NewLine;
                }
            }

            var provincesWithoutPAOLocation = flatList.FindAll(x => x.Offices.Any(y => (y.Type == OfficeType.PAOOffice) && (y.Location == null)));
            String provincesWithoutPAOLocationInfo = String.Format("No PAO location ({0}): ", provincesWithoutPAOLocation.Count());
            foreach ( var entity in provincesWithoutPAOLocation )
            {
                provincesWithoutPAOLocationInfo = provincesWithoutPAOLocationInfo + String.Format("{0} ({1}),", entity.English, entity.Geocode);
            }
            var districtsWithoutOffice = flatList.FindAll(x => x.Offices.Any(y => (y.Type == OfficeType.DistrictOffice) && (y.Location == null)));
            String districtsWithoutOfficeInfo = String.Format("No district office location ({0}): ", districtsWithoutOffice.Count());
            foreach ( var entity in districtsWithoutOffice )
            {
                districtsWithoutOfficeInfo = districtsWithoutOfficeInfo + String.Format("{0} ({1}),", entity.English, entity.Geocode);
            }

            var info = officeTypeInfo + Environment.NewLine + provincesWithoutPAOLocationInfo + Environment.NewLine + districtsWithoutOfficeInfo;

            var form = new StringDisplayForm("Office types", info);
            form.Show();
        }