Hi all,
I have a table of nodes and I am trying to add a column with the closest
node id and distance info.
I am trying this by using a function to calculate id and distance and
by displaying them in a view:
CREATE OR REPLACE FUNCTION closest_node(integer,geometry) RETURNS TABLE
(id integer,distance double precision) AS
$$ SELECT node_id AS id ,
MIN(ST_Distance($2,nodes.wkb_geometry)) AS distance
FROM nodes
WHERE node_id != $1
GROUP BY node_id ;$$
LANGUAGE SQL;
CREATE OR REPLACE VIEW nodes_view AS
SELECT *, closest_node(node_id,wkb_geometry)
FROM pipe_nodes;
I get the following error:
ERROR: column "closest_node" has pseudo-type record
Can someone explain me why?
I had a look at this post
http://stackoverflow.com/questions/7097126/including-a-set-of-rows-in-a-view-column
and I tried using the type and cast, but I get the same error.
Thanks!
Denis
PS: if someone has a better idea, I'll take it with no shame!
_______________________________________________
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users