469,304 Members | 2,303 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,304 developers. It's quick & easy.

Zip Code Radius Search

I'm creating a zip code radius search. I have a general understand of how
this works, but am puzzled by how to get my final list of company locations.

I have setup two database tables: one with zip codes w/latitudes and
longitudes and the other with company names and addresses. The user enters
their zip code and the corresponding latitude and longitude is returned. I
then use this to return a list of zips, latitudes and longitudes within a
given radius of the original zip.

Using this list, how do I get my final list of company locations? I can loop
through the list one by one, but is there a more efficient way?

Thanks in advance!
Jul 17 '05 #1
8 9104

On 28-Jan-2004, "Bacci" <ba***@shimmi.com> wrote:
I'm creating a zip code radius search. I have a general understand of how
this works, but am puzzled by how to get my final list of company
locations.

I have setup two database tables: one with zip codes w/latitudes and
longitudes and the other with company names and addresses. The user enters
their zip code and the corresponding latitude and longitude is returned. I
then use this to return a list of zips, latitudes and longitudes within a
given radius of the original zip.

Using this list, how do I get my final list of company locations? I can
loop
through the list one by one, but is there a more efficient way?


Look up the users lat/long
Join zip and company on zipcode, create a field that contains the distance
from the users lat/long to the company's order by that distance (this can be
done in one SELECT)

--
Tom Thackrey
www.creative-light.com
tom (at) creative (dash) light (dot) com
do NOT send email to ja*********@willglen.net (it's reserved for spammers)
Jul 17 '05 #2
Tom,

That should do it--thanks!

I'm somewhat concerned about performance. That is, how long it will take to
return a recordset again a database of over 52K records. Hopefully it won't
be too bad.

BTW, what's up with your signiture? Revenge? I'm thinking about doing the
same for a "deserving" group.

"Tom Thackrey" <us***********@nospam.com> wrote in message
news:cV*******************@newssvr25.news.prodigy. com...

On 28-Jan-2004, "Bacci" <ba***@shimmi.com> wrote:
I'm creating a zip code radius search. I have a general understand of how this works, but am puzzled by how to get my final list of company
locations.

I have setup two database tables: one with zip codes w/latitudes and
longitudes and the other with company names and addresses. The user enters their zip code and the corresponding latitude and longitude is returned. I then use this to return a list of zips, latitudes and longitudes within a given radius of the original zip.

Using this list, how do I get my final list of company locations? I can
loop
through the list one by one, but is there a more efficient way?
Look up the users lat/long
Join zip and company on zipcode, create a field that contains the distance
from the users lat/long to the company's order by that distance (this can

be done in one SELECT)

--
Tom Thackrey
www.creative-light.com
tom (at) creative (dash) light (dot) com
do NOT send email to ja*********@willglen.net (it's reserved for spammers)

Jul 17 '05 #3
Tom,

That should do it--thanks!

I'm somewhat concerned about performance. That is, how long it will take to
return a recordset against a database of over 52K records. Hopefully it
won't
be too bad.

BTW, what's up with your signiture? Revenge? I'm thinking about doing the
same for a "deserving" group.

"Tom Thackrey" <us***********@nospam.com> wrote in message
news:cV*******************@newssvr25.news.prodigy. com...

On 28-Jan-2004, "Bacci" <ba***@shimmi.com> wrote:
I'm creating a zip code radius search. I have a general understand of how this works, but am puzzled by how to get my final list of company
locations.

I have setup two database tables: one with zip codes w/latitudes and
longitudes and the other with company names and addresses. The user enters their zip code and the corresponding latitude and longitude is returned. I then use this to return a list of zips, latitudes and longitudes within a given radius of the original zip.

Using this list, how do I get my final list of company locations? I can
loop
through the list one by one, but is there a more efficient way?
Look up the users lat/long
Join zip and company on zipcode, create a field that contains the distance
from the users lat/long to the company's order by that distance (this can

be done in one SELECT)

--
Tom Thackrey
www.creative-light.com
tom (at) creative (dash) light (dot) com
do NOT send email to ja*********@willglen.net (it's reserved for spammers)

Jul 17 '05 #4
Tom,

That should do it--thanks!

I'm somewhat concerned about performance. That is, how long it will take to
return a recordset against a database of over 52K records. Hopefully it
won't be too bad.

BTW, what's up with your signature? Revenge? I'm thinking about doing the
same for a "deserving" recipient.

"Tom Thackrey" <us***********@nospam.com> wrote in message
news:cV*******************@newssvr25.news.prodigy. com...

On 28-Jan-2004, "Bacci" <ba***@shimmi.com> wrote:
I'm creating a zip code radius search. I have a general understand of how this works, but am puzzled by how to get my final list of company
locations.

I have setup two database tables: one with zip codes w/latitudes and
longitudes and the other with company names and addresses. The user enters their zip code and the corresponding latitude and longitude is returned. I then use this to return a list of zips, latitudes and longitudes within a given radius of the original zip.

Using this list, how do I get my final list of company locations? I can
loop
through the list one by one, but is there a more efficient way?
Look up the users lat/long
Join zip and company on zipcode, create a field that contains the distance
from the users lat/long to the company's order by that distance (this can

be done in one SELECT)

