Re: Postal code radius searches

From: Vince Vielhaber <vev(at)michvhf(dot)com>
To: Milo Hyson <milo(at)cyberlifelabs(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Postal code radius searches
Date: 2002-02-06 19:37:30
Message-ID: Pine.BSF.4.40.0202061425140.88238-100000@paprika.michvhf.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, 6 Feb 2002, Milo Hyson wrote:

> I've been struggling with this problem for a while now and I can't seem to
> find a solution. I have a postal-code database, currently populated with over
> 76,000 United States ZIP codes. Each record contains, among other things, the
> latitude and longitude for the postal code. I have a stored procedure that
> calculates the distance between any two points on the globe. I'm trying to
> figure out a fast way to locate all of the postal codes within an arbitrary
> radius of another postal code.

I do something similar. Take the lon/lat of the center point and add an
arbitrary amount to the lon/lat that would put me over the desired
distance and have my select call return all of those records. Then
I calculate the distances only with those returned. I don't have the
database do the final calculation, that's done in a C routine because
I do a few other site specific things with the info first. The database
contains locations of campgrounds. If you use this method, remember
the farther south you go in the us the larger your arbitrary number
needs to be.

Vince.
--
==========================================================================
Vince Vielhaber -- KA8CSH email: vev(at)michvhf(dot)com http://www.pop4.net
56K Nationwide Dialup from $16.00/mo at Pop4 Networking
Online Campground Directory http://www.camping-usa.com
Online Giftshop Superstore http://www.cloudninegifts.com
==========================================================================

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Michael McAlpine 2002-02-06 19:37:43 Indexs and prolems with.
Previous Message Roderick A. Anderson 2002-02-06 19:35:12 Re: Postal code radius searches