I have a points layer arround which I created a buffer of 10m. What I want to do is merge the buffers which intersects each other and the point layer.
I did this to be able to create polygon arround the points which are within 10 m.
CREATE OR REPLACE FUNCTION getbuffered() RETURNS SETOF sige.buffer AS
$BODY$
DECLARE
poly record;
pts record;
intersects boolean;
geom_poly geometry(MultiPolygon,32628);
geom_fusion geometry(MultiPolygon,32628);
BEGIN
FOR pts IN SELECT * FROM sige.object_elevation LOOP
FOR poly IN SELECT * FROM sige.buffer LOOP
intersects := (select true from sige.buffer,sige.object_elevation
where poly.id<>pts.id and st_intersects(poly.geom,pts.geom));
if true then
geom_poly := (select geom from sige.buffer where orig_fid = pts.id);
end if;
END LOOP;
END LOOP;
END
$BODY$
LANGUAGE 'plpgsql' ;
In this function I am iterating in points layer, then in buffer layer. then I select the features from buffer which have a different id from the points ones and intersect them. If the result is true I want to merge them.
I executed my function that I'm presuming correct but I get this :
ERROR: more than one line returned by a subquery used as an expression
CONTEXT: SELECT SQL statement (select true from sige.buffer, sige.object_elevation
where poly.id <> pts.id and st_intersects (poly.geom, pts.geom))
PL / pgsql function getbuffered (), line 10 to assignment
What am I'm missing?