Пример #1
0
 /// <summary>
 /// 获取第二条线路的一部分,复线-中线。单线-线杆
 /// </summary>
 /// <param name="startm"></param>
 /// <param name="endm"></param>
 /// <param name="stepm"></param>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <param name="includeLastPoint"></param>
 /// <returns></returns>
 public int getSubLine2ByDKMileage(double startm, double endm, double stepm, out double[] x, out double[] y, bool includeLastPoint = false)
 {
     double[] z, d, m;
     getLocalMileageByDKMileage(this.mDKCode, startm, out startm);
     getLocalMileageByDKMileage(this.mDKCode, endm, out endm);
     return(CSubLine.getSubLineByMileage(startm, endm, stepm, meter, mOffsetX, mOffsetY, altitude, heading, out m, out x, out y, out z, out d, includeLastPoint));
 }
Пример #2
0
 public int getOffsetLineByDKMileage(double startm, double endm, double stepm, double offsetm, out double[] mileage, out double[] x, out double[] y, out double[] z, out double[] dir, bool includeLastPoint = false)
 {
     getLocalMileageByDKMileage(mDKCode, startm, out startm);
     getLocalMileageByDKMileage(mDKCode, endm, out endm);
     return(CSubLine.getOffsetLineByMileage(startm, endm, stepm, meter, longitude, latitude, altitude, heading, mOffset, mOffsetX, mOffsetY, offsetm,
                                            out mileage, out x, out y, out z, out dir, includeLastPoint));
 }
Пример #3
0
        /// <summary>
        /// 获取中线,根据 pathNode 0判断单线复线,
        /// </summary>
        /// <param name="ml"></param>
        /// <param name="xl"></param>
        /// <param name="yl"></param>
        /// <param name="zl"></param>
        /// <param name="dl"></param>
        /// <returns></returns>
        public bool getContactLine(out double[] x, out double[] y, out double[] z,
                                   out double[] x2, out double[] y2, out double[] z2)
        {
            double[] m, m2, dir, dir2;
            m  = x = y = z = dir = null;
            m2 = x2 = y2 = z2 = dir2 = null;

            List <PathNode> ls = mPathNodeList; //getSubPath(startDKCode, startMileage, endDKCode, endMileage);

            if (ls == null || ls.Count == 0)
            {
                return(false);
            }
            //int totalCount = 0;
            // 如果是单线,接触网为中线,如果是复线,接触网为左线
            CSubLine.getSubLineByMileage(0, mLength, 50, mm, mx, my, mz, md, out m, out x, out y, out z, out dir);
            if (ls[0].mRL.mIsDouble)
            {
                // 复线,求另一个接触网
                CSubLine.getOffsetLineByMileage(0, mLength, 50, mm, mx, my, mz, md, moff, mxoff, myoff, moff * 2, out m2, out x2, out y2, out z2, out dir2, true);
                return(true);
            }

            //CSubLine.getSubLineByMileage(0, mLength, mStepM, mm, mx, my, mz, md, out ml, out xl, out yl, out zl, out dl, true);
            return(false);
        }
