ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 6th, 2004, 02:36 PM
peanutty peanutty is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 1 peanutty User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Zip code radius?

Hi, all:

My search page allows members to search for each other within a
selected mile range based on their zip code. I've downloaded a
list of zip codes (with their respective latitude and longitude
coordinates) from the U.S. Census Bureau. However, my coding
below doesn't work:

<!---Retrieve latitude/longitude of searcher's zip code--->
<CFQUERY name="userzip" datasource="#datasource#">
SELECT zip_code, latitude, longitude
FROM zipcodelist
WHERE zip_code='#form.zipcode#'
</CFQUERY>

<!---Retrieve zip codes that fall within searcher's range--->
<CFQUERY name="getlocs" datasource="#datasource#">
SELECT zip_code,
ROUND((ACOS((SIN(#userzip.latitude#/57.2958) * SIN(latitude/57.2958)) +
(COS(#userzip.latitude#/57.2958) * COS(latitude/57.2958) *
COS(longitude/57.2958 - #userzip.longitude#/57.2958)))) * 3963, 3) AS distance
FROM zipcodelist
WHERE (latitude >= #userzip.latitude# - (#FORM.miles#/111))
AND (latitude <= #userzip.latitude# + (#FORM.miles#/111))
AND (longitude >= #userzip.longitude# - (#FORM.miles#/111))
AND (longitude <= #userzip.longitude# + (#FORM.miles#/111))
ORDER BY distance
</CFQUERY>

<!---Narrow member search further and include above results--->
<CFQUERY...>
SELECT membername, etc.
FROM other tables...
WHERE zipcode IN (#ValueList(getlocs.zip_code)#)
AND etc...
</CFQUERY>

The error message I'm getting is:

ODBC Error Code = 22003 (Numeric value out of range)
...Arithmetic overflow error converting numeric to data type numeric.

Anyone know how to fix? Or perhaps have another equation I can use?

The only reason I could think of for why I was having the problem was because maybe the lat./long. coordinates in my DB are in degrees and not radians? (Positive and negative numbers such as these are listed: +2.00042, .166345,
-4.36345, etc.) But then again, I read that dividing by 57.2958 solves that (which is what I did above).

Also, is using ValueList (in my 3rd query) correct?

Thanks for the help,
J

Reply With Quote
  #2  
Old February 6th, 2004, 03:28 PM
kiteless kiteless is offline
Moderator
Dev Shed God (5000 - 5499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 5,091 kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level) 
Time spent in forums: 2 Weeks 5 Days 2 h 53 m 27 sec
Reputation Power: 966
Your use of valueList() looks correct. Beyond that, I have no idea, I've never tried or seen anyone else try this before. Sorry, and good luck!

Reply With Quote
  #3  
Old May 10th, 2004, 02:50 PM
toastyalbus toastyalbus is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 1 toastyalbus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 m 27 sec
Reputation Power: 0
Hey, did you figure it out?

Hi! I'm trying to do the exact same thing. Did you happen to get this to work? If so, would you mind helping me out, because I don't even know where to begin with the coding. I found the zips/states/lat/long and put them into a mysql database, but I don't know where to go from there1

Thanks a lot!

Mike

Reply With Quote
  #4  
Old May 10th, 2004, 03:48 PM
bfolger71 bfolger71 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Boston, MA
Posts: 47 bfolger71 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 34 sec
Reputation Power: 10
Is this where you guys started?

http://tutorial153.easycfm.com/

If not, maybe that can help...

BTW, what DB are you using?

Last edited by bfolger71 : May 10th, 2004 at 04:02 PM.

Reply With Quote
  #5  
Old May 14th, 2004, 12:19 PM
SayHelloTMLF SayHelloTMLF is offline
Freelance hockey player
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Location: in a van down by the river
Posts: 54 SayHelloTMLF User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 13 m 38 sec
Reputation Power: 12
Send a message via AIM to SayHelloTMLF
I solved this problem by adding Geo_Latt and Geo_Long fields to the same table where member info is stored, and recorded the coordinates to every member according to their zip code . This needs to be done prior to search. (it is a very simple operation, just take member's zip, find it in your zip code lookup list and record longtitude and lattitude)

When member submits a search I use a simpler formula that also takes earth curvature into account. Plug this into WHERE clause of the SQL search query:


Code:
.....
WHERE (SQRT(69.1*(Geo_Latt-#qStartCoord.Lattitude#)*69.1*(Geo_Latt-#qStartCoord.Lattitude#) + 53*(Geo_Long-#qStartCoord.Longtitude#)*53*(Geo_Long-#qStartCoord.Longtitude#)) <= #Form.Radius#)


Geo_Latt and Geo_Long are known coordinates listed in a member table for all members.
qStartCoord.Longtitude, qStartCoord.Lattitude are coordinates of a zip code submitted by member doing the search.


I also figured out how to find all zip codes within given radius around a specified city (zip code is not provided).

Last edited by SayHelloTMLF : May 14th, 2004 at 12:33 PM.

Reply With Quote
  #6  
Old September 4th, 2004, 11:30 AM
BlueScreen BlueScreen is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 1 BlueScreen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Where did you find the zip code info?

Where in the US Census Bureau website did you find the zip code information with the longitude and latitude information?
Can you give me the url?

Reply With Quote
  #7  
Old September 7th, 2004, 01:48 PM
EBP2K2 EBP2K2 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 48 EBP2K2 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
social network? ^^

Reply With Quote
  #8  
Old February 9th, 2010, 08:55 AM
webdesyne.com webdesyne.com is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Posts: 2 webdesyne.com User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 56 sec
Reputation Power: 0
Newbie Help?

Hi,

I'm trying to do the same thing (radius search with user defined number of miles from the zip code submitted AND the results mapped on a Google map), and I have tried different code, and have tried the cf Tutorial, but I must be missing something, because I keep getting errors.

Would someone be willing to help me? I have a MySQL database with two tables (Dealers, zipcodes) The zip code database was one that I found free. It has the following columns:
ZIP
LATITUDE1
LONGITUDE1
STATE
TOWN
RECNO (primary key)

The dealers table has these columns:
DealerID
DealerName
DealerAddress1
DealerAddress2
DealerCity
DealerState
DealerZipCode
DealerPhone
Latitude
Longitude

I'm using ColdFusion to query the database. I can get the radius search to work, and display the "miles away" from the submitted zip, but I don't know how to then translate the results to a Google Map.

Any help would be appreciated.

Elizabeth ;-)

Reply With Quote
  #9  
Old November 16th, 2012, 08:09 AM
tekbrand tekbrand is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 1 tekbrand User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 m 53 sec
Reputation Power: 0
PHP code for finding lattitude and longitude

You can pass the zip code to google map the returning datawill contail lattitude and longitude of that place

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Zip code radius?

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap