0

I use QGIS plugin pgRoutingLayer for displaying the shortest route. Dijkstra algorithm works fine.

I tried tsp (euclid) algorithm but it drew nothing (even no error message). I thought it may be something wrong with my data. So I uploaded pgRouting sample data into my database (http://docs.pgrouting.org/dev/doc/src/developer/sampledata.html) and tried tsp on them. But result was the same (no route and no error message).

So I debugged the pgRoutingLayer plugin, caught the sql query. It looks like this and it results in 0 records

SELECT seq, id1 AS internal, id2 AS node, cost FROM pgr_tsp('
               SELECT DISTINCT id, x, y FROM
                   (SELECT DISTINCT source AS id, x1::float8 AS x, y1::float8 AS y FROM edge_table
                   UNION
                   SELECT DISTINCT target AS id, x2::float8 AS x, y2::float8 AS y FROM edge_table)
                   AS node WHERE node.id IN (7,8,11)',
               2, 12)

I may be missing some basics, I am a routing newbie. Can anyone give me a hand please? Thanks.

1 Answer 1

3

You should include "source_id" and "target_id" values in "ids" value.
So, could you try to change "ids" value from "7,8,11" to "2,7,8,11,12"?

I will try to think about reporting error message in this case.

3
  • I tried that. But when I included those values query ended with this error: "Error: matrix[num][num] in its definition".
    – Rob
    Aug 7, 2014 at 9:36
  • Okay. Then I will try to test it with the sample data.
    – sanak
    Aug 7, 2014 at 10:18
  • After I reinstalled database the matrix error dissapeared. So including target and source into the set is the right way. Thanks
    – Rob
    Sep 23, 2014 at 12:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.