Search within 50 miles of xxxx zipcode

T

Tina

I need to be able to provide a proximity search by zip code. I have a table
of job opportunities with the zip code where they exist. So I need to be
able to list zip codes that are within xx miles of 99999 zip code.

How is this done?
Thanks,
Tina
 
L

Lit

Tina,

You need a zipcode table with longitude and Latitude Info about every
zipcode and this info actually is available.
then you need to calculate using the Longitude and Latitude,
I contacted JPL in Pasadena one time and they actually referred me to some
formulas already written in C++ , and other languages, but that was years
ago.
If you contact NASA or search on their we site you may find Formulas that
can give you the distance between earth coordinates.
there are many and since the earth is not a perfect sphere some formulas are
more accurate than others.
but if you get an approximate numbers then that should be fine. there is no
such thing as exact.

Search the web you might find a component that does that for you already.

hope that helps

Lit
 
M

Mark Fitzpatrick

In addition to Lit's great comments, don't even bother checking with the US
Postal Service. They don't maintain a zip to latitude/longitude database.
There are a number of companies that do sell them, and then there are
additional formulas to do the math to figure out where the zips are. Be
prepared though, I've seen this get very expensive.
 
K

Kevin Spencer

Here are a few methods that calculate distance between 2 points of Latitude
and Longitude. Calculations of distance between points of Latitude and
Longitude are always approximate, as the surface of the earth is curved, and
the earth is an oblate spheroid, rather than a sphere, and therefore,
distance is distance along a curve that varies from one point on the surface
to another. There are methods of calculating distance that are more or less
accurate, and they become increasingly complex as they become increasingly
accurate. The following methods treat the earth as a sphere, and use a mean
earth radius (average of the radius based upon the radius at the poles and
equator). They should be accurate enough for this purpose.

Note that there is a reference to a struct called "LatLong," which is simply
a struct containing 2 doubles:

public const double MeanEarthRadiusFeet = 20903215.2;

public static double DistanceRadians(LatLong PointA, LatLong PointB)
{
double aLat, aLong, bLat, bLong;

aLat = PointA.Lat * (Math.PI / 180);
aLong = PointA.Long * (Math.PI / 180);
bLat = PointB.Lat * (Math.PI / 180);
bLong = PointB.Long * (Math.PI / 180);

return Math.Acos(Math.Cos(aLat) * Math.Cos(bLat) *
Math.Cos(aLong - bLong)
+ Math.Sin(aLat) * Math.Sin(bLat));
}

public static double Distance(LatLong PointA, LatLong PointB)
{
double radians = DistanceRadians(PointA, PointB);
return radians * MeanEarthRadiusFeet; // Distance in feet
(convert to whatever)
}

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net
 
L

Larry Bud

In addition to Lit's great comments, don't even bother checking with the US
Postal Service. They don't maintain a zip to latitude/longitude database.
There are a number of companies that do sell them, and then there are
additional formulas to do the math to figure out where the zips are. Be
prepared though, I've seen this get very expensive.

http://www.zipinfo.com/products/products.htm

It's prety cheap, actually, and zips don't change so much that they
need to updated all that often, especially for a general "distance
from here to there" lookup.
 
L

Lit

Tina:
In addition remember the formula given is only a line-off-sight, or lack
off, Air-Distance you are getting.
If the 50 radius takes you over a mountain range, or a body of water, then
your driving distance can vary a great deal.
If this is an application that can cost you $$ for driving etc.. then you
need to study the area you are dealing with and look for some
costly-exceptions to avoid.

Some formulas are available for the USA for more accuracy + your exceptions
to avoid bad and costly decisions.

Lit.
 
T

Tina

Larry,
Thanks. The one with GeoCode looks like it might be what I need. I'm
looking to do the same kind of thing that is so commonly done on sites like
Monster, Autotrader, etc.
T
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top