コード例 #1
0
 private void DictionaryLevel1UsingAlternateNames(GazetteerRecord gazetteerRecord)
 {
     // P1A
     if (!string.IsNullOrEmpty(gazetteerRecord.AltName1))
     {
         string altLevel1Key1 = gazetteerRecord.AltName1.Trim().ToLower();
         if (!level1Dictionary.ContainsKey(altLevel1Key1))
             level1Dictionary.Add(
                 altLevel1Key1,
                 new GeoCode(gazetteerRecord.Id1, gazetteerRecord.Name1));
     }
 }
コード例 #2
0
 private void DictionaryLevel1UsingAlternateNames(GazetteerRecord gazetteerRecord)
 {
     // P1A
     if (!string.IsNullOrEmpty(gazetteerRecord.AltName1))
     {
         string altLevel1Key1 = gazetteerRecord.AltName1.Trim().ToLower();
         if (!level1Dictionary.ContainsKey(altLevel1Key1))
         {
             level1Dictionary.Add(
                 altLevel1Key1,
                 new GeoCode(gazetteerRecord.Id1, gazetteerRecord.Name1));
         }
     }
 }
コード例 #3
0
 private static void SetValue(
     GazetteerRecord gazetteerRecord,
     string propertyName,
     DataRow row,
     string columnName)
 {
     if (!string.IsNullOrEmpty(columnName))
     {
         Type type = gazetteerRecord.GetType();
         PropertyInfo propertyInfo = type.GetProperty(propertyName);
         propertyInfo.SetValue(
             gazetteerRecord,
             row[columnName].ToString(),
             new object[] {});
     }
 }
コード例 #4
0
 private static void SetValue(
     GazetteerRecord gazetteerRecord,
     string propertyName,
     DataRow row,
     string columnName)
 {
     if (!string.IsNullOrEmpty(columnName))
     {
         Type         type         = gazetteerRecord.GetType();
         PropertyInfo propertyInfo = type.GetProperty(propertyName);
         propertyInfo.SetValue(
             gazetteerRecord,
             row[columnName].ToString(),
             new object[] {});
     }
 }
コード例 #5
0
        private void DictionaryLevel2UsingAlternateNames(GazetteerRecord gazetteerRecord)
        {
            // standard name
            string level1 = gazetteerRecord.Name1.Trim().ToLower();

            if (!string.IsNullOrEmpty(gazetteerRecord.AltName2))
            {
                string altLevel2 = gazetteerRecord.AltName2.Trim().ToLower();

                // P1 + T1A
                string altLevel2Key1 = level1 + KeySeperator + altLevel2;
                if (!level2Dictionary.ContainsKey(altLevel2Key1))
                    level2Dictionary.Add(
                        altLevel2Key1,
                        new GeoCode(gazetteerRecord.Id2, gazetteerRecord.Name2));
            }
        }
コード例 #6
0
        private void AddRecord(ICollection <GazetteerRecord> locationCodeList, DataRow row)
        {
            GazetteerRecord gazetteerRecord = new GazetteerRecord();

            SetValue(gazetteerRecord, "Name1", row, ColumnHeaders.Level1Name);
            SetValue(gazetteerRecord, "Name2", row, ColumnHeaders.Level2Name);
            SetValue(gazetteerRecord, "Name3", row, ColumnHeaders.Level3Name);

            SetValue(gazetteerRecord, "Id1", row, ColumnHeaders.Level1Code);
            SetValue(gazetteerRecord, "Id2", row, ColumnHeaders.Level2Code);
            SetValue(gazetteerRecord, "Id3", row, ColumnHeaders.Level3Code);

            SetValue(gazetteerRecord, "AltName1", row, ColumnHeaders.Level1AltName);
            SetValue(gazetteerRecord, "AltName2", row, ColumnHeaders.Level2AltName);
            SetValue(gazetteerRecord, "AltName3", row, ColumnHeaders.Level3AltName);

            locationCodeList.Add(gazetteerRecord);
        }
コード例 #7
0
        private void DictionaryLevel2UsingAlternateNames(GazetteerRecord gazetteerRecord)
        {
            // standard name
            string level1 = gazetteerRecord.Name1.Trim().ToLower();

            if (!string.IsNullOrEmpty(gazetteerRecord.AltName2))
            {
                string altLevel2 = gazetteerRecord.AltName2.Trim().ToLower();

                // P1 + T1A
                string altLevel2Key1 = level1 + KeySeperator + altLevel2;
                if (!level2Dictionary.ContainsKey(altLevel2Key1))
                {
                    level2Dictionary.Add(
                        altLevel2Key1,
                        new GeoCode(gazetteerRecord.Id2, gazetteerRecord.Name2));
                }
            }
        }
コード例 #8
0
        public List<GazetteerRecord> GadmList()
        {
            List<GazetteerRecord> gadmList = new List<GazetteerRecord>();
            foreach (var line in lines)
            {
                GazetteerRecord record = new GazetteerRecord();
                record.Name1 = line.Item1[0];
                record.Name2 = line.Item1[1];
                record.Name3 = line.Item1[2];
                record.Id1 = line.Item2[0];
                record.Id2 = line.Item2[1];
                record.Id3 = line.Item2[2];
                if (line.Item3 != null)
                {
                    record.AltName1 = line.Item3[0];
                    record.AltName2 = line.Item3[1];
                    record.AltName3 = line.Item3[2];
                }

                gadmList.Add(record);
            }

            return gadmList;
        }
コード例 #9
0
        private void AddRecord(ICollection<GazetteerRecord> locationCodeList, DataRow row)
        {
            GazetteerRecord gazetteerRecord = new GazetteerRecord();

            SetValue(gazetteerRecord, "Name1", row, ColumnHeaders.Level1Name);
            SetValue(gazetteerRecord, "Name2", row, ColumnHeaders.Level2Name);
            SetValue(gazetteerRecord, "Name3", row, ColumnHeaders.Level3Name);

            SetValue(gazetteerRecord, "Id1", row, ColumnHeaders.Level1Code);
            SetValue(gazetteerRecord, "Id2", row, ColumnHeaders.Level2Code);
            SetValue(gazetteerRecord, "Id3", row, ColumnHeaders.Level3Code);

            SetValue(gazetteerRecord, "AltName1", row, ColumnHeaders.Level1AltName);
            SetValue(gazetteerRecord, "AltName2", row, ColumnHeaders.Level2AltName);
            SetValue(gazetteerRecord, "AltName3", row, ColumnHeaders.Level3AltName);

            locationCodeList.Add(gazetteerRecord);
        }