Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / July 2007

Tip: Looking for answers? Try searching our database.

Search within 50 miles of xxxx zipcode

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tina - 24 Jul 2007 19:18 GMT
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
Lit - 24 Jul 2007 19:28 GMT
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

>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
[quoted text clipped - 3 lines]
> Thanks,
> Tina
Kevin Spencer - 25 Jul 2007 12:59 GMT
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)
    }

Signature

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

> Tina,
>
[quoted text clipped - 24 lines]
>> Thanks,
>> Tina
Lit - 25 Jul 2007 19:27 GMT
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.

> Here are a few methods that calculate distance between 2 points of
> Latitude and Longitude. Calculations of distance between points of
[quoted text clipped - 62 lines]
>>> Thanks,
>>> Tina
Mark Fitzpatrick - 25 Jul 2007 02:37 GMT
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.

Signature

Hope this helps,
Mark Fitzpatrick
Microsoft FrontPage MVP 199?-2006. 2007 and beyond

>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
[quoted text clipped - 3 lines]
> Thanks,
> Tina
Larry Bud - 25 Jul 2007 19:19 GMT
> 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.
Tina - 26 Jul 2007 00:46 GMT
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

>> In addition to Lit's great comments, don't even bother checking with the
>> US
[quoted text clipped - 8 lines]
> need to updated all that often, especially for a general "distance
> from here to there" lookup.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.