[pgrouting-users] shortest_path query

Hello there. I’ve got the query for shortest path using pgrouting to run finally. I get the edges but now I need to map my result onto a mapserver layer. I’ve tried examples from the internet but mostly they’re flawed. I’m positng the query which has worked for me. Please suggest a way to convert it into a visible layer using mapserver.

SELECT * FROM shortest_path(‘SELECT gid AS id, fromnodeid::int4, tonodeid::int4, length0::float8 AS cost FROM edges_line’, 35, 210, false, false)

I tried to form a query-layer but failed. I’m sending the code I used to. Please correct me.

DATA “the_geom FROM (SELECT * FROM shortest_path(‘SELECT gid AS id, fromnodeid::int4, tonodeid::int4, length0::float8 AS cost FROM edges_line’, 35, 210, false, false)) AS foo using unique gid using srid=4326”

Here is the layer definition:

LAYER
NAME “route”
CONNECTIONTYPE postgis
CONNECTION “user=postgres password=*********** dbname=VSDelhidb host=localhost”
DEBUG 5
STATUS DEFAULT
TYPE LINE
DATA “the_geom FROM (SELECT * FROM shortest_path(‘SELECT gid AS id, fromnodeid::int4, tonodeid::int4, length0::float8 AS cost FROM edges_line’, 35, 210, false, false)) AS foo using unique gid using srid=4326”

TEMPLATE “t”

//////////////////////////////////////////////////////THE CLASS THAT CLASSIFIES EVERYTHING IN IT. ////////////////////////////////

CLASS

/////////////////////////////////////////////////////THE STYLE OF DRAWING THIS CLASS. ////////////////////////////////////

NAME “0”
STYLE
SYMBOL “circle”
SIZE 10
OUTLINECOLOR 255 0 0
COLOR 165 42 42
END #END OF THE SYLE DECLARATION FOR THIS CLASS.#####################################################################

END #END OF THE CLASS THAT CLASSIFIES EVERYTHING._##############################################################
END #END OF THE LAYER THAT DRAWS EVERYTHING.
##############################################################################

Annu,

Now that you have a working pgRouting query, go back and look at the queries I gave you before on the mapserver list. you have to join the pgrating results back to the edge table to get geometrys for mapserver to render.

-Steve W

On 6/12/2012 3:10 PM, Annu Anurag wrote:

Hello there. I've got the query for shortest path using pgrouting to run
finally. I get the edges but now I need to map my result onto a
mapserver layer. I've tried examples from the internet but mostly
they're flawed. I'm positng the query which has worked for me. Please
suggest a way to convert it into a visible layer using mapserver.

SELECT * FROM shortest_path('SELECT gid AS id, fromnodeid::int4,
tonodeid::int4, length0::float8 AS cost FROM edges_line', 35, 210,
false, false)

I tried to form a query-layer but failed. I'm sending the code I used
to. Please correct me.

DATA "the_geom FROM (SELECT * FROM shortest_path('SELECT gid AS id,
fromnodeid::int4, tonodeid::int4, length0::float8 AS cost FROM
edges_line', 35, 210, false, false)) AS foo using unique gid using
srid=4326"

Here is the layer definition:

         LAYER
             NAME "route"
             CONNECTIONTYPE postgis
             CONNECTION "user=postgres password=***********
dbname=VSDelhidb host=localhost"
             DEBUG 5
             STATUS DEFAULT
             TYPE LINE
             DATA "the_geom FROM (SELECT * FROM shortest_path('SELECT
gid AS id, fromnodeid::int4, tonodeid::int4, length0::float8 AS cost
FROM edges_line', 35, 210, false, false)) AS foo using unique gid using
srid=4326"

             TEMPLATE "t"

              #
             # //////////////////////////////////////////////////////THE
CLASS THAT CLASSIFIES EVERYTHING IN IT. ////////////////////////////////
              #

             CLASS

                  #
                 #
/////////////////////////////////////////////////////THE STYLE OF
DRAWING THIS CLASS. ////////////////////////////////////
                  #

                 NAME "0"
                 STYLE
                     SYMBOL "circle"
                     SIZE 10
                     OUTLINECOLOR 255 0 0
                     COLOR 165 42 42
                 END #___END OF THE SYLE DECLARATION FOR THIS
CLASS.___#####################################################################

             END #_________END OF THE CLASS THAT CLASSIFIES
EVERYTHING.___________##############################################################
         END #________END OF THE LAYER THAT DRAWS
EVERYTHING._________##############################################################################

_______________________________________________
Pgrouting-users mailing list
Pgrouting-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/pgrouting-users