Пример #1
0
        private void EntityNumbers_Load(object sender, EventArgs e)
        {
            _baseEntity = GlobalData.CompleteGeocodeList();
            _baseEntity.CalcOldGeocodesRecursive();
            _baseEntity.PropagateObsoleteToSubEntities();
            _allEntities = _baseEntity.FlatList()./*Where(x => !x.IsObsolete).*/ ToList();
            var allLocalGovernmentParents = _allEntities.Where(x => x.type == EntityType.Tambon || x.type == EntityType.Changwat).ToList();

            _localGovernments.AddRange(_allEntities.Where(x => x.type.IsLocalGovernment()));
            foreach (var tambon in allLocalGovernmentParents)
            {
                var localGovernmentEntity = tambon.CreateLocalGovernmentDummyEntity();
                if (localGovernmentEntity != null)
                {
                    _localGovernments.Add(localGovernmentEntity);
                    _allEntities.Add(localGovernmentEntity);
                }
            }

            var entityTypes = new List <EntityType>()
            {
                EntityType.Changwat,
                EntityType.Amphoe,
                EntityType.KingAmphoe,
                EntityType.Khet,
                EntityType.Tambon,
                EntityType.Khwaeng,
                // EntityType.Muban,
                EntityType.Sukhaphiban,
                EntityType.ThesabanNakhon,
                EntityType.ThesabanMueang,
                EntityType.ThesabanTambon,
                // EntityType.TAO,
            };

            _endYear = DateTime.Now.Year;

            foreach (var entityType in entityTypes)
            {
                _numberyByYear[entityType] = CalcEntityTypeByYear(entityType, _allEntities);

                var series = new Series();
                series.LegendText = entityType.Translate(Language.English);
                series.Tag        = entityType;
                foreach (var dataPoint in _numberyByYear[entityType])
                {
                    series.Points.Add(new DataPoint(dataPoint.Item1, dataPoint.Item2));
                }
                series.ChartType = SeriesChartType.Line;
                chart.Series.Add(series);
            }

            edtYear.Maximum = _endYear;
            edtYear.Minimum = _startYear;
            edtYear.Value   = _endYear;
        }
Пример #2
0
        private void WikiData_Load(object sender, EventArgs e)
        {
            chkTypes.Items.Add(EntityType.Changwat);
            chkTypes.Items.Add(EntityType.Amphoe);
            chkTypes.Items.Add(EntityType.Tambon);
            chkTypes.Items.Add(EntityType.Muban);
            chkTypes.Items.Add(EntityType.Thesaban);
            chkTypes.Items.Add(EntityType.TAO);
            chkTypes.Items.Add(EntityType.Khet);
            chkTypes.Items.Add(EntityType.Khwaeng);
            chkTypes.Items.Add(EntityType.Chumchon);
            chkTypes.SetItemCheckState(0, CheckState.Checked);

            allEntities = new List <Entity>();
            var entities = GlobalData.CompleteGeocodeList();

            allEntities.AddRange(entities.FlatList().Where(x => !x.IsObsolete));
            entities.PropagatePostcodeRecursive();

            var allThesaban = allEntities.Where(x => x.type.IsCompatibleEntityType(EntityType.Thesaban));

            foreach (var entity in allThesaban)
            {
                if ((entity.wiki == null) || String.IsNullOrEmpty(entity.wiki.wikidata))
                {
                    var office = entity.office.FirstOrDefault();
                    if (office == null)
                    {
                        edtCollisions.Text += "No office: " + entity.geocode.ToString() + Environment.NewLine;
                    }
                    else if ((office.wiki != null) && !String.IsNullOrEmpty(office.wiki.wikidata))
                    {
                        edtCollisions.Text += "Wikidata at office: " + entity.geocode.ToString() + Environment.NewLine;
                    }
                }
            }

            var allTambon = allEntities.Where(x => x.type == EntityType.Tambon).ToList();

            foreach (var tambon in allTambon)
            {
                var localGovernmentEntity = tambon.CreateLocalGovernmentDummyEntity();
                if (localGovernmentEntity != null)
                {
                    allEntities.Add(localGovernmentEntity);
                }
            }

            cbxChangwat.Items.AddRange(allEntities.Where(x => x.type.IsCompatibleEntityType(EntityType.Changwat)).ToArray());
            lblTambonInfo.Text = String.Empty;
        }
