Database Reference
In-Depth Information
),
aggstring AS (
SELECT '[' || STRING_AGG(pstring, ',' ORDER
BY gid) || ']' AS inputtext
FROM endingbracket
)
SELECT chp04.voronoi_fast(inputtext) FROM
aggstring;
Step three - bundling as a function
Let'sbundlethisasafunction.Toaccomplishthis,we'llhavetoreturnacustomtype,
which is a row consisting of our output string, and the integer from our temporary
ending bracket table:
CREATE TYPE vor AS (
geomstring text,
gid integer
);
Thistypewillbethereturntypeforournewfunction.Now,let'smoveontocreating
afunctionusingthisnewtype.Thisshouldlookveryfamiliar—it'sourpreviouscode
up to the step where we run running our STRING_AGG function.
CREATE OR REPLACE FUNCTION chp04.voronoi_prep
(geometry, integer) RETURNS vor AS $$
WITH astext AS (
SELECT ST_AsText(the_geom) AS pstring, gid
FROM (
SELECT (ST_DumpPoints($1)).geom AS
the_geom, $2 AS gid
) AS point_dump
),
astextcomma AS (
SELECT replace(pstring, ' ', ',') AS pstring,
Search WWH ::




Custom Search