Re: [SQL] Latitude / Longitude

From: James Orr <james(at)orrwhat(dot)net>
To: Tim Perdue <tim(at)perdue(dot)net>, Larry Rosenman <ler(at)lerctr(dot)org>
Cc: pgsql-general(at)postgresql(dot)org, pgsql-sql(at)postgresql(dot)org
Subject: Re: [SQL] Latitude / Longitude
Date: 2002-09-12 22:10:01
Message-ID: 200209121810.01389.james@orrwhat.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-sql

On Thursday 12 September 2002 15:49, Tim Perdue wrote:
> On Thu, Sep 12, 2002 at 12:49:21PM -0500, Larry Rosenman wrote:
> > Look at contrib/earthdistance, I **think** it does what you need.
>
> Thanks, yeah this starts to get me into the realm of what I need. It still
> has to run every possible permutation to figure out which one is closest
> for each postalcode. What I'll do is run that once and build a 3rd table
> which can be used to join the other two together using a view.

If you are looking for everything within a certain radius of a zip code, what
I have done in the past is calculate the highest/lowest longitude and
latitude and then select anything that falls between them and only check
those ones to see if they fall within the radius.

That's saves a lot of time over checking the exact distance for every zip
code.

- James

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Justin Hawkins 2002-09-13 01:03:33 OID order = INSERT order?
Previous Message Orr, Steve 2002-09-12 21:56:37 Developing for Multiple Databases: PostgreSQL and Oracle

Browse pgsql-sql by date

  From Date Subject
Next Message Christopher Kings-Lynne 2002-09-13 02:30:47 Re: DISTINCT
Previous Message Joe Conway 2002-09-12 20:54:25 Re: Latitude / Longitude