X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id CEFE6D1B478 for ; Sat, 27 Dec 2003 05:20:41 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 83918-07 for ; Sat, 27 Dec 2003 01:19:53 -0400 (AST) Received: from quality.qadas.com (quality.qadas.com [204.227.16.4]) by svr1.postgresql.org (Postfix) with ESMTP id 6CE54D1B43D for ; Sat, 27 Dec 2003 01:19:52 -0400 (AST) Received: from quality.qadas.com (localhost [127.0.0.1]) by quality.qadas.com (8.12.10/8.12.10) with ESMTP id hBR5JqB3013066 for ; Fri, 26 Dec 2003 22:19:52 -0700 (MST) Received: (from mfuhr@localhost) by quality.qadas.com (8.12.10/8.12.10/Submit) id hBR5Jqlt013065 for pgsql-sql@postgresql.org; Fri, 26 Dec 2003 22:19:52 -0700 (MST) Date: Fri, 26 Dec 2003 22:19:52 -0700 From: Michael Fuhr To: pgsql-sql@postgresql.org Subject: Re: Radius of a zip code Message-ID: <20031226221952.A5600@quality.qadas.com> References: <000b01c3cc09$e043fd70$0201a8c0@andy2> <20031226194244.A15916@quality.qadas.com> <20031227043404.GB5264@wolff.to> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20031227043404.GB5264@wolff.to>; from bruno@wolff.to on Fri, Dec 26, 2003 at 10:34:04PM -0600 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200312/196 X-Sequence-Number: 16362 On Fri, Dec 26, 2003 at 10:34:04PM -0600, Bruno Wolff III wrote: > On Fri, Dec 26, 2003 at 19:42:44 -0700, > Michael Fuhr wrote: > > > > I have several databases with lat/lon coordinates and frequently make > > "show me all records within a certain distance of this point" queries. > > I wrote a haversine() function that uses the Haversine Formula to > > calculate the great circle distance between two points on a sphere > > (assuming the earth is a perfect sphere is accurate enough for my uses). > > Here's a web site with related info: > > The distance operator in contrib/earthdistance got changed to use > haversine instead of the naive formula in 7.3. In 7.4 it also provides > some functions that work with contrib/cube that allow for indexed > searches. I'll have to take a closer look at contrib/earthdistance. I'm using the function I wrote for legacy reasons -- I had ported an application from another DBMS to PostgreSQL and wanted to make as few changes as possible, so I ported the haversine() function that I had already written. Incidentally, I see the following in README.earthdistance: A note on testing C extensions - it seems not enough to drop a function and re-create it - if I change a function, I have to stop and restart the backend for the new version to be seen. I guess it would be too messy to track which functions are added from a .so and do a dlclose when the last one is dropped. Maybe you've already figured it out, but LOAD should allow you to reload a .so file without having to restart the backend. http://www.postgresql.org/docs/current/static/sql-load.html -- Michael Fuhr http://www.fuhr.org/~mfuhr/