Exemplo n.º 1
0
        ////获取特定点的邻居数列
        public static List <point> get_Neighbour(point thePoint)
        {
            double       distance;
            List <point> neighbour = new List <point>();

            foreach (point points in setOfPoints)
            {
                //distance = dist(thePoint, points);
                distance = CoordinateConverter.getUTMDistance(thePoint.longitude, thePoint.latitude, points.longitude, points.latitude);
                if (distance <= Eps)
                {
                    neighbour.Add(points);
                }
            }
            neighbour.Remove(thePoint);
            return(neighbour);
        }
Exemplo n.º 2
0
        /// <summary>
        ///  根据经纬度,计算半径radius距离内的所有单位工程,按距离排序输出
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="radius"></param>
        /// <param name="firmList"></param>
        /// <returns></returns>
        public Dictionary <CRailwayDWProj, double> getNearDWProj(double x, double y, double radius, List <CRailwayDWProj> dwProjectList)
        {
            Dictionary <CRailwayDWProj, double> dict = new Dictionary <CRailwayDWProj, double>(dwProjectList.Count);
            double len;

            //getNearPos(x, y, out mm, out xx, out yy, out zz, out dir);
            for (int i = 0; i < dwProjectList.Count; i++)
            {
                len = CoordinateConverter.getUTMDistance(dwProjectList[i].mLongitude_Mid, dwProjectList[i].mLatitude_Mid, x, y);
                if (len < radius)
                {
                    dict.Add(dwProjectList[i], len);
                }
            }

            var dictSort = from d in dict orderby d.Value ascending select d;

            return(dict);
        }
Exemplo n.º 3
0
        /// <summary>
        ///  根据里程(DK123+45),计算半径radius距离内的所有单位,按距离排序输出
        /// </summary>
        /// <param name="dkCode"></param>
        /// <param name="radius"></param>
        /// <param name="firmList"></param>
        /// <returns></returns>
        public Dictionary <CRailwayFirm, double> getNearFirms(string dkCode, double radius, List <CRailwayFirm> firmList)
        {
            //double[] lenList = new double[firmList.Count];
            Dictionary <CRailwayFirm, double> dict = new Dictionary <CRailwayFirm, double>(firmList.Count);
            double xx, yy, zz, dir, len;

            //double xx1,yy1,zz1,dir1;
            getPosbyMeter(dkCode, out xx, out yy, out zz, out dir);
            for (int i = 0; i < firmList.Count; i++)
            {
                len = CoordinateConverter.getUTMDistance(firmList[i].CenterLongitude, firmList[i].CenterLatitude, xx, yy);
                if (len < radius)
                {
                    dict.Add(firmList[i], len);
                }
            }

            var dictSort = from d in dict orderby d.Value ascending select d;

            return(dict);
        }
Exemplo n.º 4
0
        /// <summary>
        ///  根据经纬度,计算半径radius距离内的所有工点,按距离排序输出
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="radius"></param>
        /// <param name="firmList"></param>
        /// <returns></returns>
        public Dictionary <CRailwayProject, double> getNearProject(double x, double y, double radius, List <CRailwayProject> projectList)
        {
            Dictionary <CRailwayProject, double> dict = new Dictionary <CRailwayProject, double>(projectList.Count);
            double len, len_start, len_mid, len_end;

            //getNearPos(x, y, out mm, out xx, out yy, out zz, out dir);
            for (int i = 0; i < projectList.Count; i++)
            {
                len_start = CoordinateConverter.getUTMDistance(projectList[i].mLongitude_Start, projectList[i].mLatitude_Start, x, y);
                len_mid   = CoordinateConverter.getUTMDistance(projectList[i].CenterLongitude, projectList[i].CenterLatitude, x, y);
                len_end   = CoordinateConverter.getUTMDistance(projectList[i].mLongitude_End, projectList[i].mLatitude_End, x, y);
                len       = getMinLen(len_start, len_mid, len_end);

                if (len < radius)
                {
                    dict.Add(projectList[i], len);
                }
            }

            var dictSort = from d in dict orderby d.Value ascending select d;

            return(dict);
        }
Exemplo n.º 5
0
 public double getUTMDistance(double x, double y)
 {
     return(CoordinateConverter.getUTMDistance(mX, mY, x, y));
 }
