I’m trying to find out: given a zipcode, what are all the zipcodes within an X-mile radius of that zipcode.
I’ve found a few solutions, which I’ve posted below, but I want to know if there are any better solutions specifically for Rails or Ruby (in other words, a gem, a gist, etc.). The Ruby solutions I’ve found are a few years old, so it seems like there could be a better solution available now.
Ideally I’d want something that just takes a string “11026” and produces strings as output, without me having to create AR models or deal with the database too extensively.
Geocoder doesn’t seem to do this explicitly… neither does Geokit. I don’t know if there’s a simple work-around for either of these gems.
Similar solutions:
Sql-wise, someone already asked that similar question here. Kinda simple to implement and would give you good enough results to test your spec.
Otherwise, if you can find a library that has lat/long for each zip, it’d be easy to look at it from a geo-proximity point of view. Then, you should look for Postgresql proximity search.
Find more: http://www.boutell.com/zipcodes/ and http://www.geopostcodes.com/