Thank you to GEB reader DJ for trying it out and letting us know about a bug which resulted in this interesting pattern:
We decided to investigate and try and improve the accuracy of the code as well as fixing the above bug. We ended up finding a number of bugs. The first, is that for drawing circles, we had reused some code we wrote for drawing fireworks to celebrate the new year. The code correctly took into account the fact that latitude and longitude vary in scale, but apart from that used basic trigonometry to draw the circle. This works very well on small scales, but for very large circles problems become obvious, and if you draw a circle over one of the poles it wraps around it as seen below:
A second bug was due to the fact that in geodesic calculations there are two angles that are typically very similar and we were using the wrong one. This tends to only show up over large distances, so it is not something you notice immediately.
The result of the above corrections is still not perfect, but is certainly a lot more accurate than it was. There is still a bug that causes it to fail when the triangle is very large, but we hope to get that fixed over the weekend.
For those interested in the code:
- GeographicLib can be found here
- The code specific to drawing circles
- Our KML library (still in development)
About Timothy Whitehead
Timothy has been using Google Earth since 2004 when it was still called Keyhole before it was renamed Google Earth in 2005 and has been a huge fan ever since. He is a programmer working for Red Wing Aerobatx and lives in Cape Town, South Africa.
Shawn Kovalchick says
Could you use the definition of a circle as the set of points equidistant from a point? Define a center point and plot the points equidistant from it.
Timothy Whitehead says
Yes, that is how I draw the circle once I have the centre. The hard part was working out where the centre is. Also plotting points equidistant from a given point on the surface of the earth is not a straight forward task without third party libraries. Luckily GeographicLib provides the necessary routines that make that task easy.
Thanks for the accreditation – I was just doing a bit of ‘beta testing’ on an ongoing project/avocation of mine -> mapping everything interesting in the world.
First map I did was on Gold Butte in Nevada – the ‘huggers’ and the BLM have all but closed off the area against seniors and anyone who can’t hike – so I was interested in visualizing some distance calculations to senior-popular sites in the area and got the results you posted.
Now, I read every word of your above post (honest) and understood all of them (even if I had no clue what you were saying – not your fault); but, I didn’t need to – it just works! [my results here: https://dl.dropboxusercontent.com/u/567495/Temp/AntarcticCircleTest.zip ]
All the fancy calculations you mentioned seemed like they should about solve mystery of life calculations so I created a “use case” that would stretch even the mighty – It actually completely and totally BORKS the great Google Earth. Just try and create an overlay with these coordinates!
I took three placemarks for a map I’m working on which includes every ‘accepted’ map feature (landmarks) in Antarctica – the three closest which surround the South Pole! If anything would bork, it should be this! Transitioning GPS coordinates around zero. The Patuxent Ice Stream, Maud Subglacial Basin and the Titan Dome – all around the Scott-Amundsen South Pole Station. The above zip file contains: the Kml file I used, the circle.kml that you drew and the screenshot of the result – PERFECT!
In case you were wondering – the South Pole Station is at 0,-90 coordinates and represented by the “snowman” on the screenshot.