Пример #3
0
        private void DisambiguationForm_Load(Object sender, EventArgs e)
        {
            cbxEntityType.Items.Add(EntityType.Tambon);
            cbxEntityType.Items.Add(EntityType.TAO);
            cbxEntityType.Items.Add(EntityType.ThesabanTambon);
            cbxEntityType.Items.Add(EntityType.ThesabanMueang);

            allEntities = new List <Entity>();
            var entities = GlobalData.CompleteGeocodeList();

            allEntities.AddRange(entities.FlatList().Where(x => !x.IsObsolete));
            cbxProvinces.Items.AddRange(allEntities.Where(x => x.type == EntityType.Changwat).ToArray());

            var allTambon = allEntities.Where(x => x.type == EntityType.Tambon).ToList();

            foreach (var tambon in allTambon)
            {
                var localGovernmentEntity = tambon.CreateLocalGovernmentDummyEntity();
                if (localGovernmentEntity != null && !localGovernmentEntity.IsObsolete)
                {
                    allEntities.Add(localGovernmentEntity);
                }
            }
        }
Пример #4
0
 private void MubanHelperForm_Load(object sender, EventArgs e)
 {
     cbxChangwat.Items.AddRange(GlobalData.CompleteGeocodeList().FlatList().Where(x => x.type.IsCompatibleEntityType(EntityType.Changwat)).ToArray());
 }
Пример #5
0
        private void WikiData_Load(object sender, EventArgs e)
        {
            chkTypes.Items.Add(EntityType.Changwat);
            chkTypes.Items.Add(EntityType.Amphoe);
            chkTypes.Items.Add(EntityType.Tambon);
            chkTypes.Items.Add(EntityType.Muban);
            chkTypes.Items.Add(EntityType.Thesaban);
            chkTypes.Items.Add(EntityType.TAO);
            chkTypes.Items.Add(EntityType.Khet);
            chkTypes.Items.Add(EntityType.Khwaeng);
            chkTypes.Items.Add(EntityType.Chumchon);
            chkTypes.Items.Add(EntityType.PAO);
            chkTypes.SetItemCheckState(0, CheckState.Checked);

            allEntities = new List <Entity>();
            var entities = GlobalData.CompleteGeocodeList();

            entities.PropagateObsoleteToSubEntities();
            allEntities.AddRange(entities.FlatList().Where(x => !x.IsObsolete));
            entities.PropagatePostcodeRecursive();

            var allThesaban = allEntities.Where(x => x.type.IsCompatibleEntityType(EntityType.Thesaban));

            foreach (var entity in allThesaban)
            {
                if ((entity.wiki == null) || String.IsNullOrEmpty(entity.wiki.wikidata))
                {
                    var office = entity.office.FirstOrDefault();
                    if (office == null)
                    {
                        edtCollisions.Text += String.Format(CultureInfo.CurrentUICulture, "No office: {0}" + Environment.NewLine, entity.geocode);
                    }
                    else if ((office.wiki != null) && !String.IsNullOrEmpty(office.wiki.wikidata))
                    {
                        edtCollisions.Text += String.Format(CultureInfo.CurrentUICulture, "WikiData at office: {0}" + Environment.NewLine, entity.geocode);
                    }
                }
            }

            var allTambon = allEntities.Where(x => x.type == EntityType.Tambon).ToList();

            foreach (var tambon in allTambon)
            {
                var localGovernmentEntity = tambon.CreateLocalGovernmentDummyEntity();
                if (localGovernmentEntity != null)
                {
                    allEntities.Add(localGovernmentEntity);
                }
            }
            var allChangwat = allEntities.Where(x => x.type == EntityType.Changwat).ToList();

            foreach (var changwat in allChangwat)
            {
                var pao = changwat.CreateLocalGovernmentDummyEntity();
                if (pao != null)
                {
                    allEntities.Add(pao);
                }
            }
            var localGovernments = allEntities.Where(x => x.type.IsLocalGovernment());

            foreach (var lao in localGovernments)
            {
                lao.CalculatePostcodeForLocalAdministration(allTambon);
            }

            GlobalData.LoadPopulationData(PopulationDataSourceType.DOPA, GlobalData.PopulationStatisticMaxYear);
            Entity.CalculateLocalGovernmentPopulation(localGovernments, allTambon, PopulationDataSourceType.DOPA, GlobalData.PopulationStatisticMaxYear);

            cbxChangwat.Items.AddRange(allEntities.Where(x => x.type.IsCompatibleEntityType(EntityType.Changwat)).ToArray());
            lblTambonInfo.Text = String.Empty;

            var thesabanMueangWithWikiData = localGovernments.Where(x => x.type == EntityType.ThesabanMueang && (x.wiki == null || String.IsNullOrEmpty(x.wiki.wikidata))).Select(x => String.Format(CultureInfo.CurrentUICulture, "{0} ({1})", x.english, x.geocode)).ToArray();

            edtCollisions.Text = String.Join(Environment.NewLine, thesabanMueangWithWikiData);
        }