Exemplo n.º 1
0
        /// <summary>
        /// 路网数据下载
        /// </summary>
        public void DownLoadRoadLine()
        {
            var roads         = new GaoDeRoads();
            var roaddataTable = new DataTable(this.City);

            roaddataTable.Columns.AddRange(
                new[]
                { new DataColumn("Name"), new DataColumn("WIDTH"), new DataColumn("TYPE"), new DataColumn("PATH") });

            Console.WriteLine("下载{0}中", this.City);
            roads.downOverHandler += () =>
            {
                var directory = this.GetCityDirectory();
                var path      = Path.Combine(directory, this.CityPinyin + "_roadNet.shp");
                ShpFileHelper.SaveShpFile(
                    roaddataTable,
                    path,
                    wkbGeometryType.wkbLineString,
                    ProjectConvert.GAODE84_WGS);
                roaddataTable.Rows.Clear();
            };
            roads.roadDateDowningHandler += (RoadModel road, int index, int count) =>
            {
                foreach (string path in road.paths)
                {
                    DataRow row = roaddataTable.NewRow();
                    row[0] = road.name;
                    row[1] = road.width;
                    row[2] = road.type;
                    row[3] = path;
                    roaddataTable.Rows.Add(row);
                }
            };
            roads.downLoadRoadsByCityName(this.City);
        }
Exemplo n.º 2
0
        private void converteEnd()
        {
            MethodInvoker invoker = delegate
            {
                if (isCreateShp)
                {
                    if (File.Exists(this.outPutPath + "\\" + this.outputFileName.Split('.')[0] + ".shp"))
                    {
                        File.Delete(this.outPutPath + "\\" + this.outputFileName.Split('.')[0] + ".shp");
                    }
                    if (File.Exists(this.outPutPath + "\\" + this.outputFileName.Split('.')[0] + ".dbf"))
                    {
                        File.Delete(this.outPutPath + "\\" + this.outputFileName.Split('.')[0] + ".dbf");
                    }
                    if (File.Exists(this.outPutPath + "\\" + this.outputFileName.Split('.')[0] + ".shx"))
                    {
                        File.Delete(this.outPutPath + "\\" + this.outputFileName.Split('.')[0] + ".shx");
                    }
                    ShpFileHelper.SaveShpFile(this.dataTable, this.outPutPath + "\\" + this.outputFileName.Split('.')[0] + ".shp", OSGeo.OGR.wkbGeometryType.wkbPoint, ProjectConvert.BAIDU_WGS);
                }
                if (!this.isStop)
                {
                    MessageBox.Show("转换成功");
                }
            };

            if ((!base.IsDisposed) && base.InvokeRequired)
            {
                base.Invoke(invoker);
            }
            else
            {
                invoker();
            }
        }
