Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 8A219476109; Thu, 12 Sep 2002 18:09:59 -0400 (EDT) Received: from rwcrmhc52.attbi.com (rwcrmhc52.attbi.com [216.148.227.88]) by postgresql.org (Postfix) with ESMTP id 8E5DD475AE5; Thu, 12 Sep 2002 18:09:58 -0400 (EDT) Received: from james ([12.213.220.58]) by rwcrmhc52.attbi.com (InterMail vM.4.01.03.27 201-229-121-127-20010626) with ESMTP id <20020912221000.HJWD25351.rwcrmhc52.attbi.com@james>; Thu, 12 Sep 2002 22:10:00 +0000 Content-Type: text/plain; charset="iso-8859-1" From: James Orr To: Tim Perdue , Larry Rosenman Subject: Re: [SQL] Latitude / Longitude Date: Thu, 12 Sep 2002 18:10:01 -0400 User-Agent: KMail/1.4.1 Cc: pgsql-general@postgresql.org, pgsql-sql@postgresql.org References: <20020912124426.A27570@mail.perdue.net> <1031852961.380.20.camel@lerlaptop.iadfw.net> <20020912144957.F27651@mail.perdue.net> In-Reply-To: <20020912144957.F27651@mail.perdue.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200209121810.01389.james@orrwhat.net> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200209/616 X-Sequence-Number: 30197 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