Re: Making small bits of code available - Mailing list pgsql-general

From Bruno Wolff III
Subject Re: Making small bits of code available
Date
Msg-id 20020907120101.GA28944@wolff.to
Whole thread Raw
In response to Re: Making small bits of code available  (Bruce Momjian <pgman@candle.pha.pa.us>)
Responses Re: Making small bits of code available  (Bruce Momjian <pgman@candle.pha.pa.us>)
List pgsql-general
On Fri, Sep 06, 2002 at 09:58:00 -0400,
  Bruce Momjian <pgman@candle.pha.pa.us> wrote:
>
> /contrib/earthdistance already exists.  Is this new functionality?

This works with cube instead of point. If you use point hold latitude and
longitude you have to worry about whether you will have data near 180
degrees of longitude or near the poles. This may not be a problem if
your data is mostly on one continent.

The script I have is most grant calls for the cube functions. Since cube
needs to be installed as postgres (or other super user), most likely
you want to grant execute to public on the provided functions. (I don't
know if you need to do this for ones just used be the gist stuff.)

The stuff people might want to see are a few sql functions for getting
to and from latitude and longitude and cube (as domain earth) and some
functions related to getting the size of boxes to use for searching for
points within a great circle distance of a specified point.

If 5K isn't too much I could post it to the list and it will get archived
and people that are interested can find it with google and can take what they
want from the code.

This stuff isn't packaged up neatly for a contrib with a regression test
and all. Probably people who use this will want to tinker with it before
using it themselves.

The function prototypes extracted from the file are:
create function earth() returns float8 language 'sql' immutable as
create function sec_to_gc(float8) returns float8 language 'sql'
create function gc_to_sec(float8) returns float8 language 'sql'
create function ll_to_earth(float8, float8) returns earth language 'sql'
create function latitude(earth) returns float8 language 'sql'
create function longitude(earth) returns float8 language 'sql'
create function earth_distance(earth, earth) returns float8 language 'sql'
create function earth_box(earth, float8) returns cube language 'sql'

pgsql-general by date:

Previous
From: Joel Rodrigues
Date:
Subject: Fwd: "...integer[] references..." = error
Next
From: Bruce Momjian
Date:
Subject: Re: Making small bits of code available