From: | lynch(at)cognitivearts(dot)com (Richard Lynch) |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Trigonometry |
Date: | 1999-04-23 06:49:49 |
Message-ID: | v02140b5fb34579b8c929@[207.152.64.133] |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
I'm using:
PostgreSQL 6.3.2 on i686-pc-linux-gnu, compiled by gcc 2.7.2.3
('cuz that's what my ISP gots)
and there don't seem to be any trigonomeric functions, so I'm really up a
creek for trying to calculate latitude/longitude distances using:
create function radians(float4) returns float4 as
'select 3.1415927 * $1 / 180'
language 'sql';
create function gpsdistance(float4, float4, float4, float4) returns float4 as
'select (3590 * (2 * atan2( sqrt(pow((sin(radians(($1 - $3))/2)),2) +
cos($4) * cos($2) * pow((sin(radians(($2 - $4))/2)),2)),
sqrt(1-(pow((sin(radians(($1 - $3))/2)),2) + cos($4) * cos($2) *
pow((sin(radians(($2 - $4))/2)),2))))))'
language 'sql';
The online docs don't seem to have anything about trig nor longitude
latitude, but I could have sworn somebody said that kind of stuff was in
PostgreSQL...
Any ideas, keeping in mind that installing a new PostgreSQL or adding stuff
to it that requires being root or even postgres super-user are not an
option?...
I *can* compile c code, so if somebody could 'splain to a Lisp hacker how
to make a gpsdistance.so that would maybe work?
-- "TANSTAAFL" Rich lynch(at)cognitivearts(dot)com webmaster@ and www. all of:
R&B/jazz/blues/rock - jademaze.com music industry org - chatmusic.com
acoustic/funk/world-beat - astrakelly.com sculptures - olivierledoux.com
my own nascent company - l-i-e.com cool coffeehouse - uncommonground.com
From | Date | Subject | |
---|---|---|---|
Next Message | Chairudin Sentosa | 1999-04-23 09:13:12 | Re: [INTERFACES] where did that date and time come from?? |
Previous Message | dustin sallings | 1999-04-23 06:17:45 | Re: [GENERAL] 9k limit? |