I've come into this thread late so ignore if the attached has been posted already or unnecessary, but here is code that takes into account the curvature of the earth.
<cfset radian = 57.2958> <cfset pi = 3.14159> <cfset lat1rad = lat1 / radian> <cfset long1rad = long1 / radian> <cfset lat2rad = lat2 / radian> <cfset long2rad = long2 / radian> <cfset distance = (sin(Lat1rad) * sin(Lat2rad) + cos(Lat1rad) * cos(Lat2rad) * cos(abs((long2rad)-(long1rad))))> <cfset distance = atn((sqr(1 - distance ^ 2)) / distance)> <cfset kmdist = round(1.852 * 60.0 * ((distance / pi) * 180))> cheers Drew Peacock -----Original Message----- From: "Darren Tracey" <[EMAIL PROTECTED]> To: "cfaussie" <[email protected]> Date: Tue, 14 Nov 2006 16:59:56 -0800 Subject: [cfaussie] Re: [OT] Calculate distance with long/lat > > If performance is an issue and you use pythagorus, then don't find the > square root of the two squared sides, but compare it to the squared > distance desired. > e.g. if you want to know things within a 10 km distance, then compare > X*X+Y*Y < 100. > Finding a square root is extremely expensive computationally, and if > you can avoid it, it will trim your time dramatically. > > Darren > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "cfaussie" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en -~----------~----~----~----~------~----~------~--~---
