0

I found this function and converted it to VB.Net. It draws an oval rather than a circle. What do I need to do to fix the calculations?

Distorted circle

Dim seg As Double = Math.PI * 2 / segments
For i As Integer = 0 To segments - 1
  Dim theta As Double = seg * i
  Dim a As Double = _pll.Lat + Math.Cos(theta) * radius
  Dim b As Double = _pll.Lng + Math.Sin(theta) * radius
  plls.Add(New PointLatLng(a, b))
Next
2
  • 1
    What coordinate reference system is your data in? Is the basemap in the same CRS?
    – Radar
    Commented May 29, 2015 at 16:28
  • I have idea, this is GMaps.Net and I don't have any idea how to check that. There are no tags for this mapping open source. It does use Bing map as the engine.
    – DonA
    Commented May 29, 2015 at 16:34

2 Answers 2

2

The problem is that your data is in degrees, and a degree of longitude is a shorter distance than a degree of latitude anywhere other than the equator. I am not familiar with GMaps.Net and the projection features it offers but typically one would convert to a projected coordinate system, generate the circle there, and convert back to degrees.

2
  • I don't have an option to convert it to a projected coordinate system - I thought it was in that mode already. Not really sure though.
    – DonA
    Commented May 29, 2015 at 18:18
  • There should be a way with the current math.
    – DonA
    Commented May 29, 2015 at 19:19
0

Seems it needed as const aspect to be added to the lat.

Dim seg As Double = Math.PI * 2 / segments
Dim aspect As Double = 0.75
For i As Integer = 0 To segments - 1
 Dim theta As Double = seg * i
 Dim a As Double = _pll.Lat + Math.Cos(theta) * radius * aspect
 Dim b As Double = _pll.Lng + Math.Sin(theta) * radius
 plls.Add(New PointLatLng(a, b))
Next

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.