Exemplo n.º 6
0
        //// 给定里程,计算经纬度朝向坐标
        //public CRWPosition getPosbyMeter(double m)
        //{
        //    CRWPosition pos = new CRWPosition();
        //    int index = 0;
        //    //x = y = z = 0; dir = 0;
        //    if (m < start)
        //    {
        //        pos.longitude = longitude[0];
        //        pos.latitude = latitude[0];
        //        pos.altitude = altitude[0];
        //        if (heading != null)
        //            pos.heading = heading[0];
        //        return pos;
        //    }
        //    if (m >= end)
        //    {
        //        pos.longitude = longitude[mPointNum - 1];
        //        pos.latitude = latitude[mPointNum - 1];
        //        pos.altitude = altitude[mPointNum - 1];
        //        if (heading != null)
        //            pos.heading = heading[mPointNum - 1];
        //        return pos;
        //    }
        //    int nm = (int)m;
        //    if (nm % 10 == 9)
        //    {
        //        index = nm / 10 + 1;
        //        pos.longitude = longitude[index];
        //        pos.latitude = latitude[index];
        //        pos.altitude = altitude[index];
        //        if (heading != null)
        //            pos.heading = heading[index];
        //    }
        //    else
        //    {
        //        index = nm / 10;
        //        if (nm % 10 == 0)
        //        {
        //            pos.longitude = longitude[index];
        //            pos.latitude = latitude[index];
        //            pos.altitude = altitude[index];
        //            if (heading != null)
        //                pos.heading = heading[index];
        //        }
        //        else
        //        {
        //            double t = (m - nm) / 10;
        //            pos.longitude = longitude[index] * (1 - t) + longitude[index + 1] * t;
        //            pos.latitude = latitude[index] * (1 - t) + latitude[index + 1] * t;
        //            pos.altitude = altitude[index] * (1 - t) + altitude[index + 1] * t;
        //            if (heading != null)
        //                pos.heading = heading[index] * (1 - t) + heading[index + 1] * t;
        //        }
        //    }
        //    return pos;
        //}

        /// <summary>
        /// 给定经纬度,输出里程与距离
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="mileage"></param>
        /// <param name="distance"></param>
        public void getMeterbyPos(double x, double y, out double mileage, out double distance)
        {
            int    errorNum = 0;
            double ux, uy;

            CoordinateConverter.LatLonToUTMXY(y, x, out ux, out uy);
            distance = 0;
            mileage  = 0;
            try
            {
                mileage = 0;

                int    count   = mPointNum;
                double mindist = (utmX[0] - ux) * (utmX[0] - ux) +
                                 (utmY[0] - uy) * (utmY[0] - uy);
                double dist = 10;
                int    step = (int)Math.Sqrt(count) + 1;
                //int i;
                int index = 0;
                for (int i = step; i < count; i += step)
                {
                    dist = (utmX[i] - ux) * (utmX[i] - ux) + (utmY[i] - uy) * (utmY[i] - uy);
                    if (dist < mindist)
                    {
                        mindist = dist;
                        index   = i;
                    }
                    errorNum = i;
                }

                int index2 = index;
                int j      = index - step;
                if (j < 0)
                {
                    j = 0;
                }
                for (; j < index + step && j < count; j++)
                {
                    dist = (utmX[j] - ux) * (utmX[j] - ux) + (utmY[j] - uy) * (utmY[j] - uy);
                    if (dist < mindist)
                    {
                        mindist = dist;
                        index2  = j;
                    }
                    errorNum = -j;
                }
                if (index2 > 0 && index2 < count - 1)
                {
                    double d1, d2;
                    d1      = Math.Sqrt(Math.Pow(utmX[index2 - 1] - ux, 2) + Math.Pow(utmY[index2 - 1] - uy, 2));
                    d2      = Math.Sqrt(Math.Pow(utmX[index2 + 1] - ux, 2) + Math.Pow(utmY[index2 + 1] - uy, 2));
                    mileage = meter[index2 - 1] + (meter[index2 + 1] - meter[index2 - 1]) * d1 / (d1 + d2);
                }
                else if (index2 == 0)
                {
                    double d1, d2;
                    d1      = Math.Sqrt(Math.Pow(utmX[0] - ux, 2) + Math.Pow(utmY[0] - uy, 2));
                    d2      = Math.Sqrt(Math.Pow(utmX[1] - ux, 2) + Math.Pow(utmY[1] - uy, 2));
                    mileage = (meter[1] - meter[0]) * d1 / (d1 + d2);
                }
                else
                {
                    double d1, d2;
                    d1      = Math.Sqrt(Math.Pow(utmX[count - 2] - ux, 2) + Math.Pow(utmY[count - 2] - uy, 2));
                    d2      = Math.Sqrt(Math.Pow(utmX[count - 1] - ux, 2) + Math.Pow(utmY[count - 1] - uy, 2));
                    mileage = meter[count - 2] + (meter[count - 1] - meter[count - 2]) * d1 / (d1 + d2);
                }
                double mx, my, mz, md;
                getPosbyLocalMeter(mileage, out mx, out my, out mz, out md);
                if (mIsReverse)
                {
                    mileage = mStart - mileage;
                }
                else
                {
                    mileage = mStart + mileage;
                }
                distance = CoordinateConverter.getUTMDistance(mx, my, x, y);
                //return mileage;
            }
            catch (Exception e)
            {
                Console.WriteLine("error num" + errorNum);
                //return -1;
            }
        }