var R = 6371; // km
var dLat = (lat2-lat1).toRad();
var dLon = (lon2-lon1).toRad();
var a = Math.sin(dLat/2) * Math.sin(dLat/2) +
Math.cos(lat1.toRad()) * Math.cos(lat2.toRad()) *
Math.sin(dLon/2) * Math.sin(dLon/2);
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
var d = R * c;
I got this from http://www.movable-type.co.uk/scripts/latlong.html
Please see the section for Distance.
Thanks a lot.
How to convert a javascript code to SQL stored procedure
Can anyone help me to conver the following javascript code to
SQLSTOREDPROCEDURE. I am not an expert to write stored procedure. I
want to make a stored procdure to find distance between two postcodes:
Vijaya KadiyalaPosted Oct 4, 2008, 4:53 PM
Hi,
You need to do following things:
1) Find the functions which are specific to Java Script and look for these in respective database.
2) Look for the piece of code which is specific in Java Script.
But by looking at the code if you find the java script equivalent functions then it will eases your work.
Thanks -- Vj
http://dotnetvj.blogspot.com
http://oravj.blogspot.com