Hello, I have the following function which check if two (or more) points are
one, the function just consider the x,y coordinates. can any body help me to
modify it to check z-index also. Thanks Ihab below is the function --
Function: assign_vertex_id(character varying, double precision, character
varying, character varying) -- DROP FUNCTION assign_vertex_id(character
varying, double precision, character varying, character varying); CREATE OR
REPLACE FUNCTION assign_vertex_id(geom_table character varying, tolerance
double precision, geo_cname character varying, gid_cname character varying)
RETURNS character varying AS $BODY$ DECLARE points record; i record; source_id
int; target_id int; pre varchar; post varchar; BEGIN BEGIN DROP TABLE
vertices_tmp; EXCEPTION WHEN UNDEFINED_TABLE THEN END; CREATE TABLE
vertices_tmp ( id serial ); EXECUTE $q$ SELECT
addGeometryColumn('vertices_tmp', 'the_geom', (SELECT srid FROM
geometry_columns WHERE f_table_name='$q$ quote_ident(geom_table)
$q$') , 'POINT', 4) $q$; CREATE INDEX vertices_tmp_idx ON vertices_tmp USING
GIST (the_geom); pre = ; post = ; FOR i in EXECUTE 'SELECT count(*) as t from '
quote_ident(geom_table) ' WHERE NumGeometries??(' quote_ident(geo_cname) ') is
not null' loop IF (i.t > 0) THEN pre = 'geometryN('; post = ' , 1)'; END IF;
END LOOP; FOR points IN EXECUTE 'SELECT ' quote_ident(gid_cname) ' AS id,' '
startPoint(' pre quote_ident(geo_cname) post ') AS source,' ' endPoint(' pre
quote_ident(geo_cname) post ') as target' ' FROM ' quote_ident(geom_table) loop
source_id := point_to_id(points.source, tolerance); target_id :=
point_to_id(points.target, tolerance); EXECUTE 'update '
quote_ident(geom_table) ' SET source_id = ' source_id ', target_id = '
target_id ' WHERE ' quote_ident(gid_cname) ' = ' points.id; END LOOP; RETURN
'OK'; END; $BODY$ LANGUAGE 'plpgsql' VOLATILE STRICT COST 100; ALTER FUNCTION
assign_vertex_id(character varying, double precision, character varying,
character varying) OW
NER TO postgres;
Discover the new Windows Vista Learn more!
_________________________________________________________________
Connect to the next generation of MSN Messenger
http://imagine-msn.com/messenger/launch80/default.aspx?locale=en-us&source=wlmailtagline
_______________________________________________
postgis-users mailing list
[email protected]
http://postgis.refractions.net/mailman/listinfo/postgis-users