Пример #4
0
        //public void getSubLineFromDKCode(string dkcode, double mileage, double dis, out double[] x, out double[] y, out double[] z, out double[] dir)
        //{
        //    x = y = z = dir = null;
        //    double m = getPathMileageByDKCode(dkcode, mileage) ;
        //    double m1, m2;
        //    if (dis > 0)
        //    {
        //        m1 = m;
        //        m2 = m + dis;
        //    }else
        //    {
        //        m1 = m + dis;
        //        m2 = m;
        //    }
        //    int fromIdx = getMileageIndex(m1);
        //    int toIdx = getMileageIndex(m2);

        //}

        //int getMileageIndex(double mileage)
        //{
        //    if (mileage < 0 || mileage > mLength)
        //        return -1;
        //    int l = 0, r = mm.Length - 1;
        //    int mid = (l + r) / 2;
        //    while (l < r)
        //    {
        //        if (mileage < mm[mid])
        //            r = mid - 1;
        //        else if (mileage > mm[mid])
        //            l = mid + 1;
        //        else
        //            return mid;
        //        mid = (l + r) / 2;
        //    }
        //    r = Math.Max(r, 0);
        //    l = Math.Min(l, mm.Length-1);
        //    return Math.Abs(mm[r] - mileage) < Math.Abs(mm[l] - mileage) ? r :l ;


        //}


        ///// <summary>
        ///// 计算偏移一定角度和距离之后的经纬度
        ///// </summary>
        ///// <param name="startDKM"></param>
        ///// <param name="endDKM"></param>
        ///// <param name="stepm"></param>
        ///// <param name="angleOff"></param>
        ///// <param name="disOff"></param>
        ///// <param name="latout"></param>
        ///// <param name="lonout"></param>
        ///// <param name="z"></param>
        ///// <returns></returns>
        //public int getOffsetLine(double angleOff, double disOff, out double[] latout, out double[] lonout, out double[] z)
        //{
        //    lonout = latout = z = null;
        //    //double[] x = null;
        //    //double[] y = null;
        //    ////double[] z = null;
        //    //double[] d = null;

        //    //int pointNum = getSubLineByDKCode(startDKM, endDKM, stepm, out x, out y, out z, out d);
        //    if (mPointCount > 0)
        //    {
        //        latout = new double[mPointCount];
        //        lonout = new double[mPointCount];
        //        for (int i = 0; i < mPointCount; i++)
        //        {
        //            CoordinateConverter.LatLonOffest(my[i], mx[i], md[i], angleOff, disOff, out latout[i], out lonout[i]);  //lat, lon
        //        }
        //        z = mz;

        //    }

        //    return mPointCount;
        //}


        ///// <summary>
        ///// 求点与多条线段的最短距离,如果投影在多条线段内,返回t,否则f
        ///// </summary>
        ///// <param name="x">点</param>
        ///// <param name="y">点</param>
        ///// <param name="xa">多线段</param>
        ///// <param name="ya"></param>
        ///// <param name="ma"></param>
        ///// <param name="fromid">多线段起点下标</param>
        ///// <param name="toid">终点下标</param>
        ///// <param name="m">最近点</param>
        ///// <param name="dis">距离</param>
        ///// <returns></returns>
        //private bool getDistance(double x, double y, double[]xa, double[] ya, double[] ma ,int fromid, int toid, out double m, out double dis)
        //{
        //    bool found = false;
        //    m = dis = 0;
        //    double lx = xa[fromid];
        //    double ly = ya[fromid];
        //    double rx = xa[toid];
        //    double ry = ya[toid];
        //    if ((x - lx) * (rx - lx) + (y - ly) * (ry - ly) < 0)
        //    {
        //        m = ma[fromid];
        //        dis = CoordinateConverter.getUTMDistance(x, y, lx, ly);
        //    }
        //    else if ((x - rx)*(lx - rx) + (y - ry) * (ly - ry) < 0)
        //    {
        //        m = ma[toid];
        //        dis = CoordinateConverter.getUTMDistance(x, y, rx, ry);
        //    }
        //    else
        //    {
        //        found = true;
        //        int minid = fromid;
        //        dis = CoordinateConverter.getUTMDistance(x, y, lx, ly);
        //        for (int i = fromid + 1; i<= toid; i++)
        //        {
        //            double di = CoordinateConverter.getUTMDistance(x, y, xa[i], ya[i]);
        //            if (di < dis) {
        //                dis = di;
        //                minid = i;
        //            }
        //        }
        //        int lid = minid - 1;
        //        if (lid < fromid) lid = fromid;
        //        int rid = minid + 1;
        //        if (rid > toid) rid = toid;
        //        double d1 = CoordinateConverter.getUTMDistance(x, y, xa[lid], ya[lid]);
        //        double d2 = CoordinateConverter.getUTMDistance(x, y, xa[rid], ya[rid]);

        //        double ddd =d1 /(d1 + d2);
        //        //if (d1 > d2)
        //        //{
        //        //    ddd = disInterpolate(x, y, xa[lid], ya[lid], xa[rid], ya[rid]);
        //        //}
        //        //else
        //        //{
        //        //    ddd = 1 - disInterpolate(x,y,xa[rid],ya[rid],xa[lid],ya[lid]);
        //        //}
        //        m = ma[lid] + (ma[rid]-ma[lid])  * ddd;
        //        double xm = xa[lid] + (xa[rid]-xa[lid])  *ddd;
        //        double ym = ya[lid] + (ya[rid] - ya[lid]) * ddd;
        //        dis = CoordinateConverter.getUTMDistance(x, y, xm, ym);
        //    }
        //    return found;
        //}

        ///误差太大
        //private double disInterpolate(double x1,double y1,double x2,double y2,double x3,double y3)
        //{
        //    double dx1 = x1 - x2;
        //    double dy1 = y1 - y2;
        //    double dx2 = x3 - x2;
        //    double dy2 = y3 - y2;
        //    double len1 = Math.Sqrt(dx1 * dx1 + dy1 * dy1);
        //    double len2 = Math.Sqrt(dx2 * dx2 + dy2 * dy2);
        //    double cosa = (dx1 * dx2 + dy1 * dy2) / len1 / len2;
        //    double d = len1 * Math.Sqrt (1 - cosa * cosa);
        //    return d / len2;
        //}
        /// <summary>
        /// 给定经纬度,输出最近点里程与距离
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="mileage"></param>
        /// <param name="distance"></param>
        public void getPathMileagebyGPS(double x, double y, out double mileage, out double distance)
        {
            distance = 5000000;
            mileage  = -1;
            if (!hasPath)
            {
                return;
            }
            //double m, d;

            //int step = Math.Max(100, (int)Math.Sqrt(mPointCount));
            //int toid = 0;

            //for (int i = 0; i<mPointCount; i+= step)
            //{
            //    toid = Math.Min(i + step , mPointCount - 1);
            //    getDistance(x, y, mx, my, mm, i, toid, out m, out d);
            //    if (d<distance)
            //    {
            //        distance = d;
            //        mileage = m;
            //    }
            //}

            CSubLine.getMileagebyGPS(x, y, mm, mx, my, out mileage, out distance);
        }
