Re: Postal code radius searches - Mailing list pgsql-general

From Vince Vielhaber
Subject Re: Postal code radius searches
Date
Msg-id Pine.BSF.4.40.0202061425140.88238-100000@paprika.michvhf.com
Whole thread Raw
In response to Postal code radius searches  (Milo Hyson <milo@cyberlifelabs.com>)
List 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@michvhf.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
==========================================================================




pgsql-general by date:

Previous
From: Milo Hyson
Date:
Subject: Postal code radius searches
Next
From: "Michael McAlpine"
Date:
Subject: Indexs and prolems with.