The st_makeShortestLine() function used: create or replace function st_makeShortestLine(g1 geometry, g2 geometry) returns geometry as $$
with dist as ( select st_distance(st_endPoint($1), st_endPoint($2)) as dee, st_distance(st_endPoint($1), st_startPoint($2)) as des, st_distance(st_startPoint($1), st_endPoint($2)) as dse, st_distance(st_startPoint($1), st_startPoint($2)) as dss ) select case when st_distance(st_startPoint($1), st_startPoint($2)) = 0 then st_makeline($1, st_reverse($2)) when st_distance(st_startPoint($1), st_endPoint($2)) = 0 then st_makeline($1, $2) when dee < des and dee < dse and dee < dss then st_makeline($1, st_reverse($2)) when des < dee and des < dse and des < dss then st_makeline($1, $2) when dss < dee and dss < dse and dss < des then st_makeline(st_reverse($1), $2) else st_makeline($2, $1) end from dist; $$ language SQL; Nicolas
_______________________________________________ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users