2016-12-07 57 views
0

我与我的努力获得PointLatLng虚拟圆弧的名单GMAP-应用给出3点(中心,开始,结束)

使用GMAP.NET库,我想画一个充满弧由3个坐标给出的多边形:center_coordinate,start_coordinateend_coordinate(全部格式为DD,MM.MMM)。

由于知道我想以适当的分辨率在地图上绘制圆弧作为多边形,我还额外定义了多个分段和顺时针/逆时针方向信息。

我通常知道如何绘制一个多边形(由列表PointLatLng产生)到GMAP.NET地图上。这工作正常,所以我决定得到PointLatLng列表。

我的问题是,我没有关于如何计算理想弧上每个点的具体想法。

我到目前为止已经

Public Function list_of_points_on_arc(point_center As PointLatLng, point_arc_start As PointLatLng, point_arc_end As PointLatLng, direction As String) As List(Of PointLatLng) 

     'direction: CW - clockwise/CC - Counter Clockwise 

     Const radiusEarthKilometres As Double = 6371.01 

     'sets the resolution of arc 
     Dim elements As Integer = 20 

     'unknown point on arc, each ...element 
     Dim point_on_arc As PointLatLng 

     'List collects all points aon arc 
     Dim gpollist As List(Of PointLatLng) = New List(Of PointLatLng) 

     For i As Integer = 0 To elements 
      ' ????????????????????????????????????????????????????????? 
      'calculates new point_on_arc based on following information 
      ' - elements, point_center, point_arc_start, point_arc_end 
      ' ... 
      ' 
      ' ... 
      ' 
      ' point_on_arc = New PointLatLng(on_arc_lat, on_arc_lon) 
      ' ????????????????????????????????????????????????????????? 

      'adds point_on_arc to list 
      gpollist.Add(point_on_arc) 
     Next 

     'returns list of pointsLatLon 
     Return gpollist 
    End Function 

做任何有助于推动我在正确的方向是高度赞赏。谢谢。

回答

0

好了,你可以使用参数方程为圆(https://en.wikipedia.org/wiki/Circle#Equations):

x = cx + r * cos(a) 
y = cy + r * sin(a) 

其中r为半径,CX,CY的起源,并且是弧度的角度。在你的情况,你可以简单的通过划分总周长(2PI)来获得增值,是这样的:

double a_part = 2 * PI/elements; 
for(i = 1; i <= elements; i++) 
{ 
    x = cx + r * cos(i * a_part); 
    y = cy + r * sin(i * a_part); 
} 

如果你将要画圆在GMAP了很多,你是最好的关闭只是通过继承GMapMarker并使用DrawEllipse函数绘制具有某个半径的圆来创建新的标记类型,在此讨论:How to draw circle on the MAP using GMAP.NET in C#