예제 #1
0
        /// <summary>
        /// 按照工点聚类,单位工程显示第一个
        /// </summary>
        /// <returns></returns>
        public static List <ConsLocation> clusterConsFromWebByProj(string fromDate = null, string toDate = null)
        {
            List <ConsLocation> ls = new List <ConsLocation>();
            double cx, cy;

            //string fromD = DateTime.Now.AddDays(-7).ToShortDateString();
            //string toD = DateTime.Now.ToShortDateString();

            //dt2.Columns.Add("ProjectName", typeof(string));
            //dt2.Columns.Add("DwName", typeof(string));
            //dt2.Columns.Add("Longitude", typeof(double));
            //dt2.Columns.Add("Latitude", typeof(double));
            //dt2.Columns.Add("StaffNum", typeof(int));
            // 2016-05-06 00:00:00Z
            //DataTable dt = CServerWrapper.findClusterConsByPDW(DateTime.Now.AddDays(-7).Date.ToString("u"));
            //DataTable dt = CServerWrapper.findClusterConsByPDW(fromDate, toDate);
            DataTable dt = CServerWrapper.findClusterConsByProj(fromDate, toDate);

            foreach (DataRow dr in dt.Rows)
            {
                GPSAdjust.bd_decrypt(Convert.ToDouble(dr["Latitude"]), Convert.ToDouble(dr["Longitude"]), out cy, out cx);
                ls.Add(new ConsLocation(dr["ProjectName"].ToString(), dr["DwName"].ToString(), cx, cy,
                                        fromDate.Substring(0, 11), toDate.Substring(0, 11), Convert.ToInt32(dr["StaffNum"])));
                //            ls.Add(new ConsLocation(dr["ProjectName"].ToString(), dr["DwName"].ToString(), Convert.ToDouble(dr["Longitude"]), Convert.ToDouble(dr["Latitude"]),
                //fromDate.Substring(0, 11), toDate.Substring(0, 11), Convert.ToInt32(dr["StaffNum"])));
            }

            return(ls);

            //new StaticCluster().clusterProcess();
        }
예제 #2
0
        /// <summary>
        /// 工具方法,批量根据wgs84坐标生成火星坐标,时间非常长
        /// </summary>
        /// <param name="dbPath"></param>
        public static void UpdateMileageMars(string dbPath)
        {
            string sqlselect = "select * from MileageInfo where longitudeMars is null ";
            string sqlUpdate = @"update MileageInfo set LongitudeMars = @longMars, LatitudeMars = @latMars where MileageID = @mID;  ";

            System.Data.DataTable dt = ExecuteDataTable(dbPath, sqlselect);
            using (SQLiteConnection connection = new SQLiteConnection("Data Source=" + dbPath))
            {
                connection.Open();
                using (SQLiteTransaction transaction = connection.BeginTransaction())
                {
                    using (SQLiteCommand command = new SQLiteCommand(connection))
                    {
                        command.CommandText = sqlUpdate;
                        double longMars, latMars;
                        foreach (DataRow dr in dt.Rows)
                        {
                            GPSAdjust.transform2Mars(Convert.ToDouble(dr["Latitude"]), Convert.ToDouble(dr["Longitude"]),
                                                     out latMars, out longMars);
                            SQLiteParameter[] parameters = new SQLiteParameter[]
                            {
                                new SQLiteParameter("@longMars", longMars),
                                new SQLiteParameter("@latMars", latMars),
                                new SQLiteParameter("@mID", Convert.ToInt32(dr["MileageID"])),
                            };
                            command.Parameters.AddRange(parameters);
                            command.ExecuteNonQuery();
                            //command.ExecuteReader()
                        }
                    }
                    transaction.Commit();
                }
            }
        }