Пример #5
0
 private void createHeightSegment(int typeSeg, int id, double length, double fromM, out double[] mSeg, out double[] hSeg, bool includeLastP = true)
 {
     if (typeSeg == 0) // 前直线
     {
         mSeg = CSubLine.generateSamplePoints(length, 50, fromM, includeLastP);
     }
     else // 圆曲线
     {
         mSeg = CSubLine.generateSamplePoints(length, 10, fromM, includeLastP);
     }
     if (mSeg == null)
     {
         hSeg = null;
         return;
     }
     hSeg = new double[mSeg.Length];
     for (int i = 0; i < mSeg.Length; i++)
     {
         if (typeSeg == 0)
         {
             hSeg[i] = h[id] + (mSeg[i] - m[id]) * i1[id];
         }
         else
         {
             hSeg[i] = h[id] + (sm[id] - m[id]) * i1[id] + (mSeg[i] - sm[id]) * i1[id]
                       + Math.Sign(i2[id] - i1[id]) * (mSeg[i] - sm[id]) * (mSeg[i] - sm[id]) / r[id] / 2;
         }
     }
 }
Пример #6
0
        // 给定里程,计算经纬度朝向坐标
        public bool getGPSbyDKMileage(double m, out double x, out double y, out double z, out double dir, out double pitch)
        {
            double dis    = 0;
            bool   isFind = getLocalMileageByDKMileage(mDKCode, m, out dis);

            CSubLine.getGPSbyMileage(dis, meter, longitude, latitude, altitude, heading, out x, out y, out z, out dir, out pitch);
            return(isFind);
        }
Пример #7
0
        // 给定里程,计算经纬度朝向坐标
        private bool getGPSbyPathMileage(double m, out double x, out double y, out double z, out double dir, out double pitch)
        {
            return(CSubLine.getGPSbyMileage(m, mm, mx, my, mz, md, out x, out y, out z, out dir, out pitch));
            //bool flag = true;
            //int index;
            //x = y = z = 0; dir = 0;

            //if (m < 0.001)
            //{
            //    flag = false;
            //    index = 0;
            //    //x = mx[0];
            //    //y = my[0];
            //    //z = mz[0];
            //    //if (md != null)
            //    //    dir = md[0];
            //}
            //else if (m > mLength - 0.001)
            //{
            //    flag = false;
            //    index = mPointCount - 2;
            //    //x = mx[mPointCount - 1];
            //    //y = my[mPointCount - 1];
            //    //z = mz[mPointCount - 1];
            //    //if (md != null)
            //    //    dir = md[mPointCount - 1];
            //}
            //else
            //{
            //    flag = true;
            //    index = (int)(m / mStepM);


            //    if (index == mPointCount - 1)
            //    {
            //        index--;
            //        //x = mx[index];
            //        //y = my[index];
            //        //z = mz[index];
            //        //if (md != null)
            //        //    dir = md[index];
            //    }
            //}

            //// Important FIX,前面方法对于距离小于10米的最后一段计算错误
            //double t = (m - mm[index]) / (mm[index + 1] - mm[index]);
            //x = mx[index] * (1 - t) + mx[index + 1] * t;
            //y = my[index] * (1 - t) + my[index + 1] * t;
            //z = mz[index] * (1 - t) + mz[index + 1] * t;
            //if (md != null)
            //    dir = md[index] * (1 - t) + md[index + 1] * t;

            //return flag;
        }
