Exemple #1
0
        private void btnBatchJp_Click(object sender, EventArgs e)
        {
            double[]      latlng = new double[2];
            StringBuilder sbCar  = new StringBuilder();

            //批量将高德地图坐标转为GPS坐标
            string    sql      = "SELECT id,latitude,longitude FROM dw_stop";
            DbHelper  dbHelper = new DbHelper();
            DataTable dt       = dbHelper.Fill(sql);

            //循环处理每条坐标 记录
            foreach (DataRow dr in dt.Rows)
            {
                string sguid = dr[0].ToString();     //坐标标识
                string slat  = dr[1].ToString();     //纬度
                string slon  = dr[2].ToString();     //经度

                GpsCorrect.TransToGps(Convert.ToDouble(slat), Convert.ToDouble(slon), latlng);

                sql = "UPDATE dw_stop set latitude={0},longitude={1} where id='{2}';" + Environment.NewLine;
                sql = string.Format(sql, latlng[0], latlng[1], sguid);

                sbCar.Append(sql);
            }

            dbHelper.Add(sbCar.ToString());

            MessageBox.Show("数据处理完成");
        }
Exemple #2
0
        private void btnJP_Click(object sender, EventArgs e)
        {
            double[] latlng  = new double[2];
            string   FileDir = txtInDir.Text;                //待处理经纬度文件所在目录

            string[] arrFiles = Directory.GetFiles(FileDir); //目录内的所有经纬度文件
            string   SQL;

            StringBuilder sbCar = new StringBuilder();

            foreach (string doFileName in arrFiles)
            {
                //打开excel文件,放到数据表中
                DataTable dt = ExcelHelper.ReadExelToTable(doFileName, 0);

                //循环处理每条坐标 记录
                foreach (DataRow dr in dt.Rows)
                {
                    string sguid = dr[0].ToString();     //坐标标识
                    string slat  = dr[1].ToString();     //纬度
                    string slon  = dr[2].ToString();     //经度

                    GpsCorrect.TransToGps(Convert.ToDouble(slat), Convert.ToDouble(slon), latlng);

                    SQL = "UPDATE line_standinfo set slat={0},slon={1} where sguid='{2}';" + Environment.NewLine;
                    SQL = string.Format(SQL, latlng[0], latlng[1], sguid);

                    sbCar.Append(SQL);
                }
            }

            string savename = @"f:\临时文件\MapToGps.txt";

            if (File.Exists(savename))
            {
                File.Delete(savename);
            }
            StreamWriter sw = new StreamWriter(savename, true, System.Text.Encoding.Default);

            sw.Write(sbCar.ToString());
            sw.Close();
        }