I wrote the following code (after spending a few hours trying to get the quoting correct):
CREATE FUNCTION ast3angsep(double precision, double precision, double precision, double precision) RETURNS double precision AS $$
SELECT ST_Distance( ST_GeographyFromText('SRID=4326;POINT('||$1||' '||$2||')'), ST_GeographyFromText('SRID=4326;POINT('||$3||' '||$4||')') )/6370986.0/PI()*180.0;
$$
LANGUAGE SQL
IMMUTABLE
RETURNS NULL ON NULL INPUT;
This function works but, unfortunately, it's precision is HORRIBLE. It seems like there should be a much simpler way to do this. I just want to pass the values to the function and have it pass them to the ST functions. I was completely unable to find a way of doing this without converting them to string first, which is probably where the loss of precision enters.
Am I doing this totally screwed up?