Beispiel #1
0
        private void btnCoverter_Click(object sender, EventArgs e)
        {
            this.path = this.txbPath.Text.Trim();
            if (!System.IO.File.Exists(this.path))
            {
                MessageBox.Show("文件不存在");
                return;
            }
            FileInfo file = new FileInfo(this.path);
            //if (file.Extension != ".csv")
            //{
            //    MessageBox.Show("不支持改文件类型");
            //    return;
            //}
            IntPtr vHandle = _lopen(this.path, OF_READWRITE | OF_SHARE_DENY_NONE);

            if (vHandle == HFILE_ERROR)
            {
                MessageBox.Show(this.path + "被其他程序占用!");
                return;
            }
            CloseHandle(vHandle);
            string[] columns = AsposeCellsHelper.GetFileColumns(this.path);
            //if (!SVCHelper.isContainsCloumnName(this.path, "x") || !SVCHelper.isContainsCloumnName(this.path, "y"))
            //{
            //    MessageBox.Show("文件中没有同时包含x和y列,大小写不区分");
            //    return;
            //}
            if (!columns.Contains("X") || !columns.Contains("Y"))
            // (!SVCHelper.isContainsCloumnName(this.path, "x") || !SVCHelper.isContainsCloumnName(this.path, "y"))
            {
                MessageBox.Show("文件中没有同时包含x和y列,大小写不区分");
                return;
            }
            btnCoverter.Enabled = false;
            btnStop.Enabled     = true;
            if (checkBoxX1.Checked)
            {
                this.isCreateShp = true;
            }
            this.isStop = false;
            this.InitDataTable();
            this.outPutPath = file.DirectoryName;
            if (this.outPutPath.Substring(this.outPutPath.Length - 1, 1) == "\\")
            {
                this.outPutPath = this.outPutPath.Substring(0, this.outPutPath.Length - 1);
            }
            this.outputFileName = file.Name.Split('.')[0] + "_WGS84.csv";
            SVCHelper.ExportToSvc(this.dataTable, this.outPutPath + "\\" + this.outputFileName);
            this.thread = new System.Threading.Thread(this.converteData);
            thread.Start();
        }
        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成功";
            }
        }
        private void poiDownHandler(POIInfo poi, int index, int count)
        {
            MethodInvoker invoker = delegate
            {
                k++;
                DataRow row = this.dataTable.NewRow();
                row["name"] = poi.name;
                row["X"]    = poi.cx;
                row["Y"]    = poi.cy;
                //row["WGS84X"] = poi.cx;
                //row["WGS84Y"] = poi.cy;
                row["r_addr"] = poi.address.Replace(",", "");
                row["type"]   = poi.type;
                row["phone"]  = poi.phone.Replace(",", ";");
                this.dataTable.Rows.Add(row);
                if (this.dataTable.Rows.Count % 10 == 0 || index == count)
                {
                    try
                    {
                        string name = this.keyWords.Trim() != "" ? this.keyWords.Trim() : "_兴趣点";
                        SVCHelper.ExportToSvc(this.dataTable, this.path + "\\" + name + ".csv");
                    }
                    catch (Exception ex)
                    {
                        log.Error(ex);
                    }
                }
                if (index > count)
                {
                    index = count;
                }
                this.progressBar.Value = index * 100 / count;
                this.labMessage.Text   = "提示:已下载兴趣点:" + k.ToString() + "条," + index.ToString() + "/" + count.ToString();
                this.progressBar.Update();
            };

            if ((!base.IsDisposed) && base.InvokeRequired)
            {
                base.Invoke(invoker);
            }
            else
            {
                invoker();
            }
        }
Beispiel #4
0
        private void roadDownHandler(RoadModel road, int index, int count)
        {
            MethodInvoker invoker = delegate
            {
                for (int i = 0; i < road.paths.Count; i++)
                {
                    m++;
                    DataRow row = this.RoaddataTable.NewRow();
                    row[0] = road.name;
                    row[1] = road.width;
                    row[2] = road.type;
                    row[3] = road.paths[i];
                    //row["WGSPATH"] = road.getWgsPath(i);


                    //row["length"] = 0;
                    //row["car"] = 1;
                    //row["walk"] = road.IsHeightWay ? 0 : 1;
                    //row["speed"] = road.getSpeed();
                    //row["highspeed"] = road.IsHeightWay ? 1 : 0;
                    //row["np_level"] = road.getNpLevel();

                    this.RoaddataTable.Rows.Add(row);
                }
                SVCHelper.ExportToSvc(
                    this.RoaddataTable,
                    this.roadSavePath + "\\" + this.roadCurrentCity + "_道路.csv");
                this.progressBar.Value = index * 100 / count;
                this.labMessage.Text   = "已下载完道路:" + road.name;
                this.progressBar.Update();
            };

            if ((!base.IsDisposed) && base.InvokeRequired)
            {
                base.Invoke(invoker);
            }
            else
            {
                invoker();
            }
        }
Beispiel #5
0
        private void roadCrossDownHandler(RoadCrossModel roadCross, int index, int count)
        {
            MethodInvoker invoker = delegate
            {
                if (roadCross.id != "" && !this.dicCross.ContainsKey(roadCross.id))
                {
                    crossCount++;
                    DataRow row = this.crossDataTable.NewRow();
                    row["first_name"]  = roadCross.first_name;
                    row["second_name"] = roadCross.second_name;
                    //row["first_id"] = roadCross.first_id;
                    //row["second_id"] = roadCross.second_id;
                    row["x"]    = roadCross.wgs_x;
                    row["y"]    = roadCross.wgs_y;
                    row["name"] = string.Format("{0}_{1}", roadCross.first_name, roadCross.second_name);
                    this.crossDataTable.Rows.Add(row);
                    if (this.crossDataTable.Rows.Count % 10 == 0 || index == count)
                    {
                        SVCHelper.ExportToSvc(this.crossDataTable, this.path + "\\" + this.currentCity + "_WGS.csv");
                    }
                    this.progressBar.Value = index * 100 / count;
                    this.labMessage.Text   = "提示:已下载路口数据:" + crossCount.ToString() + "条";
                    this.progressBar.Update();
                    this.dicCross.Add(roadCross.id, roadCross.id);
                }
            };

            if ((!base.IsDisposed) && base.InvokeRequired)
            {
                base.Invoke(invoker);
            }
            else
            {
                invoker();
            }
        }