Esempio n. 1
0
        private void converteMessage(DataRow row, int index, int count)
        {
            MethodInvoker invoker = delegate
            {
                if (index < count + 1)
                {
                    SVCHelper.AddToSvc(row, this.outPutPath + "\\" + this.outputFileName);
                    this.progressBar.Value = index * 100 / count;
                }
                if (index >= count)
                {
                    this.btnCoverter.Enabled = true;
                    this.btnStop.Enabled     = false;
                    this.progressBar.Value   = 100;
                }
            };

            if ((!base.IsDisposed) && base.InvokeRequired)
            {
                base.Invoke(invoker);
            }
            else
            {
                invoker();
            }
        }
Esempio n. 2
0
 private void InitDataTable()
 {
     this.dataTable = SVCHelper.ReadCsvFile(this.path);
     dataTable.Columns.Add("WGS84_X", Type.GetType("System.String"));
     dataTable.Columns.Add("WGS84_Y", Type.GetType("System.String"));
     dataTable.Rows.Clear();
 }
Esempio n. 3
0
        private void converteData()
        {
            DataTable tempDataTable = SVCHelper.ReadCsvFile(this.path);
            int       k             = 0;

            foreach (DataRow row in tempDataTable.Rows)
            {
                if (!this.isStop)
                {
                    k++;
                    string xString = row["X"] != null ? row["X"].ToString() : "";
                    string yString = row["Y"] != null ? row["Y"].ToString() : "";
                    double x = 0.0, y = 0.0;
                    double.TryParse(xString, out x);
                    double.TryParse(yString, out y);
                    Coord coord = new Coord(x, y);
                    coord = CoordHelper.Gcj2Wgs(coord.lon, coord.lat);
                    DataRow newRow = this.dataTable.NewRow();
                    for (int i = 0; i < row.ItemArray.Length; i++)
                    {
                        newRow[i] = row[i];
                    }
                    newRow["WGS84_X"] = coord.lon;
                    newRow["WGS84_Y"] = coord.lat;
                    if (this.convertHandler != null)
                    {
                        this.convertHandler(newRow, k, tempDataTable.Rows.Count);
                    }
                }
            }
            if (this.converteEndHandler != null)
            {
                this.converteEndHandler();
            }
        }
Esempio n. 4
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);

            //if (!SVCHelper.isContainsCloumnName(this.path, "x") || !SVCHelper.isContainsCloumnName(this.path, "y"))
            //{
            //    MessageBox.Show("文件中没有同时包含x和y列,大小写不区分");
            //    return;
            //}
            string[] columns = AsposeCellsHelper.GetFileColumns(this.path);

            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();
            }
        }
Esempio n. 7
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();
            }
        }
Esempio n. 8
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();
            }
        }