0

I own two tables one with streets and one points, i use the table with the roads to calculate routes with dijkstra algorithm. But I want when someone add one point in the table Point and this point is part of road from streets table ,then how i make the dijkstra algorithm not to take into consideration this road wich contain this point, when it calculate a route.


If i want to go from A --> B is give me the read way the dikjstra . i want if i put a point like the point of image the dijkstra change the way and give me the orange way. Can i make this?

enter image description here

  • Do you mean that the new point is like a block which prevents the road from being used? Adding a sketch might help to clarify what you are looking for. – underdark Feb 1 '15 at 20:31
  • Make this road a barrier, i.e. assign very high cost of travel through it. – FelixIP Feb 1 '15 at 21:13
  • Yes i try it i sum 10000 in legnth of the table but is take the same way. – vagelis Feb 1 '15 at 21:33
  • Check connectivity in your network. Based on your answer there are posiibilities a)'red' is the only possible option b) your code is wrong – FelixIP Feb 1 '15 at 23:57
2

If you can intersect the point with the table containing the records with the line geometry, then you can obtain some unique record of the line that intersects the point. Say the column containing unique identification is id, and the line that intersects the point has an id = 12. Then your pgRouting query would be something like this (modified from the examples listed here):

SELECT seq, id1 AS node, id2 AS edge, cost
    FROM pgr_dijkstra(
            'SELECT id, source, target, cost
            FROM edge_table
            WHERE id <> 12',
            7, 12, false, false
    );

The WHERE id <> 12 is the key part: it excludes that particular edge from consideration in your shortest path query.

Note that this may prevent a solution from being found at all, in which case a very high cost may be more appropriate than excluding it altogether.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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