zip code trig, radius calculations

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default zip code trig, radius calculations

    i have the code below to find the distance between two zips....but i want to
    find all the zips around another in a given distance (say 10 miles around
    10015), anyone know how to calc?

    this is code to find the distance between two zipcodes (you must have a
    database of long and lats for each zipcode)
    <cfset radlat1 = ((pi() * lat1)/180)>
    <cfset radlat2 = ((pi() * lat2)/180)>
    <cfset radlon1 = ((pi() * lon1)/180)>
    <cfset radlon2 = ((pi() * lon2)/180)>
    <cfset theta = lon1-lon2>
    <cfset radtheta = ((pi() * theta)/180)>
    <cfset dist = ((60 * 1.1515) * (180 / pi()) * (ACos((Sin(radlat1) *
    Sin(radlat2)) + (Cos(radlat1) * Cos(radlat2) * Cos(radtheta)))))>

    flasheister Guest

  2. Similar Questions and Discussions

    1. How to set PieChart radius?
      I have two PieCharts -- one displays a subset of the data shown in the other. Therefore, I'd like the second to be proportionally smaller. How do I...
    2. Zip code radius query
      I found this query in another post and since it appeared to be exactly what i needed, i copied it. thank you to the author. My problem is that...
    3. Radius authentication
      Hi, I need to authenticate against Radius Server from different platforms (windows and unix) . Can you help? thx
    4. Radius Authentication...
      Hey, I have searched and searched and searched for direction with this subject. Basically, I would like to use our local Windows 20003 IAS Server...
    5. Radius Server
      Has anyone setup a Radius server before using Debian ? Matt --
  3. #2

    Default Re: zip code trig, radius calculations

    Hm. Your code sure looks more likely to be correct than what I used for the
    distances. I made some simplifying assumptions that of course go whacky near
    the poles but who really cares? ;-> Here's the code I'm using: ------- <cfset
    LocalLat = q_GetLocal.Lat> <cfset LocalLong = q_GetLocal.Long> <cfloop
    condition='Contacts lt 3'> <cfset Range = Range + 0.5> <cfset LatLow =
    LocalLat - Range> <cfset LatHigh = LocalLat + Range> <cfset LongLow =
    LocalLong - Range> <cfset LongHigh = LocalLong + Range> <!--- simple
    query to just count records ---> <cfquery name=q_Contacts datasource=CPS_u>
    select Zip from Contacts where Zip in ( select
    Zip_Code from Web..ZipCodes where Lat between (#LatLow#) and (#LatHigh#)
    and Long between (#LongLow#) and (#LongHigh#) ) </cfquery>
    <cfset Contacts = q_Contacts.RecordCount> </cfloop> ----- Note that I'm
    looking to find a minimum number of 'hits' in the loop and Range is set at 0
    somewhere above this.

    Pat D. Guest

  4. #3

    Default Re: zip code trig, radius calculations

    I'm also looking to pull nearby parks based on a zip code entry. Did you find the correct calculations? Also, where did you get the database that you use, if I may ask?

    Thanks!
    DrawQuarter Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139