Пример #8
0
        /// <summary>
        /// 如果复线,返回两条接触网线,如果单线,返回一条
        /// </summary>
        /// <param name="m"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="z"></param>
        /// <param name="dir"></param>
        /// <param name="m2"></param>
        /// <param name="x2"></param>
        /// <param name="y2"></param>
        /// <param name="z2"></param>
        /// <param name="dir2"></param>
        /// <returns></returns>
        public bool getContactLineByMileage(out double[] m, out double[] x, out double[] y, out double[] z, out double[] dir,
                                            out double[] m2, out double[] x2, out double[] y2, out double[] z2, out double[] dir2)
        {
            m  = x = y = z = dir = null;
            m2 = x2 = y2 = z2 = dir2 = null;
            CSubLine.getSubLineByMileage(0, Math.Abs(mEnd - mStart), 50, meter, longitude, latitude, altitude, heading, out m, out x, out y, out z, out dir);

            if (mIsDouble)
            {
                CSubLine.getOffsetLineByMileage(0, Math.Abs(mEnd - mStart), 50, meter, longitude, latitude, altitude, heading, mOffset, mOffsetX, mOffsetY, mOffset * 2,
                                                out m2, out x2, out y2, out z2, out dir2, false);
            }

            return(mIsDouble);
        }
Пример #9
0
        /// <summary>
        /// 重采样,根据起始里程,获取距离为dis的子路径
        /// </summary>
        /// <param name="fromdkcode"></param>
        /// <param name="frommileage"></param>
        /// <param name="dis"></param>
        /// <param name="stepm"></param>
        /// <param name="mils"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="z"></param>
        /// <param name="dir"></param>
        /// <returns></returns>
        public int getSubLineByDKCode(string fromdkcode, double frommileage, double dis, double stepm, out double[] mils, out double[] x, out double[] y, out double[] z, out double[] dir)
        {
            mils = x = y = z = dir = null;
            double m = getPathMileageByDKCode(fromdkcode, frommileage);

            return(CSubLine.getSubLineByMileage(m, m + dis, stepm, mm, mx, my, mz, md, out mils, out x, out y, out z, out dir));
            //double m1, m2;
            //if (dis > 0)
            //{
            //    m1 = m;
            //    m2 = m + dis;
            //}
            //else
            //{
            //    m1 = m + dis;
            //    m2 = m;
            //}
            //m1 = Math.Max(m1, 0);
            //m2 = Math.Min(m2, mLength);

            //dis = m2 - m1;
            ////double dir;
            //stepm = Math.Min(1,Math.Abs(stepm));

            //int count = (int)((dis - 0.05) / stepm) + 1;
            //// 保证count至少为2
            //if (dis < stepm * 2)
            //    count = 2;

            //mils = new double[count];
            //x = new double[count];
            //y = new double[count];
            //z = new double[count];
            //dir = new double[count];
            //double temp;

            //m = m1;
            //for (int i = 0; i < count - 1; i++)
            //{
            //    mils[i] = m;
            //    getGPSbyPathMileage(m, out x[i], out y[i], out z[i], out dir[i],out temp);
            //    m += stepm;
            //}
            //mils[count - 1] = m2;
            //getGPSbyPathMileage(m2, out x[count - 1], out y[count - 1], out z[count - 1], out dir[count - 1],out temp);

            //return count;
        }
