This gem contains a rakefile that will generate a metro zipcode database.
Why is this useful? Metro areas are useful for locating population areas. So useful infact the USPS charges for access to this database. I found myself in need of it for two projects. I’m currently getting my data off wikipedia by hand. I hope someone more skilled with web scrappers can write one that can keep the database more upto date.
gem install metrozd git => 'git://gems.github.com/jbwyatt4/metrozd'
To generate the model and populate your rails apps.
bundle exec rake db:metro:create bundle exec rake db:metro:populate
To remove the table.
bundle exec rake db:metro:drop
You can add a metro area by city by adding a handleCityEntry(..) to the populateData function. An example
handleCityEntry("New York-Northern New Jersey-Long Island","New York City","NY", 10000..10499, 11004..05, 11100..11499, 11600..11699)
This function can handle an unlimited number of zipcodes (ranges or integer). Since according to the USPS zipcodes change all the time (at least in growing areas) using a function makes it easier to change.
-
Have the zipcodes for the top 50 US metro areas as defined by this wikipedia article. en.wikipedia.org/wiki/Table_of_United_States_Metropolitan_Statistical_Areas
-
Improve the database schema to be more efficient.
-
A webscrapper to autogenerate the function calls.
-
The database can be optimized. Instead of duplicating the metro, city, state with each zipcode you can just use an id and a relation. However i’m not sure how to generate a relationship automatically without going deeper into generators.
-
Wikipedia. We get our data from wikipedia… nuff said. But honestly it’s probably good enough and I think alot of people will enjoy a gem version of a needed database.
Copyright © 2012 John B. Wyatt IV LGPL v3+ by the Free Software Foundation. To make it easy for everyone by contributing to this repository you agree to license said contributions under these terms.