Hi guys. As they say in CF good practices. Make your database do the work
for you. I have a CFC with this function below. I need to make it into a
stored procedure.
The function is:
    <cffunction name="LatLonDist" returntype="numeric" access="public">

        <cfargument name="lat1" type="numeric" required="true">
        <cfargument name="lon1" type="numeric" required="true">
        <cfargument name="lat2" type="numeric" required="true">
        <cfargument name="lon2" type="numeric" required="true">
        <cfargument name="units" type="string" required="true">

            <cfset var myResult = 0>

            <CFIF (arguments.lat1 GT 90 OR arguments.lat1 LT -90 OR
arguments.lon1 GT 180 OR arguments.lon1 LT -180 OR arguments.lat2 GT 90 OR
arguments.lat2 LT -90 OR arguments.lon2 GT 280 OR arguments.lon2 LT -280)>
            <cfset myResult = 0>

            <cfelse>

            <cfset lat1 = arguments.lat1 * pi()/180>
            <cfset lon1 = arguments.lon1 * pi()/180>
            <cfset lat2 = arguments.lat2 * pi()/180>
            <cfset lon2 = arguments.lon2 * pi()/180>
            <cfset UnitConverter = 1.150779448>

            <cfif arguments.units eq 'nm'>
            <cfset UnitConverter = 1.0>
            </cfif>

            <cfif arguments.units eq 'km'>
            <cfset UnitConverter = 1.852>
            </cfif>

            <cfset distance =
2*asin(sqr((sin((arguments.lat1-arguments.lat2)/2))^2
+ cos(arguments.lat1)*cos(arguments.lat2)*(sin((
arguments.lon1-arguments.lon2)/2))^2))>
            <cfif arguments.units neq 'radians'>
                <cfset distance = UnitConverter * 60 * distance * 180/pi()>
            </cfif>

            <cfset myResult=distance>
            </CFIF>
            <cfreturn myResult>

    </cffunction>

Thanks,
K


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Find out how CFTicket can increase your company's customer support 
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:225979
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to