Beispiel #1
0
        public CRailwayFirm(CRailwayScene s, int num, int fid, string fname, double x, double y, string firmType, string presentation, string fileName)
        {
            mScene    = s;
            mFirmType = firmType;
            mFirmName = fname;

            mNumStaff = num;
            mFirmID   = fid;
            //mSNo = sNo;
            //mUpdateTime = dt;
            mPresentation  = presentation;
            mLongitude_Mid = x;
            mLatitude_Mid  = y;

            //if (fname.StartsWith("11标"))
            //    Console.WriteLine(fname + x + "\t" + y);
            mLine = CRailwayLineList.getMileagebyGPS(x, y, out mMileage_Mid, out mDis, out misInside);
            //mDKCode = mLine.mDKCode;
            double dis;

            mScene.mMainPath.getPathMileagebyGPS(x, y, out mMainMileage, out dis);

            mLabelImage = fileName;
            if (mDis < 8000)
            {
                mHotSpot = new CHotSpot(mLine.mDKCode, mMileage_Mid, mLongitude_Mid, mLatitude_Mid, 100, mMainMileage, mDis, "Firm", this);
            }
            else
            {
                mHotSpot = null;
            }
        }
Beispiel #2
0
 public PathNode(CRailwayLine rl, double fromM, double toM, bool re)
 {
     mRL         = rl;
     fromMileage = fromM;
     toMileage   = toM;
     isReverse   = re;
     mLength     = Math.Abs(fromM - toM);
 }
Beispiel #3
0
        ///// <summary>
        ///// 获取最小len
        ///// </summary>
        //public double getMinLen(double len_start, double len_mid, double len_end)
        //{
        //    double len = Math.Min(Math.Min(len_start, len_mid), len_end);
        //    return len;

        //}

        ///// <summary>
        ///// 根据dk码以及里程,例如DIK12+23.4,获取经纬度高度、朝向坐标
        ///// </summary>
        ///// <param name="dk"></param>
        ///// <param name="meter"></param>
        ///// <param name="x"></param>
        ///// <param name="y"></param>
        ///// <param name="z"></param>
        ///// <param name="dir"></param>
        ///// <returns></returns>
        //public bool getGPSAndGlobalMileageByDKCode(string dk, double meter, out double x, out double y, out double z, out double dir, out double globalmeter)
        //{
        //    x = y = z = dir = 0;
        //    double dis;
        //    globalmeter = 0;
        //    foreach (CRailwayLine rw in mLineList)
        //    {
        //        if (rw.isInSide(dk, meter, out dis))
        //        {
        //            rw.getGPSbyMileage(meter, out x, out y, out z, out dir);
        //            globalmeter += dis;
        //            return true;

        //        }
        //        globalmeter += rw.mLength;
        //    }
        //    //Console.WriteLine(dk + " " + meter + "is not valid !");
        //    return false;
        //}



        /// <summary>
        /// 根据经纬度,获取里程,如果经纬度不在铁路线上,定位铁路线上最近的一个点,返回该段铁路、该点里程以及距离
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="dis"></param>
        /// <returns></returns>
        public static CRailwayLine getMileagebyGPS(double x, double y, out double mileage, out double dis, out bool isInside)
        {
            dis = -1;
            //double mi;
            mileage = -1;
            double       mi;
            double       min = 100;
            CRailwayLine mrw = null;

            isInside = false;
            //bool isInside2;
            foreach (CRailwayLine rw in mLineList)
            {
                rw.getDKMileagebyGPS(x, y, out mi, out dis);

                if (mrw == null)
                {
                    min     = dis;
                    mileage = mi;
                    mrw     = rw;
                    //isInside = isInside2;
                }
                else if (dis < min)
                {
                    min     = dis;
                    mileage = mi;
                    mrw     = rw;
                    //isInside = isInside2;
                }
                //if (isInside2 && dis < 10)
                //    break;
            }
            dis = min;
            //mileage
            return(mrw);
        }
