2016-12-07 59 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#