This is something we use for searching for service centers within a 
certain radius. Hope it helps.

<CFPARAM NAME="form.distance" DEFAULT="50"> 
<CFQUERY NAME="geoCode" DATASOURCE="#request.site.dsn#">
SELECT latitude,longitude
FROM geocode
WHERE  zipCode = '#form.zipCode#'
</cfquery>
<CFIF geoCode.recordCount is 0>
<CFLOCATION URL="ZipNotFound.cfm?zipCode=#form.zipCode#">
</cfif>
<CFQUERY NAME="findSC" DATASOURCE="#request.site.dsn#">
SELECT  svccode,
  name,
  city,
  state,
  status,
  latitude,
  longitude,
  distance = sqrt(  square( 69.1 *  (longitude  - #geocode.longitude#) 
* ( cos(#geocode.latitude#/57.3)  )  ) 
           + square( 69.1 *  (latitude - #geocode.latitude#)  )  )
FROM serviceCenter
WHERE sqrt(  square( 69.1 *  (longitude  - #geocode.longitude#) * ( 
cos(#geocode.latitude#/57.3)  )  ) 
           + square( 69.1 *  (latitude - #geocode.latitude#)  )  ) <= 
(#form.distance# + 5) -->
ORDER BY distance
</cfquery>




There are two major products that come out of Berkeley: LSD and [Unix] 
BSD. We don't believe this to be a coincidence.



Doug Brown
----- Original Message ----- 
From: "Tangorre, Michael T." <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Saturday, January 12, 2002 9:17 AM
Subject: RE: CF and Zip Codes


> Basically what I am doing to clarify things is the following:
> I wanna be able to search for stores in my database and get the stores
> within x number of miles from the visitors enetered zip code..
> 
> Does this make more sense..sorry for the confusion... I pulled an all
> nighter  :-)
> 
> 
> 
> -----Original Message-----
> From: Jeff Beer [mailto:[EMAIL PROTECTED]] 
> Sent: Saturday, January 12, 2002 11:35 AM
> To: CF-Talk
> Subject: RE: CF and Zip Codes
> 
> 
> Hey - Michael - I read your message wrong.  If all you need is the 
distance
> between two zips you can have that tag for free.  It won't do the 
radius
> calcs (all zips within x miles of a given zip).
> 
> Sorry for the confusion!
> 
> <cf_need_coffee strength="strong" style="black">
> 
> 
> 
> -----Original Message-----
> From: Tangorre, Michael T. [mailto:[EMAIL PROTECTED]]
> Sent: Saturday, January 12, 2002 11:14 AM
> To: CF-Talk
> Subject: CF and Zip Codes
> 
> 
> Has anyone ever done this or know a good way to do it..
> I need to calculate the distance between 2 zip codes using Cold 
Fusion.
> 
> Michael T. Tangorre
> 
> ==========================
> Resident Assistant - Brick
> Web Applications Developer
> A.U. Webteam Slave  :-)
> AIM: CrazyFlash4
> ==========================
> 
> 
> 
> 
______________________________________________________________________
Why Share?
  Dedicated Win 2000 Server � PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER
  Instant Activation � $99/Month � Free Setup
  http://www.pennyhost.com/redirect.cfm?adcode=coldfusionc
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to