コード例 #1
0
ファイル: CMiddleLineList.cs プロジェクト: xuyanning/JQGis
        public static MGraph gMileageConnection; // 用于计算里程

        /// <summary>
        /// 由数据库或远程服务器读入三维中线的数据,这儿无效,在工具中使用,
        /// </summary>
        /// <param name="fileName"></param>
        //public static void CreateLinelistFromExcel(string dbPath)
        //{
        //    double[] m, x, y, z;
        //    double fromMeter, toMeter;
        //    //double fromX, toX, fromY, toY;
        //    int chainIndex;
        //    int chainType;
        //    string dkcode, dkcode2;
        //    //bool isRight = false;
        //    //bool isDouble = true;
        //    int count;

        //    DataTable dt1, dt2, dt3;

        //    //本地sqlite数据库读取里程数据
        //    //#if DEBUG
        //    //            Helper.LogHelper.WriteLog("SQlite Database" + dbPath);
        //    //#endif

        //    dt1 = ExcelWrapper.LoadDataTableFromExcel(dbPath, @"select chainIndex, fromMeter, toMeter,DKCode,DKCode2,chainType from [ChainInfo$] order by chainIndex");
        //    dt2 = ExcelWrapper.LoadDataTableFromExcel(dbPath, @"select fromChain, toChain from [ExtraConnection$] ");
        //    List<OneConnection> connectionList = new List<OneConnection>();
        //    foreach (DataRow dr in dt2.Rows)
        //    {
        //        OneConnection aCon = new OneConnection();
        //        aCon.fromIndex = Convert.ToInt32(dr["fromChain"]);
        //        aCon.toIndex = Convert.ToInt32(dr["toChain"]);
        //        //aCon.isRealConnect = Convert.ToInt32(dr["isConnect"])==0 ? true:false;
        //        //aCon.mileageOffset = Convert.ToDouble(dr["mileageOffset"]);
        //        connectionList.Add(aCon);
        //    }
        //    //int index = 0;

        //    foreach (DataRow dr in dt1.Rows)
        //    {
        //        chainIndex = Convert.ToInt32(dr["chainIndex"]);
        //        fromMeter = Convert.ToDouble(dr["fromMeter"]);
        //        toMeter = Convert.ToDouble(dr["toMeter"]);
        //        dkcode = (string)dr["DKCode"];
        //        dkcode2 = dr["DKCode2"].ToString();
        //        chainType = Convert.ToInt32(dr["chainType"]);
        //        //  isReverse = Convert.ToBoolean(dr["IsReverse"]);
        //        string strOrder = (fromMeter < toMeter) ? "" : " desc ";
        //        string tableName = "sheet" + chainIndex;
        //        dt3 = ExcelWrapper.LoadDataTableFromExcel(dbPath, @"select Mileage, Longitude,Latitude,Altitude from [" + tableName + "$] order by mileage " + strOrder);
        //        count = dt3.Rows.Count;
        //        if (count < 2) continue;

        //        m = new double[count];
        //        x = new double[count];
        //        y = new double[count];
        //        z = new double[count];
        //        //xMars = new double[count];
        //        //yMars = new double[count];
        //        int j = 0;
        //        foreach (DataRow dr2 in dt3.Rows)
        //        {

        //            m[j] = Math.Abs(Convert.ToDouble(dr2["Mileage"]) - fromMeter);
        //            x[j] = Convert.ToDouble(dr2["Longitude"]);
        //            y[j] = Convert.ToDouble(dr2["Latitude"]);
        //            z[j] = Convert.ToDouble(dr2["Altitude"]);
        //            j++;
        //            //xMars[j] = Convert.ToDouble(dr2["LongitudeMars"]);
        //            //yMars[j] = Convert.ToDouble(dr2["LatitudeMars"]);
        //        }
        //        mLineList.Add(new CRailwayLine(chainIndex, dkcode, dkcode2, fromMeter, toMeter, chainType, count, m, x, y, z));
        //    }


        //    gRealConnection = new MGraph();
        //    gMileageConnection = new MGraph();

        //    ShortestPathFloyd.initPathGraph(mLineList, gRealConnection, null);
        //    ShortestPathFloyd.initPathGraph(mLineList, gMileageConnection, connectionList);
        //}

        /// <summary>
        /// 由数据库或远程服务器读入三维中线的数据
        /// </summary>
        /// <param name="fileName"></param>
        public static void CreateLinelistFromSqlite(string dbPath)
        {
            double[] m, x, y, z;
            double   fromMeter, toMeter;
            //double fromX, toX, fromY, toY;
            int    chainIndex;
            int    chainType;
            string dkcode, dkcode2;
            //bool isRight = false;
            //bool isDouble = true;
            int count;

            DataTable dt1, dt2, dt3;

            //本地sqlite数据库读取里程数据
            //#if DEBUG
            //            Helper.LogHelper.WriteLog("SQlite Database" + dbPath);
            //#endif

            dt1 = DatabaseWrapper.ExecuteDataTable(dbPath, @"select chainIndex, fromMeter, toMeter,DKCode,DKCode2,chainType from ChainInfo order by chainIndex; ");
            dt2 = DatabaseWrapper.ExecuteDataTable(dbPath, @"select fromChain, toChain from ExtraConnection; ");

            //dt1 = ExcelWrapper.LoadDataTableFromExcel(dbPath, @"select chainIndex, fromMeter, toMeter,DKCode,DKCode2,chainType from [ChainInfo$] order by chainIndex");
            //dt2 = ExcelWrapper.LoadDataTableFromExcel(dbPath, @"select fromChain, toChain from [ExtraConnection$] ");
            List <OneConnection> connectionList = new List <OneConnection>();

            foreach (DataRow dr in dt2.Rows)
            {
                OneConnection aCon = new OneConnection();
                aCon.fromIndex = Convert.ToInt32(dr["fromChain"]);
                aCon.toIndex   = Convert.ToInt32(dr["toChain"]);
                //aCon.isRealConnect = Convert.ToInt32(dr["isConnect"])==0 ? true:false;
                //aCon.mileageOffset = Convert.ToDouble(dr["mileageOffset"]);
                connectionList.Add(aCon);
            }
            //int index = 0;

            foreach (DataRow dr in dt1.Rows)
            {
                chainIndex = Convert.ToInt32(dr["chainIndex"]);
                fromMeter  = Convert.ToDouble(dr["fromMeter"]);
                toMeter    = Convert.ToDouble(dr["toMeter"]);
                dkcode     = (string)dr["DKCode"];
                if (dr["DKCode2"] == null)
                {
                    dkcode2 = "";
                }
                else
                {
                    dkcode2 = dr["DKCode2"].ToString();
                }
                chainType = Convert.ToInt32(dr["chainType"]);
                //  isReverse = Convert.ToBoolean(dr["IsReverse"]);
                string strOrder = (fromMeter < toMeter) ? "" : " desc ";
                //string tableName = "sheet" + chainIndex;
                dt3   = DatabaseWrapper.ExecuteDataTable(dbPath, @"select Mileage, Longitude,Latitude,Altitude from MileageInfo where MileagePrefix=" + chainIndex + "  order by mileage " + strOrder);
                count = dt3.Rows.Count;
                if (count < 2)
                {
                    continue;
                }

                m = new double[count];
                x = new double[count];
                y = new double[count];
                z = new double[count];
                //xMars = new double[count];
                //yMars = new double[count];
                int j = 0;
                foreach (DataRow dr2 in dt3.Rows)
                {
                    m[j] = Math.Abs(Convert.ToDouble(dr2["Mileage"]) - fromMeter);
                    x[j] = Convert.ToDouble(dr2["Longitude"]);
                    y[j] = Convert.ToDouble(dr2["Latitude"]);
                    z[j] = Convert.ToDouble(dr2["Altitude"]);
                    j++;
                    //xMars[j] = Convert.ToDouble(dr2["LongitudeMars"]);
                    //yMars[j] = Convert.ToDouble(dr2["LatitudeMars"]);
                }
                mLineList.Add(new CRailwayLine(chainIndex, dkcode, dkcode2, fromMeter, toMeter, chainType, count, m, x, y, z));
            }

            gRealConnection    = new MGraph();
            gMileageConnection = new MGraph();

            ShortestPathFloyd.initPathGraph(mLineList, gRealConnection, null);
            ShortestPathFloyd.initPathGraph(mLineList, gMileageConnection, connectionList);
        }
