I have just got this to work exactly the way I want it,

I have wrote a UDF with the correct formula in it now
and it seems to be 100% accurate,

the UDF takes into account that your LAT and LON values
are in Degree decimal format,


<!---UDF distance Formula||--->
<CFSCRIPT>
        //calculate the Deltas
        function distance(lat1,lat2,lon1,lon2){
                km=6367;
                deltaLon=twoRadians(lon1)-twoRadians(lon2);
                deltaLat=twoRadians(lat1)-twoRadians(lat2);
                //intermediate values
                intMedVal =     sin2(deltaLat/2) + cos(twoRadians(lat1)) *
cos(twoRadians(lat2)) * sin2(deltaLon/2);
                        
                        //the great circle distance in radians
                        gcd = 2 * arcSin(getMin(1,Sqr(intMedVal)));
                        //multiply the the radians by the radius to get the
distance in specified units
                        d = km * gcd;
                        //this only applies to us (ANDRONICS.CO.UK)
                        //it relevant to the vendor that is displaying the
map data
                        //the map is coming back in rectangular format they
use the length as the zoom distance
                        //we multiply it by 2 two get an equal zoom distance
from top to bottom
                        d = round(d * 2);
        }
        //Convert to Radians
        function twoRadians(currDegree){
                (currDegree * (Pi()/180));
        }
        function sin2(currVal){
                (1 - cos(2*currVal))/2;
        }
        function arcSin(x){
                atn(x/Sqr(-x * x + 1));
        }
        function getMin(y,z){
                if(y lte z){
                        getMin=y;
                }else{
                        getMin=z;
                }
        }
</CFSCRIPT>
<CFSET
ATTRIBUTES.D=distance(maxLatitude,minLatitude,maxLongitude,minLongitude)>

Respectfully,

J
______________________________________________________________________
Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. http://www.fusionauthority.com/ads.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to