Re: BUG #2037: user function call unexpected "input out of range" - Mailing list pgsql-bugs

From Bruno Wolff III
Subject Re: BUG #2037: user function call unexpected "input out of range"
Date
Msg-id 20051112202300.GA11657@wolff.to
Whole thread Raw
In response to BUG #2037: user function call unexpected "input out of range"  ("Tom" <lackey@ltu.edu>)
List pgsql-bugs
On Fri, Nov 11, 2005 at 21:26:47 +0000,
  Tom <lackey@ltu.edu> wrote:
>
>         --Calculate distance
>         select     acos
>             (
>                 sin($1*pi()/180)*sin($3*pi()/180)
>                 +
>                 cos($1*pi()/180)*cos($3*pi()/180)
> *cos(($2-$4)*pi()/180)
>             )*60*1.1515*180/pi();

In addition to the other comments, you don't want to calculate distance this
way. It isn't very accurate when $2 and $4 are nearly equal which is the
normal case.
Do a search for haversine.

pgsql-bugs by date:

Previous
From: tomas@tuxteam.de (Tomas Zerolo)
Date:
Subject: Re: BUG #2037: user function call unexpected "input out of range"
Next
From: "Qingqing Zhou"
Date:
Subject: Re: storage sync failed on magnetic disk: Permission denied