Re: Finding points within 50 miles

From: Vivek Khera <vivek(at)khera(dot)org>
To: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Finding points within 50 miles
Date: 2005-06-27 14:32:43
Message-ID: 969488A8-E0AD-45E9-98EF-581AFF21F2FC@khera.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Jun 27, 2005, at 3:47 AM, Janning Vygen wrote:

> I had some problems with the calculation inside acos() sometimes
> being greater
> than 1, which should not occur. Please use a
> CASE WHEN sin(...) > 1 THEN 1 ELSE sin(...) END
> if you have the same problem.
>

We've seen this as well with the distance radius calculation. It
doesn't happen in 8.x but did happen 7.4, and then was easily worked
around by reducing the precision of the arguments. Ie, we would use
73.13 rather than 73.1343593421 as pulled from the database for the
lat/lon values of the center point.

In any case, I urge you to derive the formulas yourself from basic
research so you *know* you're getting what you think you're getting.

Vivek Khera, Ph.D.
+1-301-869-4449 x806

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Vivek Khera 2005-06-27 14:41:20 Re: Finding points within 50 miles
Previous Message Tom Lane 2005-06-27 14:29:59 Re: number of records returned by cursors