--
Tom Thackrey
www.creative-light.com
tom (at) creative (dash) light (dot) com
do NOT send email to ja*********@willglen.net (it's reserved for spammers)

Jul 17 '05 #5
"Bacci" <ba***@shimmi.com> wrote in message news:<V_0Sb.178697$na.291973@attbi_s04>...
I'm creating a zip code radius search. I have a general understand of how
this works, but am puzzled by how to get my final list of company locations.

I have setup two database tables: one with zip codes w/latitudes and
longitudes and the other with company names and addresses. The user enters
their zip code and the corresponding latitude and longitude is returned. I
then use this to return a list of zips, latitudes and longitudes within a
given radius of the original zip.

Using this list, how do I get my final list of company locations? I can loop
through the list one by one, but is there a more efficient way?


This is not the solution for your question. But, this is a good
link on the topic <http://www.phparchitect.com/sample.php?disc_show=316&mid=9>

--
"I don't believe in the God who doesn't give me food, but shows me
heaven!" -- Swami Vivekanandha
Email: rrjanbiah-at-Y!com
Jul 17 '05 #6


On 29-Jan-2004, "Bacci" <ba***@shimmi.com> wrote:

Look up the users lat/long
Join zip and company on zipcode, create a field that contains the
distance
from the users lat/long to the company's order by that distance (this
can be
done in one SELECT)

I'm somewhat concerned about performance. That is, how long it will take
to
return a recordset again a database of over 52K records. Hopefully it
won't
be too bad.

BTW, what's up with your signiture? Revenge? I'm thinking about doing the
same for a "deserving" group.


It's just arithmetic, so I think performance will be OK. I've used it a bit,
but not on a large table.

James Butler was one of Walter Matthew's aliases in the movie Hopscotch. I
use it as a honey pot for spammers, any email to that account goes directly
to spamcop.

--
Tom Thackrey
www.creative-light.com
tom (at) creative (dash) light (dot) com
do NOT send email to ja*********@willglen.net (it's reserved for spammers)
Jul 17 '05 #7
For performance reasons, I'm going to pre-calculate the high latitude and
longitude.

BTW, you and I have similar backgrounds and interests. I am web application
developer by trade, but have been doing photography since high school. I was
film based until finally converting to a digital about a year ago. I'd
eventually like to get out of development all together and follow my bliss.
Time will tell...

"Tom Thackrey" <us***********@nospam.com> wrote in message
news:29*****************@newssvr29.news.prodigy.co m...


On 29-Jan-2004, "Bacci" <ba***@shimmi.com> wrote:

Look up the users lat/long
Join zip and company on zipcode, create a field that contains the
distance
from the users lat/long to the company's order by that distance (this
can be
done in one SELECT)
I'm somewhat concerned about performance. That is, how long it will take
to
return a recordset again a database of over 52K records. Hopefully it
won't
be too bad.

BTW, what's up with your signiture? Revenge? I'm thinking about doing

the same for a "deserving" group.


It's just arithmetic, so I think performance will be OK. I've used it a

bit, but not on a large table.

James Butler was one of Walter Matthew's aliases in the movie Hopscotch. I
use it as a honey pot for spammers, any email to that account goes directly to spamcop.

--
Tom Thackrey
www.creative-light.com
tom (at) creative (dash) light (dot) com
do NOT send email to ja*********@willglen.net (it's reserved for spammers)

Jul 17 '05 #8

On 30-Jan-2004, "Bacci" <ba***@shimmi.com> wrote:
For performance reasons, I'm going to pre-calculate the high latitude and
longitude.
I suppose you could compute a square around the target zip and select those
zips that fall within the square the companies that are in those zips.

BTW, you and I have similar backgrounds and interests. I am web
application
developer by trade, but have been doing photography since high school. I
was
film based until finally converting to a digital about a year ago. I'd
eventually like to get out of development all together and follow my
bliss.
Time will tell...


I've been dragged kicking and screaming into digital. I now do very little
color film. I still do all my black and white in the darkroom, but I've
friends who are scanning B&W, photoshoping it and inkjet printing new negs.
Most of them are platinum printing, but I can see the advantages for hard to
print negs.

--
Tom Thackrey
www.creative-light.com
tom (at) creative (dash) light (dot) com
do NOT send email to ja*********@willglen.net (it's reserved for spammers)
Jul 17 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Shelly | last post: by
15 posts views Thread by J Peterman | last post: by
2 posts views Thread by Nazir | last post: by
1 post views Thread by Marek Mänd | last post: by
1 post views Thread by Chris Ochs | last post: by
20 posts views Thread by chump1708 | last post: by
3 posts views Thread by dimstthomas | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by harlem98 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.