0

I am struggling with my GMAP-Application

Using the GMAP.NET library, I'm trying to draw a filled arc-polygon given by 3 coordinates: center_coordinate, start_coordinate and end_coordinate (All in format DD,MM.MMM).

Knowing that I want to draw the arc as a polygon on the map with appropriate resolution, I additionally define a number of segments and the clockwise/counterclockwise direction information.

I generally know how to draw a polygon (generated by List of PointLatLng) onto the map with GMAP.NET. That works fine, so I decided to get a List of PointLatLng.

My problem is that I don't have a concrete idea on how to calculate each point on the ideal arc.

What I've done so far

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

Any help to push me in the right direction is highly appreciated. Thanks.

Brandon
  • 4,491
  • 6
  • 38
  • 59
Dirk
  • 1
  • 1

1 Answers1

0

Well, you can use the parametric equation for a circle (https://en.wikipedia.org/wiki/Circle#Equations):

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

Where r is the radius, cx, cy the origin, and a is the angle in radians. In your case, you will simply divide the total circumference (2pi) by a to get the increment value, something like:

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);
}

If you are going to be drawing circles a lot in gmap, you are best off just making a new marker type by inheriting the GMapMarker and using the DrawEllipse function to draw a circle with some radius, which is discussed here: How to draw circle on the MAP using GMAP.NET in C#.

Community
  • 1
  • 1
T James
  • 490
  • 5
  • 16