Пример #10
0
        public int getMiddleLineByDKMileage(double startm, double endm, double stepm, out double[] mileage, out double[] x, out double[] y, out double[] z, out double[] dir, bool includeLastPoint = false)
        {
            getLocalMileageByDKMileage(this.mDKCode, startm, out startm);
            getLocalMileageByDKMileage(this.mDKCode, endm, out endm);

            if (mIsDouble)
            {
                return(CSubLine.getSubLineByMileage(startm, endm, stepm, meter, mOffsetX, mOffsetY, altitude, heading, out mileage, out x, out y, out z, out dir, includeLastPoint));
            }
            else
            {
                return(CSubLine.getSubLineByMileage(startm, endm, stepm, meter, longitude, latitude, altitude, heading, out mileage, out x, out y, out z, out dir, includeLastPoint));
            }
            //z = altitude;
            //dir = heading;
        }
Пример #11
0
 public void getPolePos(out double[] x, out double[] y, out double[] z, out double[] dir)
 {
     //double dis = 0;
     double[] m;
     m = x = y = z = dir = null;
     if (meter == null || meter.Length == 0)
     {
         return;
     }
     //x = new double[m.Length];
     //y = new double[m.Length];
     //z = new double[m.Length];
     if (mIsDouble)
     {
         CSubLine.getOffsetLineByMileage(0, Math.Abs(mEnd - mStart), 50, meter, longitude, latitude, altitude, heading, mOffset, mOffsetX, mOffsetY, mOffset * 2,
                                         out m, out x, out y, out z, out dir, false);
     }
 }
Пример #12
0
        public bool getPierPosbyDKMileage(double m, out double x, out double y, out double z, out double dir, out double pitch)
        {
            double dis = 0;

            x = y = z = dir = pitch = 0;
            bool isFind = getLocalMileageByDKMileage(mDKCode, m, out dis);

            if (isFind)
            {
                if (mIsDouble)
                {
                    CSubLine.getGPSbyMileage(dis, meter, mOffsetX, mOffsetY, altitude, heading, out x, out y, out z, out dir, out pitch);
                }
                else
                {
                    CSubLine.getGPSbyMileage(dis, meter, longitude, latitude, altitude, heading, out x, out y, out z, out dir, out pitch);
                }
            }
            return(isFind);
        }
Пример #13
0
        /// <summary>
        /// 获取中线,根据 pathNode 0判断单线复线,
        /// </summary>
        /// <param name="ml"></param>
        /// <param name="xl"></param>
        /// <param name="yl"></param>
        /// <param name="zl"></param>
        /// <param name="dl"></param>
        /// <returns></returns>
        public bool getMiddleLine(out double[] ml, out double[] xl, out double[] yl, out double[] zl, out double[] dl)
        {
            //bool isDoubleLine = false;
            xl = yl = zl = dl = ml = null;

            List <PathNode> ls = mPathNodeList; //getSubPath(startDKCode, startMileage, endDKCode, endMileage);

            if (ls == null || ls.Count == 0)
            {
                return(false);
            }
            //int totalCount = 0;
            if (ls[0].mRL.mIsDouble)
            {
                CSubLine.getSubLineByMileage(0, mLength, mStepM, mm, mxoff, myoff, mz, md, out ml, out xl, out yl, out zl, out dl, true);
                return(true);
            }

            CSubLine.getSubLineByMileage(0, mLength, mStepM, mm, mx, my, mz, md, out ml, out xl, out yl, out zl, out dl, true);
            return(false);
        }
Пример #14
0
 /// <summary>
 /// 给定经纬度,输出里程与距离
 /// </summary>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <param name="mileage"></param>
 /// <param name="distance"></param>
 public void getDKMileagebyGPS(double x, double y, out double mileage, out double distance)
 {
     CSubLine.getMileagebyGPS(x, y, meter, longitude, latitude, out mileage, out distance);
     mileage = getDKMileagebyLocalMileage(mileage);
 }
Пример #15
0
 public void getSubLinebyPathMileage(double startm, double endm, double stepm, out double[] dm, out double[] dx, out double[] dy, out double[] dz, out double[] dd)
 {
     CSubLine.getSubLineByMileage(startm, endm, stepm, mm, mx, my, mz, md, out dm, out dx, out dy, out dz, out dd, true);
 }