Skip site navigation (1) Skip section navigation (2)

Re: BUG #2037: user function call unexpected "input out of range"

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Tom <lackey(at)ltu(dot)edu>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #2037: user function call unexpected "input out of range"
Date: 2005-11-12 20:23:00
Message-ID: 20051112202300.GA11657@wolff.to (view raw or flat)
Thread:
Lists: pgsql-bugs
On Fri, Nov 11, 2005 at 21:26:47 +0000,
  Tom <lackey(at)ltu(dot)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.

In response to

pgsql-bugs by date

Next:From: Qingqing ZhouDate: 2005-11-12 20:34:51
Subject: Re: storage sync failed on magnetic disk: Permission denied
Previous:From: Qingqing ZhouDate: 2005-11-12 18:27:39
Subject: Re: storage sync failed on magnetic disk: Permission denied

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group