Beispiel #1
0
        /// <summary>
        /// Loads state data
        /// </summary>
        private void LoadStateData()
        {
            this.stateCodeMapping = new Dictionary <string, string>();

            var adminCode1Path = this.config[Constants.StateFilePathKey];
            var dataParser     = new TabSeparatedDataParser(adminCode1Path);
            var data           = dataParser.ParseData();

            foreach (DataRow dataRow in data.Rows)
            {
                var geoNameCode = dataRow["code"].ToString();
                var name        = dataRow["name"].ToString();

                this.stateCodeMapping.Add(geoNameCode, name);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Loads the city data from files
        /// </summary>
        /// <returns>The cities</returns>
        public List <City> LoadData()
        {
            this.LoadStateData();

            var filePath   = this.config[Constants.FilePathKey];
            var dataParser = new TabSeparatedDataParser(filePath);
            var data       = dataParser.ParseData();

            return((from DataRow dataRow in data.Rows
                    select new City
            {
                Id = Convert.ToInt64(dataRow["id"]),
                Name = dataRow["name"].ToString(),
                LocationInformation = new LocationInformation(Convert.ToDouble(dataRow["lat"]), Convert.ToDouble(dataRow["long"])),
                RegionName = this.stateCodeMapping[$"{dataRow["country"]}.{dataRow["admin1"]}"],
                CountryCode = dataRow["country"].ToString()
            }).ToList());
        }