It's been a while we are using PostGIS to store our Geometry information in our Postgres database. We have developed vertex-to-vertex routing ourselves using iGraph library. Yesterday I read about pgRouting and I am porting our current application to pgRouting. However, I face some issues in using shooting start path finder.

We stored edges and vertices information in tables and for finding a graph route with turn restriction, we are calling following SQL script:

SELECT  shortest_path_shooting_star(
    'SELECT e.id,
                e.first as source,
                e.second as target,
                ST_Length(e.geom) as cost, 
                st_x(st_pointn(e.geom, 1)) AS x1, st_y(st_pointn(e.geom, 1)) AS y1,
                st_x(st_pointn(e.geom, 2)) AS x2, st_y(st_pointn(e.geom, 2)) AS y2,
                (not connected)::boolean::int * 1000000 AS to_cost,
                c.first AS rule
        FROM edges e LEFT OUTER JOIN edge_connections c ON e.id = c.second
        WHERE e.group_id = 0
        ORDER BY e.id',
    1209560, 1209653, true, false);

My inner subqery woud have following results:

  id    | source  | target  |   cost |  x1   |  y1   |  x2   |  y2   | to_cost |  rule  
1087134 |  926686 |  926687| 2.3299 |51.4675|35.728 |51.4675|35.7280|         |    
1209706 | 1039731 | 1039870 | 4.005 |51.4082|35.7239|51.4082|35.7239| 1000000 | 1209564

In the results, when a constraint exists, rule and to_cost would not be NULL. When a turn restriction exists, the results would be exactly like what specified in the docs.

However, when I call the shortest_path_shooting_star function, results would not differ if a rule-and-to_cost exists or not. I have changed directed and has_reverse_cost parameters but nothing happened.

I was wondering if you guys could help me in this matter. Any advice or even a clue would be very much appreciated.

1 Answer 1


You seem to be lacking the "reverse_cost" column in your subquery.

From docs:

reverse_cost (optional): the cost for the reverse traversal of the edge. This is only used when the directed and has_reverse_cost parameters are true (see the above remark about negative costs).

Your Answer

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