Exemplo n.º 3
0
        private void saveDataInShp()
        {
            MethodInvoker invoker = delegate
            {
                this.progressBar.Value = 100;
                this.labMessage.Text   = "正在保存文件到shp";
                string path = this.roadSavePath + "\\" + this.roadCurrentCity + "_路网.shp";
                int    x    = 0;
                while (File.Exists(path))
                {
                    x++;
                    path = path.Substring(0, path.LastIndexOf('.')) + x.ToString() + ".shp";
                }
                ShpFileHelper.SaveShpFile(this.RoaddataTable, path, wkbGeometryType.wkbLineString, ProjectConvert.GAODE84_WGS);
                this.progressBar.Value = 100;
                this.labMessage.Text   = "保存完成";
                this.progressBar.Update();
            };

            if ((!base.IsDisposed) && base.InvokeRequired)
            {
                base.Invoke(invoker);
            }
            else
            {
                invoker();
            }
        }
        private void SavePoiData()
        {
            string name = this.keyWords.Trim() != "" ? this.keyWords.Trim() : "_兴趣点";

            SVCHelper.ExportToSvc(this.dataTable, this.path + "\\" + name + ".csv");
            this.progressBar.Value = 100;
            this.labMessage.Text   = "提示:已下载完成";
            this.progressBar.Update();
            if (this.isCreatShp)
            {
                this.labMessage.Text = "提示:已下载完成,生成shp...";
                ShpFileHelper.SaveShpFile(this.dataTable, this.path + "\\" + name + ".shp", OSGeo.OGR.wkbGeometryType.wkbPoint, ProjectConvert.NONE);
                this.labMessage.Text = "提示:生成shp成功";
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// excel 导成shap
        /// </summary>
        public void ExcelToShap()
        {
            var files = Directory.GetFiles(this.GetCityDirectory(), "*.xls");

            foreach (var file in files)
            {
                var dataTable = AsposeCellsHelper.ExportToDataTable(file, true);

                var shpPath = Path.Combine(
                    this.GetCityDirectory(),
                    string.Format("{0}_{1}.shp", this.CityPinyin, file.Contains("roadcross") ? "roadcross" : "poi"));
                ShpFileHelper.SaveShpFile(
                    dataTable,
                    shpPath,
                    file.Contains("roadnet") ? wkbGeometryType.wkbLineString : wkbGeometryType.wkbPoint,
                    ProjectConvert.NONE);
            }
        }
Exemplo n.º 6
0
        private void downEnd()
        {
            MethodInvoker invoker = delegate
            {
                ShpFileHelper.SaveShpFile(this.crossDataTable, this.path + "\\" + this.currentCity + "_路口.shp", OSGeo.OGR.wkbGeometryType.wkbPoint, ProjectConvert.NONE);
                this.btnDown.Enabled   = true;
                this.progressBar.Value = 100;
                this.labMessage.Text   = "提示:已下载路口数据完成";
                this.progressBar.Update();
            };

            if ((!base.IsDisposed) && base.InvokeRequired)
            {
                base.Invoke(invoker);
            }
            else
            {
                invoker();
            }
        }
Exemplo n.º 7
0
        private void adminDivisionDownedHandler()
        {
            MethodInvoker invoker = delegate
            {
                labMessage.Text        = "提示:下载完成";
                this.progressBar.Value = 100;
                if (this.countryDataTable.Rows.Count > 0)
                {
                    ShpFileHelper.SaveShpFile(this.countryDataTable, this.path + "\\" + this._CurrentName + "_country.shp", OSGeo.OGR.wkbGeometryType.wkbPolygon, ProjectConvert.BAIDU_WGS);
                    labMessage.Text = "提示:保存" + this.path + "\\" + this._CurrentName + "_country.shp成功";
                }
                if (this.provinceDataTable.Rows.Count > 0)
                {
                    ShpFileHelper.SaveShpFile(this.provinceDataTable, this.path + "\\" + this._CurrentName + "_province.shp", OSGeo.OGR.wkbGeometryType.wkbPolygon, ProjectConvert.BAIDU_WGS);
                    labMessage.Text = "提示:保存" + this.path + "\\" + this._CurrentName + "_province.shp成功";
                }
                if (this.cityDataTable.Rows.Count > 0)
                {
                    ShpFileHelper.SaveShpFile(this.cityDataTable, this.path + "\\" + this._CurrentName + "_city.shp", OSGeo.OGR.wkbGeometryType.wkbPolygon, ProjectConvert.BAIDU_WGS);
                    labMessage.Text = "提示:保存" + this.path + "\\" + this._CurrentName + "_city.shp成功";
                }
                if (this.districtDataTable.Rows.Count > 0)
                {
                    ShpFileHelper.SaveShpFile(this.districtDataTable, this.path + "\\" + this._CurrentName + "_district.shp", OSGeo.OGR.wkbGeometryType.wkbPolygon, ProjectConvert.BAIDU_WGS);
                    labMessage.Text = "提示:保存" + this.path + "\\" + this._CurrentName + "_district.shp成功";
                }
                labMessage.Text = "提示:保存成功";
            };

            if (base.InvokeRequired)
            {
                base.Invoke(invoker);
            }
            else
            {
                invoker();
            }
        }
Exemplo n.º 8
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(this.rtxbRoadNames.Text))
            {
                return;
            }
            if (this.cmbCity.SelectedItem == null)
            {
                return;
            }
            var cityName  = ((ComboboxItem)this.cmbCity.SelectedItem).Text;
            var roadNames = this.rtxbRoadNames.Text.Replace(",", ",").Split(',');

            var roadMap       = new GaoDeRoads();
            var roaddataTable = new DataTable();

            roaddataTable.Columns.Add("Name", Type.GetType("System.String"));
            roaddataTable.Columns.Add("WIDTH", Type.GetType("System.String"));
            roaddataTable.Columns.Add("TYPE", Type.GetType("System.String"));
            roaddataTable.Columns.Add("PATH", Type.GetType("System.String"));
            var m = 0;

            roadMap.roadDateDowningHandler += (RoadModel road, int index, int count) =>
            {
                for (int i = 0; i < road.paths.Count; i++)
                {
                    m++;
                    DataRow row = roaddataTable.NewRow();
                    row[0] = road.name;
                    row[1] = road.width;
                    row[2] = road.type;
                    row[3] = road.paths[i];
                    roaddataTable.Rows.Add(row);
                }
                this.BeginInvoke(
                    new MethodInvoker(
                        () =>
                {
                    if (this.IsDisposed)
                    {
                        return;
                    }
                    this.progressBar.Value = index * 100 / count;
                    this.labMessage.Text   = "已下载完道路:" + road.name;
                    this.progressBar.Update();
                }));
            };

            roadMap.downOverHandler += () =>
            {
                var path = System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, cityName + ".shp");
                ShpFileHelper.SaveShpFile(roaddataTable, path, wkbGeometryType.wkbLineString, ProjectConvert.GAODE84_WGS);
                this.BeginInvoke(
                    new MethodInvoker(
                        () =>
                {
                    if (this.IsDisposed)
                    {
                        return;
                    }
                    this.progressBar.Value = 100;
                    this.labMessage.Text   = "保存完成";
                    this.progressBar.Update();
                }));
            };
            new Thread(
                () =>
            {
                roadMap.DownLoadRoads(cityName, roadNames.ToList());
            }).Start();
        }