Пример #1
0
        private void CityToExcel(List <City> cities, string fileName)
        {
            DataTable dataTable = new DataTable();

            dataTable.Columns.AddRange(new DataColumn[]
            {
                new DataColumn("name"),
                new DataColumn("X"),
                new DataColumn("Y"),
                new DataColumn("PATH"),
            });
            foreach (City city in cities)
            {
                var row = dataTable.NewRow();
                row["name"] = city.CityName;
                row["PATH"] = city.GetGJC02Bound();
                var center = city.getGJC02Center();
                row["X"] = center.lon;
                row["Y"] = center.lat;

                dataTable.Rows.Add(row);
            }
            ShpFileHelper.SaveShpFile(dataTable, fileName, wkbGeometryType.wkbPolygon, ProjectConvert.GCJ_WGS);
            //SVCHelper.ExportToSvc(dataTable, fileName);
            //AsposeCellsHelper.ExportToExcel(dataTable,fileName);
        }
Пример #2
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);
        }