コード例 #2
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();
        }
コード例 #3
0
ファイル: CMiddleLine.cs プロジェクト: liangyulin/railGis
        /// <summary>
        /// 由数据库或远程服务器读入三维中线的数据
        /// </summary>
        /// <param name="fileName"></param>
        public void LoadLineListFromDB()
        {
            double[] m, x, y, z;
            double   fromMeter, toMeter;
            int      fromID, toID;
            string   dkcode;
            int      count;

            System.Data.DataTable dt1, dt2;
            dt1 = dt2 = null;

            //System.Data.DataTable dt3;
            //double[] lgt, lat;
            //dt3 = ExcelWrapper.LoadDataTableFromExcel(@"D:\GISData\jiqing\中线测试.xlsx", "MiddleLine", @"select Mileage, Longitude, Latitude from [MiddleLine$];");
            //count = 93;
            //m = new double[count];
            //x = new double[count];
            //y = new double[count];
            //z = new double[count];

            //string dk = "DK";
            //double meter = 0;
            //double startm = 1800;
            //int ii = 0;
            //foreach (DataRow dr3 in dt3.Rows)
            //{
            //    //dr2 = dt2.Rows[i];
            //    parseDKCode(dr3["Mileage"].ToString(), out dk, out meter);
            //    m[ii] = meter - startm;
            //    x[ii] = Convert.ToDouble(dr3["Longitude"]);
            //    y[ii] = Convert.ToDouble(dr3["Latitude"]);
            //    ii++;
            //    //z[j] = Convert.ToDouble(dr3["Altitude"]);
            //}
            //CoordinateConverter.UTMXYToLatLonList(count,y,x,out lgt, out lat,50,false);
            ////UTM2GPS.GaussProjInvCal(y[0], x[0], out lgt[1], out lat[1]);
            //for (int i = 0; i < count; i++)
            //{
            //    Console.WriteLine("longi: {0}\t lati {1}", lgt[i], lat[i]);
            //}
            //Console.WriteLine();

            if (!CServerWrapper.isConnected)
            {
                string fileName = CGisDataSettings.gDataPath + @"jiqing\MiddleLine0525.xls";
                dt1 = DatabaseWrapper.LoadDataTableFromExcel(fileName, "Chain", @"select fromMeter, toMeter,fromID,toID,DKCode from [Chain$]; ");
                dt2 = DatabaseWrapper.LoadDataTableFromExcel(fileName, "MiddleLine", @"select Mileage, Longitude,Latitude,Altitude from [MiddleLine$]; ");
                ////dt1 = ds.Tables["Chain"];
                ////dt2 = ds2.Tables["MiddleLine"];
            }
            else
            {
                //  ProjectService.ProjectServiceSoapClient ws = new ProjectService.ProjectServiceSoapClient();

                //WS_GISServerData.GisDataWebServiceSoapClient ws = new WS_GISServerData.GisDataWebServiceSoapClient();
                //dt1 = ws.ws_FindChainInfo();
                //dt2 = ws.ws_FindMileageInfo();
//                    double mm = 100000;
//                    double mmin  ,xx,yy,zz;
//                    double mmax, xx2,yy2,zz2;
//                    double mx, my, mz;
//                    string dd = "DK";
//                    mmin = xx = yy = zz = 0; //Mileage, Longitude, Latitude, Altitude
//                    mx = my = mz = 0;
//                    System.Data.DataTable dt = CServerWrapper.execSqlQuery(@"SELECT   Mileage, Longitude, Latitude, Altitude
//FROM      MileageInfo
//WHERE   (MileagePrefix = '" +
//  dd + @"') AND ( Mileage > " + (mm - 500) + @" ) AND ( Mileage <" + (mm + 500) + @" ) ORDER BY Mileage");

//                    DatabaseWrapper.PrintDataTable(dt);
//                    bool isfind = false;
//                    foreach (DataRow dr in dt.Rows)
//                    {
//                        if (Convert.ToDouble(dr["Mileage"]) < mm)
//                        {
//                            mmin = Convert.ToDouble(dr["Mileage"]);
//                            xx = Convert.ToDouble(dr["Longitude"]);
//                            yy = Convert.ToDouble(dr["Latitude"]);
//                            zz = Convert.ToDouble(dr["Altitude"]);

//                        }
//                        else {
//                            isfind = true;
//                            mmax = Convert.ToDouble(dr["Mileage"]);
//                            xx2 = Convert.ToDouble(dr["Longitude"]);
//                            yy2 = Convert.ToDouble(dr["Latitude"]);
//                            zz2 = Convert.ToDouble(dr["Altitude"]);
//                            double a = (mm - mmin) / (mmax - mmin);
//                            mx = xx + (xx2 - xx) * a;
//                            my = yy + (yy2 - yy) * a;
//                            mz = zz + (zz2 - zz) * a;

//                        }
//                    }
//                    Console.WriteLine(mx + "\t" + my + "\t" +mz + "\t"+ isfind);

                dt1 = CServerWrapper.findChainInfo();
                dt2 = CServerWrapper.findMileageInfo();
                //dt1 = ProjectFromServer.FindChainInfo();
                //dt2 = ProjectFromServer.FindMileageInfo();
            }


            DataRow dr2;

            foreach (DataRow dr in dt1.Rows)
            {
                fromMeter = (double)dr["fromMeter"];
                toMeter   = (double)dr["toMeter"];
                if (!CServerWrapper.isConnected)
                {
                    fromID = (int)((double)dr["fromID"] + 0.1);
                    toID   = (int)((double)dr["toID"] + 0.1);
                }
                else
                {
                    fromID = (int)dr["fromID"];
                    toID   = (int)dr["toID"];
                }
                dkcode = (string)dr["DKCode"];
                count  = toID - fromID + 1;

                if (count < 2)
                {
                    continue;
                }

                m = new double[count];
                x = new double[count];
                y = new double[count];
                z = new double[count];
                int j = 0;
                for (int i = fromID - 1; i < toID; i++, j++)
                {
                    dr2  = dt2.Rows[i];
                    m[j] = Math.Abs((double)dr2["Mileage"] - fromMeter);
                    x[j] = Convert.ToDouble(dr2["Longitude"]);
                    y[j] = Convert.ToDouble(dr2["Latitude"]);
                    z[j] = Convert.ToDouble(dr2["Altitude"]);
                }
                mLineList.Add(new CRailwayLine(dkcode, fromMeter, toMeter, false, count, m, x, y, z));
            }
        }