First, of all, you need to make sure your calculator or computer
is using degrees, not radians, to figure out the Sine, Cosine, and ArcCosine
functions. If you're using a calculator or computer that uses radians, then
use a different version of the formula:
Arccos[Cos[a1] Cos[b1] Cos[a2] Cos[b2] + Cos[a1] Sin[b1] Cos[a2] Sin[b2]
+ Sin[a1] Sin[a2]] * r
Also, keep in mind that these formulae don't take into account the squashed
nature of the earth. As you may know, the earth is kind of fat around the
equator, as a result of the centrifugal force it gets from spinning on its
axis. So that will throw a little error into these calculations. I've
never tried to come up with a formula that takes the squashing into account,
and I suspect it might be hard.
ALso here is link for distance calculator http://jan.ucc.nau.edu/~cv
Main Topics
Browse All Topics





by: CristopherJonesPosted on 2008-08-16 at 16:35:01ID: 22245577
As far as I can tell both code snippet sets look fine, I would definitely do testing once you have the code in place :).
As far as whether to go with SQL server or Programming, I would say if you are going to use the DB in your Application, and it will be available for the end users, do the calculation in sql server,
Reasoning being, the calculation is a fairly fast one so unless you will be doing THOUSANDS of these for a user at one time(Single Function Call), the load will be minimal on the server, secondly, it's always easier to change the calculations you have if they are in the SQL server as opposed to your code, so say you had to go back in and change the Radius of the Earth calculation, instead of changing your app you just change the function / stored procedure and everything is DONE.
Now, if you plan on doing Lots of these calculations (seperate function calls) and you have integrated this calculation all over the place, say for 500 points on a map or some such, you may as well move it into the application, because the communication lag for SQL response will eat you up after just a few calls to the function.
Hope this helps.
Thanks, Cris