1 post tagged “census”
Several years and fewer gray hairs ago, I developed an application just like Citysearch for a client. It was focused on restaurants which catered to the wine crowd, with byob service.
The client requested the ability to search restaurants through a radius. "I want all restaurants within 15 miles of Hoboken, New Jersey." At 20 years of age, I probably shouldn't have told him "no problem" before doing my homework. Fortunately, naivete is counterbalanced with determination at 20. You work dumber and harder as opposed to working smarter when you get older. But I digress...
Free as in Beer
Did you know that the United States Census Bureau gives away its city, state, zip code, latitude and longitude data for free? No foolin'. Just visit the U.S. Gazetteer Web site and download the flat files with the data. This data coupled with a math equation to determine the distance between latitudinal and longitudinal points is all you need to add regionality to your application. For PHP developers, there's a open source project called phpZipLocator to speed up the process.
How We're Using it
At 52 Clix, we're adding an Events calendar section and we'd like for our users to be able to choose to display only events relevant to their region. We prompt the user once for their home zip code. With the census data called "Zips," we look up and store the latitude and longitude.
When an event is created, the poster enters the city and state. We use the census data called "Places" to look up and store the latitude and longitude. We do not ask for the zip code because it's often the case that someone doesn't know the zip for a particular place. Some cities have different zip codes every 10 blocks!
Once the lat/lon is known for each of the points, we simply query our database with the distance math equation. We're using the query found in the GPL'd package Zipdy written by V. Alex Brennen.