There's a component called ZipFinder.cfc, that contains four different methods for calculating the Zip codes (lng/lat pairs really) that fall in a certain radius. Some are quicker than others, but less accruate. While others are more accurate, but slower to run. One of the methods (the Haversine formula I think), takes into account the curvature of the earth! That is of course useful only if you're radius is big enough to cover the globe and you've got corresponding lng/lat pairs.

That said, I'd still be interested in seeing the scripts. Thanks for sharing Sophek! :o)

Chris

Loyd Campbell wrote:
Sophek,

I’d really appreciate getting the scripts, too. Thanks for sharing your hard work on this.

Loyd Campbell

[EMAIL PROTECTED]

------------------------------------------------------------------------

*From:* [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] *On Behalf Of *Sophek Tounn
*Sent:* Wednesday, April 18, 2007 5:31 PM
*To:* Dallas/Fort Worth ColdFusion User Group Mailing List
*Subject:* [DFW CFUG] free Zipcode radius cfc and includes the sql script for the zipcodeinsertion.

Hi All,

I just created a zipradius component that I would like to share, if any one is interested. I was tasked to develop code to query records within a radius of a zip code. I figure this can be useful to someone. I make use of Rob Gonda SQL component for record selection.

Check this out.

<cfcomponent extends="sql">
    <cffunction name="zipRadius" returntype="query">
        <cfargument name="zip" required="Yes" type="numeric">
        <cfargument name="radius" required="Yes" type="numeric">
<cfset getData = tblselect("zipcodes","zipcode,latitude,longitude","zipcode = #arguments.zip#","","","1")> <cfset getDataZip = tblselect("zipcodes","zipcode, latitude, longitude, statename, city, 3963 * (ACOS((SIN(#getData.latitude#/57.2958) * SIN(latitude/57.2958)) +(COS(#getData.latitude#/57.2958) * COS(latitude/57.2958) *COS(longitude/57.2958 - #getData.longitude#/57.2958)))) AS distance","3963 * (ACOS((SIN(#getData.latitude#/57.2958) * SIN(latitude/57.2958)) + (COS(#getData.latitude#/57.2958) * COS(latitude/57.2958) * COS(longitude/57.2958 - #getData.longitude#/57.2958)))) <= #arguments.radius#","","","")>
        <cfreturn getDataZip>
    </cffunction>
</cfcomponent>

Email me if you want the scripts.

Thanks
Sophek


------------------------------------------------------------------------

_______________________________________________
Reply to DFWCFUG: [email protected] Subscribe/Unsubscribe: http://lists1.safesecureweb.com/mailman/listinfo/list List Archives: http://www.mail-archive.com/list%40list.dfwcfug.org/ http://www.mail-archive.com/list%40dfwcfug.org/ DFWCFUG Sponsors: www.instantspot.com/
  www.teksystems.com/

--
http://www.cjordan.us

_______________________________________________
Reply to DFWCFUG: [email protected] Subscribe/Unsubscribe: http://lists1.safesecureweb.com/mailman/listinfo/list List Archives: http://www.mail-archive.com/list%40list.dfwcfug.org/ http://www.mail-archive.com/list%40dfwcfug.org/ DFWCFUG Sponsors: www.instantspot.com/
 www.teksystems.com/

Reply via email to