Beispiel #1
0
        public string getCodeByCityName(string cityName)
        {
            List <City> cities = CityConfig.GetInstance().GetCityByName(cityName);

            if (cities.Count > 0)
            {
                return(cities[0].gaodeCode);
            }
            return(string.Empty);
        }
Beispiel #2
0
        private void FillBaiduCode(List <City> cities)
        {
            var list = CityConfig.GetInstance().Countryconfig.countries;

            foreach (Province province in list)
            {
                var city = cities.Find(m => m.CityName.Contains(province.name) || province.name.Contains(m.CityName));
                if (city != null)
                {
                    province.baiduCode = city.Code;
                }
            }
        }
Beispiel #3
0
        public void ExportChina()
        {
            var otherNames = new string[] { "2912", "2911" };
            var provinces  =
                CityConfig.GetInstance()
                .Countryconfig.countries.Where(m => !otherNames.Contains(m.baiduCode))
                .Where(m => m.name == "上海市")
                .ToList();
            var others    = new string[] { "北京市", "天津市", "重庆市", "上海市" };
            var dataTable = new DataTable();

            dataTable.Columns.AddRange(
                new DataColumn[]
            {
                new DataColumn("area_code"), new DataColumn("X"),
                new DataColumn("area_name"), new DataColumn("parent_code"), new DataColumn("Y"),
                new DataColumn("PATH")
            });
            foreach (Province province in provinces)
            {
                //dataTable.Rows.Clear();
                if (others.Contains(province.name))
                {
                    province.cities.ForEach(
                        m =>
                    {
                        m.name = province.name;
                        ResoleGoadeData(m, dataTable, "1");
                    });
                }
                else
                {
                    ResoleProvinceData(province, dataTable);
                    province.cities.ForEach(m => ResoleGoadeData(m, dataTable, province.baiduCode));
                }
            }
            //SVCHelper.ExportToSvc(dataTable, Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "上海市.csv"));
            ShpFileHelper.SaveShpFile(dataTable, System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "上海市.shp"), wkbGeometryType.wkbPolygon, ProjectConvert.GCJ_WGS);
        }
Beispiel #4
0
 /// <summary>
 /// 获取配置信息(单例模式)
 /// </summary>
 /// <returns></returns>
 public static CityConfig GetInstance()
 {
     return(instance ?? (instance = new CityConfig()));
 }