From: Mark Ericson Date: 2005-12-14T03:09:32+09:00 Subject: Re: US Zipcode API for Ruby? ------=_Part_17745_26238748.1134497327587 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Excellent! The only thing remaining is an efficient algorithm for a search for all zipcodes within a given radius. I suppose one technique might be to first narrow the databse search within = a given a given square latitude/longitude range and then filter those results by testing that they are within the given circle radius On 12/13/05, Dan Diebolt wrote: > > There is a 40,000+ zip code database in CivicSpace labs that has lat and > long by zip code: > > http://civicspacelabs.org/home/developers/download > > http://civicspacelabs.org/releases/zipcodes/zipcodes-csv-10-Aug-2004.zi= p > > Distance between two points (lat, long) is calculated using the > Haversine formula: > > dlon =3D lon2 - lon1 > dlat =3D lat2 - lat1 > a =3D (sin(dlat/2))^2 + cos(lat1) * cos(lat2) * (sin(dlon/2))^2 > c =3D 2 * atan2(sqrt(a), sqrt(1-a)) > d =3D R * c > > See the following link or google for more: > > http://mathforum.org/library/drmath/view/51879.html > > > --------------------------------- > Yahoo! Shopping > Find Great Deals on Holiday Gifts at Yahoo! Shopping > ------=_Part_17745_26238748.1134497327587--