Пример #1
0
 public void createExcelData(double[] m, double[] z, StreamWriter sw)
 {
     //for (int i = 0; i < m.Length -1; i++)
     //{
     //    if (m[i + 1] - m[i] < 1)
     //        Console.WriteLine(i+" error");
     //}
     double[] x = CubicSpline.Compute(meter.Length, meter, longitude, m);
     double[] y = CubicSpline.Compute(meter.Length, meter, latitude, m);
     if (mIsReverse)
     {
         for (int i = 0; i < m.Length; i++)
         {
             sw.WriteLine((mStart - m[i]) + "\t" + x[i] + "\t" + y[i] + "\t" + z[i] + "\t" + mIndex);
         }
     }
     else
     {
         for (int i = 0; i < m.Length; i++)
         {
             sw.WriteLine((mStart + m[i]) + "\t" + x[i] + "\t" + y[i] + "\t" + z[i] + "\t" + mIndex);
         }
     }
     sw.Close();
 }
Пример #2
0
        /// <summary>
        /// 旧版,没有dkcode2
        /// </summary>
        /// <param name="idx"></param>
        /// <param name="dkcode"></param>
        /// <param name="fromM"></param>
        /// <param name="toM"></param>
        /// <param name="isA"></param>
        /// <param name="isR"></param>
        /// <param name="isD"></param>
        /// <param name="num"></param>
        /// <param name="m"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="z"></param>
        /// <param name="stepm"></param>
        /// <param name="otherDKCode"></param>
        public CRailwayLine(int idx, string dkcode, double fromM, double toM, bool isA, bool isR, bool isD, int num, double[] m, double[] x, double[] y, double[] z, double stepm = 10, string otherDKCode = "")
        {
            mIndex = idx;
            mStart = fromM;
            mEnd   = toM;
            if (mStart < mEnd)
            {
                mIsReverse = false;
            }
            else
            {
                mIsReverse = true;
            }
            mDKCode = dkcode;

            mIsAuxiliary = isA;

            mIsRight  = isR;
            mIsDouble = isD;
            if (mIsDouble)
            {
                mOffset = 2.5; // 根据济青铁路轨道间距5米测算
            }
            else
            {
                mOffset = 5.4; // 线杆偏移位置
            }

            mStepm = Math.Max(1, Math.Abs(stepm)); //
            //mFromID = fromID;
            //mToID = toID;

            // 利用stepM重采样,0513,FIXED,采样非10米时,mPointNum计算错误
            mLength = m[num - 1] - m[0];
            if (mLength < 2 * mStepm)
            {
                mPointNum = 2;
            }
            else
            {
                mPointNum = (int)((mLength - 2 * stepm) / stepm) + 3;  //最后一段一般大于10米,避免最后一段过短,
            }
            meter = new double[mPointNum];

            meter[0]             = m[0];
            meter[mPointNum - 1] = m[num - 1];
            //for (int j = 0; j < num - 1; j++)
            //    if (m[j] >= m[j+ 1])
            //        Console.WriteLine("mileage error " + m[j] + "\t" + m[j+1]);

            for (int i = 1; i < mPointNum - 1; i++)
            {
                meter[i] = meter[i - 1] + mStepm;
            }

            longitude = CubicSpline.Compute(num, m, x, meter);
            latitude  = CubicSpline.Compute(num, m, y, meter);
            altitude  = CubicSpline.Compute(num, m, z, meter);

            //for (int i = 0; i < mPointNum - 1; i += (int)(1000/mStepm))
            //    mBBoxList.Add(new RectangleF((float)(longitude[i] - 0.01),(float)(latitude[i] -0.01),0.02f,0.02f));
            //if (mPointNum % 100 > 20)
            //    mBBoxList.Add(new RectangleF((float)(longitude[mPointNum -1] - 0.01), (float)(latitude[mPointNum -1] - 0.01), 0.02f, 0.02f));
            //          RectangleF rec = mBBoxList[0];
            //CoordinateConverter.LatLonToUTMXYList(mPointNum, latitude, longitude, out utmX, out utmY);
            mOtherDKCode = otherDKCode;
            CoordinateConverter.LatLonToOffsetYawList(latitude, longitude, 90, mOffset, out mOffsetX, out mOffsetY, out heading);
            //CoordinateConverter.LatLonToUTMXYList(mPointNum, latitudeMars, longitudeMars, out utmXMars, out utmYMars);


            //CoordinateConverter.LatLonOffest(longitude,latitude,heading,90,mOffset,out mOffsetX,out mOffsetY );
#if DEBUG
            validateHeading();
#endif
        }