从n海里

时间:2018-01-31 16:23:56

标签: c# sql-server math geometry geography

我正试图从地图中找到D处的坐标。

从C到D的线需要与A线和B线成90度。

坐标D必须远离坐标C和海里,坐标C可以是A和B之间的任何位置。

我使用C#使用命名空间System.Data.Spatial来生成DbGeometry数据。

我正在使用的数据如此133043N1443814E至133515N1443710E然后以13.316N在133416N1445256E为中心的原点锁定

其他数据样本位于美国联邦航空局网站http://tfr.faa.gov/save_pages/detail_8_2189.html

enter image description here

谢谢,

3 个答案:

答案 0 :(得分:1)

例如,可以按如下方式进行:

  1. 使用此formula
  2. 查找点AB之间的路线(方位角)
  3. 通过此formula找到连接AB的大圆圈部分的中点(中间点为f=0.5
  4. 通过固定前一步骤中获得的点并调整在第一步中获得的方位角(减去pi / 2模2 * pi),可以calculate所需的点D达到规定的距离
  5. 如果预先指定了点C,可以跳过步骤2并直接在步骤3中使用此点以及在步骤1中计算的调整后的路线。

答案 1 :(得分:0)

在将sql标记添加到问题之前,您需要了解所需的计算。您还没有为sql server提供帮助,首先需要逻辑帮助,然后是数学帮助。

您已将C的位置标记为插图的1/2方向,但是AB线的90度可能在线上比直接在中间更高或更低。在您将所有要求定义为数学帮助之后,在您的问题中也没有提及它。

获得等式后,显示您计划在SQL Server或C#中使用的代码,以及您计划在哪里进行繁重的工作'首先是代码然后社区可以提供帮助。

我认为这是一个非常有趣的问题,会得到关注。

答案 2 :(得分:0)

//Example with mutliple coordinates before creating an arc. AREA DEFINED AS 133830N1450807E TO 132836N1444449E TO 133043N1443814E TO 133515N1443710E THEN CLOCKWISE ON A 15.3 NM ARC CENTERED ON 133416N1445256E TO THE POINT OF ORIGIN
                    //Abbreviation
                    //    a
                    //    b
                    //    m(midangle)   (cx,cy,ax,ay,bx,by)
                    //    x(lat)
                    //    y(long)
                    //Xc=latitude provided in text for center point
                    //Yc=longitude provided in text for center point

                    //point is the last point
                    var startPointStr = generateCircleLine[generateCircleLine.Length - 1].Split(' ');

                    var startPoint = new TfrXY { LngX = Convert.ToDouble(startPointStr[0]), LatY = Convert.ToDouble(startPointStr[1]) };
                    //point before the last point

                    var stopPointStr = generateCircleLine[generateCircleLine.Length - 2].Split(' ');

                    var stopPoint = new TfrXY { LngX = Convert.ToDouble(stopPointStr[0]), LatY = Convert.ToDouble(stopPointStr[1]) };
                    var centerPoint = new TfrXY { LngX = Convert.ToDouble(centerPointStr[0]), LatY = Convert.ToDouble(centerPointStr[1]) };

                    var a = Math.Atan2(stopPoint.LatY- centerPoint.LatY, stopPoint.LngX-centerPoint.LngX);
                    var b = Math.Atan2(startPoint.LatY-centerPoint.LatY, startPoint.LngX-centerPoint.LngX);

                    var m = MidAngle(centerPoint.LngX, centerPoint.LatY, startPoint.LngX, startPoint.LatY, stopPoint.LngX, stopPoint.LatY);

                    var d = Math.Sqrt(      
                        Math.Pow(Convert.ToDouble(centerPointStr[0]) - startPoint.LngX, 2) +
                        Math.Pow(Convert.ToDouble(centerPointStr[1]) - startPoint.LatY, 2)   );

                    var ym = (centerPoint.LatY) +( d * Math.Sin(m));
                    var xm = (centerPoint.LngX) + (d * Math.Cos(m));








The latidude and longitude would be  ym  and xml

You will also need to use this function.



        /// <summary>
        /// Find mid angle
        /// </summary>
        /// <param name="cx">center point longitude</param>
        /// <param name="cy">center point latitude</param>
        /// <param name="ax">Starting point longitude </param>
        /// <param name="ay">Starting point latitude</param>
        /// <param name="bx">Stopping point longitude</param>
        /// <param name="by">Stopping point latitude</param>
        /// <returns></returns>
        public static double MidAngle(double cx, double cy, double ax, double ay, double bx, double by)
        {

            var a = Math.Atan2(ay - cy, ax - cx);
            var b = Math.Atan2(by - cy, bx - cy);

            //Fixing infinite loop issue
            if ((ax == cx) && (ay > cy))
                a = Math.PI / 2.0;
            else if ((ax == cx) && (ay <= cy))
                a = -Math.PI / 2.0;
            else
                a = Math.Atan2(ay - cy, ax - cx);

            if ((bx == cx) && (by > cy))
                b = Math.PI / 2.0;
            else if ((bx == cx) && (by <= cy))
                b = -Math.PI / 2.0;
            else
                b = Math.Atan2(by - cy, bx - cx);



            var delta = a - b;
            while (delta < 0)
            {
                delta += 2 * Math.PI;
            }
            return a - (delta / 2);
        }