C# 按半径和角度在地图上画一个圆

C# 按半径和角度在地图上画一个圆,c#,map,geometry,dynamic-data-display,C#,Map,Geometry,Dynamic Data Display,我正在使用MicrosoftVisualStudio2010,带有参考动态数据显示。 我想在地图上画一个圆,我有两个点,一个是圆心,另一个是圆上的点,它们之间的距离是圆的半径。 结果应该如下所示: 当我用一个点画一个圆时,我的结果是,距离=半径=15: 但当我画的圆的距离在2点距离=3400+之间时,我看不到我画的圆。 我很想得到一些帮助,有我的代码可以找到两点之间的距离 // Calculating the distance between the two points double dL

我正在使用MicrosoftVisualStudio2010,带有参考动态数据显示。 我想在地图上画一个圆,我有两个点,一个是圆心,另一个是圆上的点,它们之间的距离是圆的半径。 结果应该如下所示:

当我用一个点画一个圆时,我的结果是,距离=半径=15:

但当我画的圆的距离在2点距离=3400+之间时,我看不到我画的圆。 我很想得到一些帮助,有我的代码可以找到两点之间的距离

 // Calculating the distance between the two points 
double dLat = (ps.X - centerPoint.X) / 180 * Math.PI;
double dLong = (
       double.Parse(this.plotter.Viewport.Transform.DataTransform.ViewportToData(ps).Y.ToString()) -
       double.Parse(this.plotter.Viewport.Transform.DataTransform.ViewportToData(centerPoint).Y.ToString())) / 180 * Math.PI;

double a = Math.Sin(dLat / 2) * Math.Sin(dLat / 2)
            + Math.Cos(ps.X / 180 * Math.PI) * Math.Cos(pointLine1.X / 180 * Math.PI)
            * Math.Sin(dLong / 2) * Math.Sin(dLong / 2);
double c = 2 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1 - a));

//Calculate radius of earth
double radiusE = 6378135; // Equatorial radius, in metres
double radiusP = 6356750; // Polar Radius

//Numerator part of function
double nr = Math.Pow(radiusE * radiusP * Math.Cos(ps.X / 180 * Math.PI), 2);
//Denominator part of the function
double dr = Math.Pow(radiusE * Math.Cos(ps.X / 180 * Math.PI), 2)
                + Math.Pow(radiusP * Math.Sin(ps.X / 180 * Math.PI), 2);
double radius = Math.Sqrt(nr / dr);

//Calculate distance in meters.
distance = (radius * c); // resualt in meters
distance /= 1000; // resualt in KM
下面是我添加圆圈的代码:

while (a < 360) // Doing one round around the point (The angels)
{
    // Get the X position of the pointClicked
    cx = (double)prePs.X;
    // Get the Y position of the pointClicked
    cy = double.Parse(this.plotter.Viewport.Transform.DataTransform.ViewportToData(prePs).Y.ToString());

    // Get the new X position of the pointClicked by the angel with math calculation
    xEndP = (float)(distance * Math.Cos(a * Math.PI / 180F)) + cx;
    // Get the new Y position of the pointClicked by the angel with math calculation
    yEndP = (float)(distance * Math.Sin(a * Math.PI / 180F)) + cy;

    // Creating the new point 
    globalPoint = new DraggablePoint(new Point(xEndP, yEndP));
    globalPoint.Position = new Point(xEndP, yEndP);
    globalPoint.Visibility = Visibility.Visible;

    // Increas the angel
    a++;
    //Creat new point on the circle with new angel
    xEndPNext = (float)(distance * Math.Cos(a * Math.PI / 180F)) + cx;
    yEndPNext = (float)(distance * Math.Sin(a * Math.PI / 180F)) + cy;

    // Creat line between the two new points that we creat now
    segmentHelper = new Segment(new Point(xEndP, yEndP), new Point(xEndPNext, yEndPNext));

    // Brush between the points by line
    SolidColorBrush mySolidColorBrush = new SolidColorBrush();
    mySolidColorBrush.Color = Color.FromArgb(255, 47, 79, 49);
    segmentHelper.Stroke = mySolidColorBrush;

    // Add the line to the chartplotter
    plotter.Children.Add(segmentHelper);

    // Add the angel
    a++;
}
我的算法是取一个点和下一个点,当这些点明显错误时,在它们之间画一条线,然后我得到一个漂亮的圆。
非常感谢:

不过,你的圆圈是正确的,是地图扭曲了!然而,你可能仍然想在投影的地图上画一个完美的圆圈。看看这幅图,它显示了不同的地图投影是如何扭曲地球表面的圆圈的。例如,它们并不总是产生圆或椭圆。我不认识你用的投影,你从哪里得到公式的。无论如何,我不知道如何用我的距离创造一个圆。。因为距离大约是Thausends,太远了看不见。我该怎么做呢?
while (a < 360) // Doing one round around the point (The angels)
{
    // Get the X position of the pointClicked
    cx = (double)prePs.X;
    // Get the Y position of the pointClicked
    cy = double.Parse(this.plotter.Viewport.Transform.DataTransform.ViewportToData(prePs).Y.ToString());

    // Get the new X position of the pointClicked by the angel with math calculation
    xEndP = (float)(distance * Math.Cos(a * Math.PI / 180F)) + cx;
    // Get the new Y position of the pointClicked by the angel with math calculation
    yEndP = (float)(distance * Math.Sin(a * Math.PI / 180F)) + cy;

    // Creating the new point 
    globalPoint = new DraggablePoint(new Point(xEndP, yEndP));
    globalPoint.Position = new Point(xEndP, yEndP);
    globalPoint.Visibility = Visibility.Visible;

    // Increas the angel
    a++;
    //Creat new point on the circle with new angel
    xEndPNext = (float)(distance * Math.Cos(a * Math.PI / 180F)) + cx;
    yEndPNext = (float)(distance * Math.Sin(a * Math.PI / 180F)) + cy;

    // Creat line between the two new points that we creat now
    segmentHelper = new Segment(new Point(xEndP, yEndP), new Point(xEndPNext, yEndPNext));

    // Brush between the points by line
    SolidColorBrush mySolidColorBrush = new SolidColorBrush();
    mySolidColorBrush.Color = Color.FromArgb(255, 47, 79, 49);
    segmentHelper.Stroke = mySolidColorBrush;

    // Add the line to the chartplotter
    plotter.Children.Add(segmentHelper);

    // Add the angel
    a++;
}