Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Zip Code Database

Status
Not open for further replies.

RyanGlas

Technical User
May 1, 2003
29
0
0
US
Does anyone have any sugestions on where I can go to figure out the code to do a search with zip codes. I have a database with the zip codes, lat & long. I would like to know how to program a search so that when someone searches their zip code they can find anything within X amount of miles.
Thanks!
 
Are the lat and lon measurements the center of the zip code, or are there a bunch of them that describe the perimeter of the zip code?

Do you have the lat and lon measurements for the things you wish to give them distances to? That is if you were directing them to one of your stores, say, do you have the lat and lon numbers for the stores?

Note: to do this accurately requires some really complex software. I looked into doing it some years ago and to create an accurate distance you had to have a detailed map database and software/programming that actually plots out the route. We ended up partnering with MapBlast (or MapQuest, I don't remember which) because the project is seriously daunting.

The problem with a zip code lat/lon database is that it can work fairly well inside a large, densely-packed city because the middle of the zip code isn't that far from anyone's address. You basically
[ol][li]Calculate the number of degrees/minutes/seconds (converted to just seconds for the moment) between the two points,

[li]Figure out the sum of the right sides of the triangle with that measurement as the hypotenuse (the a and b in[tt] a[sup]2[/sup] + b[sup]2[/sup] = c[sup]2[/sup][/tt]) because roads tend to run at right angles to the place you're going, not directly diagonal, and

[li]Convert seconds to miles[/ol]
This system will generate a semi-meaningful number in a densely-packed city (though it completely ignores anything like the fact that the person might have to cross a river at a bridge that's 5 miles out of the way), but it fails if the user is starting out in a less densely-packed area because zip codes can cover dozens, even hundreds of square miles. If the user was living out in the country the system might estimate that the nearest location was 30 miles away when in fact it's 5 or 50.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top