Skip to content

Instantly share code, notes, and snippets.

@ajashton
Created January 28, 2016 22:28
Show Gist options
  • Save ajashton/5763986633b466b2b459 to your computer and use it in GitHub Desktop.
Save ajashton/5763986633b466b2b459 to your computer and use it in GitHub Desktop.
-- Instance of ST_AsText that can handle an array of geometries
create or replace function ST_AsText(geometry[])
returns text
language plpgsql immutable as
$$
declare
g geometry;
res text := '{';
begin
if $1 is null or array_length($1, 1) = 0 then
return '{}';
end if;
foreach g in array $1 loop
res := res || ST_AsText(g) || ', ';
end loop;
return trim(trailing ', ' from res) || '}';
end;
$$;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment