Calculate distance between two Lattitude Longitude Coordiantes using ColdFusion 6

I see there are many formulae on this site for doing this. But I need to know how to do it using
Cold Fusion.

I will have two coordinates I need to calculate the distance dynamically as I run a Schedulted CF task to mail members of the data base:- .  to see if a posted opportunity is within their defined area - they specify how many KMS they are prepared to travel.

Eg I will have

        MemberLat = "37.6922361"
        MemberLng = "-97.3375448"

          OpportunityLat = "56.1303660"
        OpportunityLng = "-106.3467710"

How to calulate the distance between in Kilometers using CF6?

Thanks for your help/
Ian WhiteOwner and FounderAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You need the equation, then it's all down hill.

Here is one in SQL

Below is code in Coldfusion...

<cfset radlat1 = ((pi() * lat1)/180)>
<cfset radlat2 = ((pi() * lat2)/180)>
<cfset radlon1 = ((pi() * lon1)/180)>
<cfset radlon2 = ((pi() * lon2)/180)>
<cfset theta = lon1-lon2>
<cfset radtheta = ((pi() * theta)/180)>
<cfset dist = ((60 * 1.1515) * (180 / pi()) * (ACos((Sin(radlat1) * Sin(radlat2)) + (Cos(radlat1) * Cos(radlat2) * Cos(radtheta)))))>

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ian WhiteOwner and FounderAuthor Commented:
Thanks it brings back a result ok.  Do you know if the CF code returns miles or kilometers. It does not say in the documentation. Give it talks about zip codes - does this mean miles?


 Yea, it's miles.   Just convert the result to kilometers..
Ian WhiteOwner and FounderAuthor Commented:
Quick response
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.