Page 1 of 1

Understanding complex pgrouting query(pgr_dijkstra)

Posted: Sun Sep 06, 2015 2:51 pm
by gautamz07
I was just going through the documentation herehttp://workshop.pgrouting.org/chapters/ ... hted-costs .

Code: Select all

SELECT seq, id1 AS node, id2 AS edge, cost FROM pgr_dijkstra('
                SELECT gid AS id,
                         source::integer,
                         target::integer,
                         length * c.cost AS cost
                        FROM ways, classes c
                        WHERE class_id = c.id',
                30, 60, false, false);
What is happaning at this part of the query :

Code: Select all

 length * c.cost AS cost
 FROM ways, classes c
 WHERE class_id = c.id',
Its a bit hard to understand , can somebody explain please ?

Re: Understanding complex pgrouting query(pgr_dijkstra)

Posted: Sun Sep 06, 2015 7:54 pm
by requinix
That's just another query.

This one pulls from two tables: ways.class_id is something that classifies an edge rather than having the cost of the edge right in the table, and classes.cost is the cost per length unit of the edge. Like if an edge has class #12 and length 5, and classes says the cost is 2, then the true cost of the edge is 5*2=10.
Otherwise it works the exact same way as the other examples.