예제 #3
0
파일: CConsLog.cs 프로젝트: xuyanning/JQGis
        /// <summary>
        /// 按照工点聚类,单位工程显示第一个
        /// </summary>
        /// <returns></returns>
        public static void clusterConsFromWebByProj(CRailwayScene s, string dbFile, List <ConsLocation> ls, List <CHotSpot> ls2, string fromDate = null, string toDate = null, bool fromLocal = true)
        {
            double cx, cy;
            double tx, ty, tz, td;

            CRailwayLine rl;
            double       mileage, dis, gm;
            bool         isInside;

            //string fromD = DateTime.Now.AddDays(-7).ToShortDateString();
            //string toD = DateTime.Now.ToShortDateString();

            //dt2.Columns.Add("ProjectName", typeof(string));
            //dt2.Columns.Add("DwName", typeof(string));
            //dt2.Columns.Add("Longitude", typeof(double));
            //dt2.Columns.Add("Latitude", typeof(double));
            //dt2.Columns.Add("StaffNum", typeof(int));
            // 2016-05-06 00:00:00Z
            //DataTable dt = CServerWrapper.findClusterConsByPDW(DateTime.Now.AddDays(-7).Date.ToString("u"));
            //DataTable dt = CServerWrapper.findClusterConsByPDW(fromDate, toDate);
            if (ls == null)
            {
                ls = new List <ConsLocation>();
            }
            else
            {
                ls.Clear();
            }

            if (ls2 == null)
            {
                ls2 = new List <CHotSpot>();
            }
            else
            {
                ls2.Clear();
            }

            DataTable dt = null;

            if (fromLocal)
            {
                string localPath = dbFile;
                dt = DatabaseWrapper.ExecuteDataTable(dbFile, @"SELECT * from ConsInfo ;");
            }
            else if (CServerWrapper.isConnected)
            {
                dt = CServerWrapper.findClusterConsByProj(fromDate, toDate);
            }

            if (dt == null)
            {
                return;
            }

            foreach (DataRow dr in dt.Rows)
            {
                GPSAdjust.bd_decrypt(Convert.ToDouble(dr["Latitude"]), Convert.ToDouble(dr["Longitude"]), out cy, out cx);

                rl = CRailwayLineList.getMileagebyGPS(Convert.ToDouble(dr["Longitude"]), Convert.ToDouble(dr["Latitude"]), out mileage, out dis, out isInside);
                CRailwayLineList.getGPSbyDKCode(rl.mDKCode, mileage, out tx, out ty, out tz, out td);
                s.mMainPath.getPathMileageByDKCode(rl.mDKCode, mileage, out gm, out dis);
                //FIXME xyn 加入两次,比较实际坐标和火星坐标的差别
                //ConsLocation cl = new ConsLocation("Mars" + dr["ProjectName"].ToString(), dr["DwName"].ToString(), Convert.ToDouble(dr["Longitude"]), Convert.ToDouble(dr["Latitude"]), //tx, ty,
                //    fromDate.Substring(0, 11), toDate.Substring(0, 11), Convert.ToInt32(dr["StaffNum"]));
                //ls.Add(cl);
                ConsLocation cl = new ConsLocation(dr["ProjectName"].ToString(), dr["DwName"].ToString(), cx, cy, //Convert.ToDouble(dr["Longitude"]), Convert.ToDouble(dr["Latitude"]),
                                                   fromDate, toDate, Convert.ToInt32(dr["StaffNum"]));
                ls.Add(cl);


                ls2.Add(new CHotSpot(rl.mDKCode, mileage, tx, ty, tz, gm, dis, "Cons", cl));
                //            ls.Add(new ConsLocation(dr["ProjectName"].ToString(), dr["DwName"].ToString(), Convert.ToDouble(dr["Longitude"]), Convert.ToDouble(dr["Latitude"]),
                //fromDate.Substring(0, 11), toDate.Substring(0, 11), Convert.ToInt32(dr["StaffNum"])));
            }

            //new StaticCluster().clusterProcess();
        }