Beispiel #4
0
        /// <summary>
        /// 生成子路径
        /// </summary>
        /// <param name="g">寻径的floyd图</param>
        /// <param name="DKlist">路径上的dkcode列表,至少2个</param>
        /// <param name="milelist">路径上的里程列表,至少2个</param>
        /// <param name="stepm">细分里程间隔</param>
        private void CreateSubPathFromNodeList(MGraph g, List <string> DKlist, List <double> milelist, double stepm)
        {
            if (DKlist == null || DKlist.Count < 2)
            {
                return;
            }
            mFromDK      = DKlist.First();
            mToDK        = DKlist.Last();
            mFromMileage = milelist.First();
            mToMileage   = milelist.Last();
            mStepM       = stepm;
            mLength      = 0;
            List <PathNode> ls = new List <PathNode>();
            // 路径节点,0,2,4,6下标为链路编号,1,3,5,7等标注正序还是逆序,0-正序,1-逆序
            List <int>   idls = null;
            CRailwayLine tmpLine;

            //存放所有路径上的链路编号
            int[] rlls = new int[DKlist.Count];

            for (int i = 0; i < DKlist.Count; i++)
            {
                tmpLine = CRailwayLineList.getRailwayLineByDKCode(DKlist[i], milelist[i]);
                if (tmpLine == null)
                {
                    return;
                }
                rlls[i] = tmpLine.mIndex;
            }


            // 路径节点,0,2,4,6下标为路径编号,1,3,5,7等标注正序还是逆序,0-正序,1-逆序
            idls = ShortestPathFloyd.getNavPath(rlls, g);
            if (idls == null)
            {
                Console.WriteLine(DKlist[0] + "等路径不存在");
                return;
            }
            if (DKlist.Count == 2 && rlls[0] == rlls[1])  // 起点和终点在同一个链路中
            {
                CRailwayLine rl = CRailwayLineList.getRailwayLineByIndex(idls[0]);
                mLength = Math.Abs(milelist[0] - milelist.Last());
                //if (idls[1] == 0)
                ls.Add(new PathNode(rl, milelist[0], milelist.Last(), false));
                //else
                //    ls.Add(new PathNode(rl, milelist.Last(), milelist[0], true));
            }
            else if (idls.Count > 2)
            {
                mLength     = 0;
                mNodeLength = new double[idls.Count / 2];
                // path中的第一条链
                CRailwayLine rl = CRailwayLineList.getRailwayLineByIndex(idls[0]);
                if (idls[1] == 0)
                {
                    ls.Add(new PathNode(rl, milelist[0], rl.mEnd, false));
                    mLength += Math.Abs(milelist[0] - rl.mEnd);
                }
                else
                {
                    ls.Add(new PathNode(rl, milelist[0], rl.mStart, true));
                    mLength += Math.Abs(milelist[0] - rl.mStart);
                }
                mNodeLength[0] = mLength;
                if (idls.Count > 2)
                {
                    // path的中间链
                    for (int i = 1; i < idls.Count / 2 - 1; i++)
                    {
                        rl = CRailwayLineList.getRailwayLineByIndex(idls[2 * i]);
                        if (idls[2 * i + 1] == 0)
                        {
                            ls.Add(new PathNode(rl, rl.mStart, rl.mEnd, false));
                        }
                        else
                        {
                            ls.Add(new PathNode(rl, rl.mEnd, rl.mStart, true));
                        }
                        mLength       += Math.Abs(rl.mLength);
                        mNodeLength[i] = mLength;
                    }

                    // path的最后一条链
                    rl = CRailwayLineList.getRailwayLineByIndex(idls[idls.Count - 2]);
                    if (idls.Last() == 0)
                    {
                        ls.Add(new PathNode(rl, rl.mStart, milelist.Last(), false));
                        mLength += Math.Abs(rl.mStart - milelist.Last());
                    }
                    else
                    {
                        ls.Add(new PathNode(rl, rl.mEnd, milelist.Last(), true));
                        mLength += Math.Abs(rl.mEnd - milelist.Last());
                    }
                    mNodeLength[mNodeLength.Length - 1] = mLength;
                }
            }

            mPathNodeList = ls;

            hasPath = mPathNodeList.Count > 0 && mLength > 1;

            if (hasPath)
            {
                createSubLine();
            }
        }