470,565 Members | 2,224 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

How to "Find store locations near you" in VB?

I have to find zipcodes within a given mileage range (25, 50, etc). I know
it's possible to use the longitude/latitude to find this, and I have that
for the zipcodes, but does anyone have a "ready made" formula? I know it has
something to do with the sine/cosine, but the "signs" aren't clear enough to
me (neither are the wonders).

Thanks in advance for the wisdom.

J
Jul 17 '05 #1
4 12928

"321ConTact" <co*******@sNpOvSiPsAiMonREMOVECAPS.com> wrote in message
news:MY**********************@twister.tampabay.rr. com...
I have to find zipcodes within a given mileage range (25, 50, etc). I know
it's possible to use the longitude/latitude to find this, and I have that
for the zipcodes, but does anyone have a "ready made" formula? I know it has something to do with the sine/cosine, but the "signs" aren't clear enough to me (neither are the wonders).


There is no formula for this. The US postal service does not assign zip
codes by longitude / latitude and distance can only be measured between two
valid addresses but not zip codes.

If not obvious, I live on the boundary of two zipcodes. My two door away
neighbor is in a different zip code.
Jul 17 '05 #2
Thus spake "Raoul Watson" <Wa*****@IntelligenCIA.com>:
"321ConTact" <co*******@sNpOvSiPsAiMonREMOVECAPS.com> wrote in message
news:MY**********************@twister.tampabay.rr. com...
I have to find zipcodes within a given mileage range (25, 50, etc). I
know it's possible to use the longitude/latitude to find this, and I
have that for the zipcodes, but does anyone have a "ready made"
formula? I know it

has
something to do with the sine/cosine, but the "signs" aren't clear
enough

to
me (neither are the wonders).


There is no formula for this. The US postal service does not assign
zip codes by longitude / latitude and distance can only be measured
between two valid addresses but not zip codes.

If not obvious, I live on the boundary of two zipcodes. My two door
away neighbor is in a different zip code.


True, but at the "heart" of each ZIP code is a post office, which certainly
does have a longitude and latitude; you can use the post office as a proxy
for the entire ZIP code, bearing in mind that Los Angeles ZIP codes are
tiny but Wyoming ZIP codes are huge...

All that being said, I'm afraid my trig skillz aren't up to the OP's
original question. Sorry.
Jul 17 '05 #3
> I have to find zipcodes within a given mileage range (25, 50, etc). I know
it's possible to use the longitude/latitude to find this, and I have that
for the zipcodes, but does anyone have a "ready made" formula? I know it has
something to do with the sine/cosine, but the "signs" aren't clear enough to
me (neither are the wonders).


It depends on what you are trying to do. Assuming Long/Latitude creates
perfectly horizontal and vertical lines (which they do in about 25-30miles
radius), then a famous mathematician might be able to help.

Pythagoras (Greece, BC) came up with a rule we still use today.
(a^2) + (b^2) = (c^2)
If a = latitudinal distance, b = longitudinal distance, then c = distance
between the two points.
For each ZIP code, you'll have to do
a = x1 - x2
b = y1 - y2
c = Sqrt((a^2) + (b^2))
Where x1 is latitude of the "from" ZIP, x2 is lat. of the "to" ZIP,
y1 is long. of the "from" ZIP and y2 is long. of the "to" ZIP.

Alternatively, a is the difference in latitude of the two ZIPs, b is the
difference in longitude of the two ZIPs. These can be negative, as squaring them
makes them positive in any case.

Now, if c =< 25, then the distance is less than or equal to 25miles from ZIP to
ZIP.

Finally, the bummer: Where do you measure long/latitude?
You can either find the middle of the streets ((left end + right end) / 2) or
you can find some other way.

Trig doesn't come into it, unless the distance is large (such as 100miles) as
the curvature of the Earth forces us to abandon Euclidean co-ordinate systems
and think spherically, which is too difficult.

--
QuickHare
(BSc in Maths with Computer Science)
(QuickHare "at" Hotmail "dot" com)
Jul 17 '05 #4
I have to find zipcodes within a given mileage range (25, 50, etc). I know
it's possible to use the longitude/latitude to find this, and I have that
for the zipcodes, but does anyone have a "ready made" formula? I know it has
something to do with the sine/cosine, but the "signs" aren't clear enough to
me (neither are the wonders).

Thanks in advance for the wisdom.

J
Check this pdf link from ZipCodeWorld:

http://www.zipcodeworld.com/docs/distance.pdf.

It shows code examples for various languages and scripts. Can visit the zipcodeworld.com site for dot net controls etc. :) Hope this helps.
Jun 27 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Todd Nathan | last post: by
1 post views Thread by Francesc Guim Bernat | last post: by
1 post views Thread by livre | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.