This is a followup to this question.
I seem to be stuck on this. Basically, I need to be able to convert back and forth to referring to coordinates either in the st
Check out http://www.movable-type.co.uk/scripts/latlong.html
That site has a lot of different formulas and Javascript code that should help you out. I've successfully translated it into both C# and a SQL Server UDF and I use them all over the place.
For example for Javascript to calculate distance:
var R = 6371; // km
var φ1 = lat1.toRadians();
var φ2 = lat2.toRadians();
var Δφ = (lat2-lat1).toRadians();
var Δλ = (lon2-lon1).toRadians();
var a = Math.sin(Δφ/2) * Math.sin(Δφ/2) +
Math.cos(φ1) * Math.cos(φ2) *
Math.sin(Δλ/2) * Math.sin(Δλ/2);
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
var d = R * c;
Enjoy!