[pgrouting-users] Why does shooting star return the last segment twice?

Stephen Woodbridge woodbri at swoodbridge.com
Thu May 7 11:07:13 EDT 2009


Any idea why shooting_star would return the last segment twice???

-Steve


routing=# SELECT gid, the_geom
routing-#                     FROM shooting_star_sp_cd(
routing(#                         'st',
routing(#                         11213,
routing(#                         11218,
routing(#                         0.0724637681159,
routing(#                         'cost_time',
routing(#                         'rcost_time',
routing(#                         false);
   gid  | 
     the_geom
-------+----------------------------------------------------------------------------------------------------------------------------------------------
  11212 | 
0105000020E610000001000000010200000003000000A83BA88CC54B5140782922711A44414058048149C74B51403832B9011F444140B8ECA0B9CF4B5140D84BD5C734444140
  33942 | 
0105000020E610000001000000010200000002000000F82D2A95B54B514008144FD950444140B8ECA0B9CF4B5140D84BD5C734444140
  11217 | 
0105000020E610000001000000010200000002000000E06B2FD39E4B514090B0354869444140F82D2A95B54B514008144FD950444140
  11218 | 
0105000020E610000001000000010200000002000000E8004137864B514068B4ABB383444140E06B2FD39E4B514090B0354869444140
  11218 | 
0105000020E610000001000000010200000002000000E8004137864B514068B4ABB383444140E06B2FD39E4B514090B0354869444140
(5 rows)


shooting_star_sp_cd() function is just a straight wrapper around your 
standard function.


CREATE OR REPLACE FUNCTION shooting_star_sp_cd(
     geom_table varchar, sourceid int4, targetid int4, delta float8,
     cost_column varchar, rcost_column varchar, dir boolean)
     RETURNS SETOF GEOMS AS
$$
DECLARE
         path_result record;
         geom geoms;
     query text;
     id integer;

BEGIN
     query := generic_sp_query('shortest_path_shooting_star', geom_table,
         sourceid, targetid, delta, cost_column, rcost_column, dir);

     id :=0;
     FOR path_result IN EXECUTE query
         LOOP

                  geom.gid      := path_result.gid;
                  geom.the_geom := path_result.the_geom;
          id := id+1;
          geom.id       := id;

                  RETURN NEXT geom;

         END LOOP;
         RETURN;
END;
$$
LANGUAGE 'plpgsql' VOLATILE STRICT;



More information about the Pgrouting-users mailing list