This is one of the flaws of pgRouting. I would have been much easier for the C++ implementation (shortest_path
is directly mapped over a C++ function) to return a sequence number column than to have to resort to re-ordering in SQL.
The other option is to do it in PLPGSQL.
You build an array out of the results and then you use the position in the array as the ordering indicator:
select array_agg(edge_id) from shortest_path('
SELECT gid as id,
source,
target,
length as cost
FROM trail_network',
src, dst,false,false) into edges;
FOR i in 1..array_upper(edges, 1) LOOP
select name, symbol, st_length(the_geom) from trail_network where gid = edges[i] into tn;
RAISE NOTICE 'Edge % on trail [%] symbol [%]', edges[i], tn.name, tn.symbol;
END LOOP;